Skip to content
34 changes: 17 additions & 17 deletions .claude/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,15 @@ NOP/ (Network Observatory Platform)
docker-compose up -d # Start all services
docker-compose -f docker-compose.test.yml up -d # Test environment

# Test
python backend/tests/test_complete_platform.py # Full platform test
python backend/tests/test_advanced_features.py # Advanced features test
python backend/tests/test_access_hub.py # Access hub test

# Run Individual Services
docker-compose up backend # Backend only (port 12000)
docker-compose up frontend # Frontend only (port 12001)

# Development
cd frontend && npm run dev # Frontend dev server
cd backend && uvicorn app.main:app --reload # Backend dev server

# Testing
# Note: Formal test infrastructure planned for future implementation
# Current testing: Manual integration testing via Docker Compose
# Test scripts available in scripts/ directory for specific features

# Knowledge Management
# Run update_knowledge and update_skills workflows via agent orchestration
# See .github/workflows/ for workflow definitions
Expand All @@ -70,23 +66,27 @@ cd backend && uvicorn app.main:app --reload # Backend dev server
- [x] Host monitoring and terminal access
- [x] Docker-based deployment complete
- [x] Test environment with 4 service containers
- [x] Comprehensive test suites (100% passing)
- [x] Documentation and deployment guides
- [x] Manual integration testing via Docker Compose
- [x] Documentation consolidated and optimized
- [x] Knowledge graph system (project + global)
- [x] Skills framework configured
- [ ] Formal unit/integration test infrastructure (planned)

## Session Notes
**Task**: Execute update workflows (knowledge, skills)
**Task**: Execute update workflows (knowledge, skills, agents effectiveness)
**Changes**:
- context.md: Updated with full project details
- skills/domain.md: Added 8 NOP-specific domain skills
- Removed legacy memory system (scripts/update_memory.py, .openhands/microagents/memory_manager.md)
- skills/domain.md: 8 NOP-specific domain skills (network services, React patterns)
- skills/devops.md: 7 DevOps/workflow effectiveness patterns (Docker, validation, etc.)
- Removed legacy memory system (deprecated)
- Agent files kept clean (cross-project, no bloat)
- Project-specific patterns moved to skills/ directory
**Decisions**:
- Memory system deprecated - using knowledge files only (project_knowledge.json, global_knowledge.json)
- Knowledge graph maintains JSONL format for compatibility
- Skills framework configured for Python + TypeScript + Docker stack
- Domain skills capture NOP-specific patterns (network services, WebSocket streaming, protocol dissection)
**Next**: Complete knowledge graph optimization and generate workflow log
- Skills framework: 13 core + 8 domain + 7 devops patterns
- Agent instructions stay cross-project, patterns in skills
**Next**: Validate patterns through next 10 workflow sessions

## Handover
**Branch**: copilot/update-all-3-workflows | **Uncommitted**: No | **Blockers**: None
24 changes: 19 additions & 5 deletions .claude/skills.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Claude Skills

**Purpose**: Codified patterns preventing rediscovery | **Version**: 1.1.0
**Purpose**: Codified patterns preventing rediscovery | **Version**: 1.2.0
**Usage**: Copy `.claude/` to any project, run `update_skills` workflow

---

## Skill Index (13 Core Skills)
## Skill Index (13 Core Skills + 7 DevOps/Workflow Skills)

| # | Skill | Category | Trigger |
|---|-------|----------|---------|
Expand All @@ -23,6 +23,10 @@
| 12 | [Infrastructure](#12-infrastructure) | DevOps | Docker, CI/CD |
| 13 | [Workflow Logs](#13-workflow-logs) | Process | Session complete |

**Domain-Specific Skills**:
- See `.claude/skills/domain.md` for 8 NOP-specific patterns (Network services, React, etc.)
- See `.claude/skills/devops.md` for 7 DevOps/Workflow effectiveness patterns (Docker, validation, etc.)

---

## 1. Code Standards
Expand Down Expand Up @@ -142,27 +146,32 @@ project_knowledge.json → Project entities, codegraph, relations
{"type":"relation","from":"Component","to":"Feature","relationType":"IMPLEMENTS|USES|CONSUMES|DEPENDS_ON"}
```

**Protocol**:
**Protocol** (syncs with `.github/instructions/protocols.md`):
| Event | Action |
|-------|--------|
| Session start | Load knowledge, query relevant entities |
| Decision made | Document rationale, alternatives |
| Bug fixed | Add pattern to knowledge |
| Session end | Update knowledge, create handover |

**Cross-References**:
- Agent protocol: See `.github/agents/_DevTeam.agent.md` → Knowledge section
- Detailed format: See `.github/instructions/protocols.md` → Knowledge section
- Update workflow: See `.github/workflows/update_knowledge.md`

---

## 7. Orchestration

**Trigger**: Multi-step tasks, complex operations

**Phases** (syncs with _DevTeam):
**Phases** (syncs with `.github/agents/_DevTeam.agent.md`):
```
CONTEXT → PLAN → COORDINATE → INTEGRATE → VERIFY → LEARN → COMPLETE
1 2 3 4 5 6 7
```

**Emissions**:
**Emissions** (detailed in `.github/instructions/protocols.md`):
```
[SESSION: role=Lead | task=<desc> | phase=CONTEXT]
[PHASE: PLAN | progress=2/7 | next=COORDINATE]
Expand All @@ -179,6 +188,11 @@ CONTEXT → PLAN → COORDINATE → INTEGRATE → VERIFY → LEARN → COMPLETE
| Feature | Full 7-phase |
| Bug | CONTEXT→COORDINATE→INTEGRATE→VERIFY→COMPLETE |

**Cross-References**:
- Agent workflow: See `.github/agents/_DevTeam.agent.md` → Phase Flow
- Protocol details: See `.github/instructions/phases.md`
- Examples: See `.github/instructions/examples.md`

---

## 8. Handover
Expand Down
231 changes: 231 additions & 0 deletions .claude/skills/devops.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
# Domain Skills - DevOps & Workflow Patterns (NOP)

> Project-specific effectiveness patterns from workflow analysis. Updated by agent effectiveness reviews.

**Detailed Analysis**: See `.github/instructions/agent_effectiveness_patterns.md` for complete pattern analysis with prevention strategies.

**Methodology**: See `.github/instructions/AGENT_EFFECTIVENESS_ANALYSIS.md` for 14-session analysis and validation plan.

---

## Skill D9: Docker Cache Management

**Trigger**: Frontend/backend changes not visible after rebuild

**Pattern**:
```bash
# When standard rebuild fails (2nd attempt):
docker-compose down -v # Stop and remove volumes
docker system prune -af --volumes # Remove ALL Docker data
docker network create nop_test-network # Recreate external networks
docker-compose build --no-cache # Build without cache
docker-compose up -d # Start fresh containers
```

**Rules**:
- ✅ Escalate to nuclear cleanup after 2nd failed rebuild
- ✅ Don't waste attempts on cache invalidation strategies
- ✅ Reclaim disk space (typically 3-7GB freed)
- ✅ Recreate external networks before rebuild

**Frequency**: 3 occurrences (21% of sessions)

## Skill D10: Incremental Validation

**Trigger**: Build failures after multiple file edits

**Pattern**:
```
BETTER:
Edit file A → Build → ✓
Edit file B → Build → ✓
Edit file C → Build → ✗ (know it's file C)

AVOID:
Edit A, B, C → Build → ✗ (which file caused it?)
```

**Rules**:
- ✅ Build/test after EACH file change
- ✅ Isolate failures quickly (seconds vs minutes)
- ✅ Apply especially in multi-file refactors
- ✅ Reviewer should validate incrementally

## Skill D11: Import Verification Protocol

**Trigger**: Adding logging, external function calls, or library methods

**Pattern**:
```python
# BEFORE adding any external call, check imports:
# 1. Verify import exists at top of file
import logging
logger = logging.getLogger(__name__)

# 2. THEN add the call
logger.info("Message here")

# DON'T add calls first and fix imports later
```

**Rules**:
- ✅ Check imports BEFORE adding function calls
- ✅ Verify module initialized (e.g., `logger = ...`)
- ✅ No circular dependencies
- ✅ Applies to Python, TypeScript, any language

**Frequency**: 2 occurrences (runtime crashes)

## Skill D12: React Scope Explicit Props

**Trigger**: Creating child components that need parent state

**Pattern**:
```tsx
// WRONG (child can't access parent state):
const Parent = () => {
const [data, setData] = useState([]);
return <Child />; // ✗ data not accessible
}

// CORRECT (pass as prop):
interface ChildProps {
data: DataType[]; // Define in interface
}

const Parent = () => {
const [data, setData] = useState([]);
return <Child data={data} />; // ✓ Pass explicitly
}

const Child: React.FC<ChildProps> = ({ data }) => {
// Now data is in scope
}
```

**Rules**:
- ✅ ALWAYS pass parent state as props
- ✅ Define in TypeScript interface
- ✅ Don't assume child can access parent variables
- ✅ Check interfaces before implementation

**Frequency**: 2 occurrences (build failures)

## Skill D13: File Edit Complexity Threshold

**Trigger**: Complex JSX/TSX refactoring with >3 edits in same region

**Pattern**:
```bash
# When complex edits needed (multiple string replacements):
# Option A: Line-based truncation
head -n <safe_line_number> original.tsx > temp.tsx
mv temp.tsx original.tsx

# Option B: Rewrite entire section
# Extract reusable parts, rewrite clean structure

# AVOID: >3 sequential string replacements in same region
```

**Rules**:
- ✅ For >3 edits in same region, use truncation or rewrite
- ✅ Validate JSX structure after each edit
- ✅ Avoid orphaned code after export statements
- ✅ Applies especially to React components

**Frequency**: 2 occurrences (orphaned code, syntax errors)

## Skill D14: Decision Minimalism

**Trigger**: Documenting design decisions or alternatives

**Pattern**:
```
GOOD (concise):
[DECISION: Typography scale?]
→ CHOSEN: Tailwind text-xs (consistent, responsive)
→ REJECTED: Custom px (no scalability)

AVOID (verbose):
[DECISION: Typography scale?]
→ CHOSEN: Tailwind text-xs
→ REJECTED: Custom px
→ REJECTED: Custom rem
→ REJECTED: Material-UI
→ REJECTED: Styled-components
→ REJECTED: Emotion
```

**Rules**:
- ✅ Document main choice + primary alternative only
- ✅ Keep rationale to 1 sentence
- ✅ Focus on critical trade-offs
- ✅ Reduces cognitive overhead

**Applies to**: Architect, _DevTeam decision documentation

## Skill D15: Anti-Drift Protocol

**Trigger**: Starting any task session

**Pattern**:
```
EVERY session MUST start with:
[SESSION: role=Lead | task=<desc> | phase=CONTEXT]
[PHASE: CONTEXT | progress=1/7]

Load: skills.md → project_knowledge.json → global_knowledge.json

Before ANY implementation:
1. Emit [SESSION: ...] at task start
2. Emit [PHASE: CONTEXT | progress=1/7] when loading knowledge
3. Emit [PHASE: PLAN | progress=2/7] when designing solution
4. Emit [DECISION: ?] for every choice made
5. Emit [ATTEMPT #N] for every implementation try
6. Emit [SUBAGENT: Name] for every delegation
7. Track phase transitions

VIOLATION CHECK: If markers missing, STOP and emit them now.
```

**Rules**:
- ✅ Prevents context loss from skipped initialization
- ✅ Ensures knowledge/skills loaded before work
- ✅ Critical for _DevTeam orchestrator
- ✅ Enables proper workflow logging

**Frequency**: 1 critical occurrence (prevented future issues)

---

## Success Metrics

Track these across workflow logs:
- **Build failures per session**: Target <2 (down from 3-4)
- **Attempts per task**: Target <2 (down from 2-3)
- **Docker nuclear cleanups**: Target 0 (detect caching early)
- **Import errors**: Target 0 (check before adding calls)
- **Scope errors**: Target 0 (pass props explicitly)
- **Orphaned code**: Target 0 (use truncation threshold)

---

## Pattern Sources

**Analysis**: 14 workflow sessions (2025-12-28 to 2025-12-30)
- 78 tracked attempts
- 11 failures (14% rate)
- 7 critical patterns identified

**Detailed Reference**: See `.github/instructions/agent_effectiveness_patterns.md` for complete analysis with code examples and prevention strategies.

**Methodology**: See `.github/instructions/AGENT_EFFECTIVENESS_ANALYSIS.md` for validation plan and expected impact metrics.

**Agent Integration**: Agents reference these skills during CONTEXT phase. See `.github/agents/_DevTeam.agent.md` → Session Protocol.

---

**Updated**: 2025-12-30 by agent effectiveness analysis
**Version**: 1.0
**Next Review**: After 10 more workflow sessions
5 changes: 5 additions & 0 deletions .github/agents/_DevTeam.agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ _DevTeam (Orchestrator)
```
Load: `project_knowledge.json` → `.github/global_knowledge.json` → detect project type

**Practical Patterns**: See `.claude/skills.md` → Skill #6 (Knowledge) for knowledge loading workflow.

## Phase Flow
```
[PHASE: CONTEXT|PLAN|COORDINATE|INTEGRATE|VERIFY|LEARN|COMPLETE | progress=N/7]
Expand Down Expand Up @@ -109,6 +111,9 @@ Query before work, update after:
[KNOWLEDGE: added=N | updated=M | type=project|global]
```

**Practical Workflow**: See `.claude/skills.md` → Skill #6 (Knowledge)
**Protocol Details**: See `.github/instructions/protocols.md` → Knowledge

## Completion
```
[COMPLETE: task=<desc> | result=<summary> | learnings=N]
Expand Down
Loading