|
| 1 | +# Update Docs |
| 2 | + |
| 3 | +Systematic review and update of context markdowns (CLAUDE.md, MEMORY.md, agent_docs/) based on session traces, git history, and codebase drift. Run weekly. |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +``` |
| 8 | +/update-docs # Full review: CLAUDE.md + MEMORY.md + agent_docs/ |
| 9 | +/update-docs memory # Only review MEMORY.md entries |
| 10 | +/update-docs claude # Only review CLAUDE.md |
| 11 | +/update-docs agents # Only review agent_docs/ |
| 12 | +``` |
| 13 | + |
| 14 | +## Instructions |
| 15 | + |
| 16 | +You are a context gardener. Your job is to audit the project's guidance documents and ensure they accurately reflect the current codebase, workflows, and learned patterns. Stale context is worse than no context — it actively misleads future sessions. |
| 17 | + |
| 18 | +### Step 1: Gather evidence |
| 19 | + |
| 20 | +Run these in parallel to build a picture of what's changed since the docs were last updated: |
| 21 | + |
| 22 | +1. **Recent git history** (last 2 weeks): |
| 23 | + ```bash |
| 24 | + git log --oneline --since="2 weeks ago" --no-merges |
| 25 | + ``` |
| 26 | + |
| 27 | +2. **Files changed recently** (detect structural shifts): |
| 28 | + ```bash |
| 29 | + git diff --stat HEAD~50 HEAD | tail -20 |
| 30 | + ``` |
| 31 | + |
| 32 | +3. **Current CLAUDE.md** — read it fully |
| 33 | +4. **Current MEMORY.md** — read it fully |
| 34 | +5. **All memory files** — `ls ~/.claude/projects/*/memory/` and read each |
| 35 | +6. **Agent docs index** — `ls agent_docs/` if it exists |
| 36 | +7. **Conductor traces** (if available): |
| 37 | + ```bash |
| 38 | + stackmemory conductor trace-stats 2>/dev/null |
| 39 | + ``` |
| 40 | +8. **Recent test results** — check if test counts or patterns have shifted: |
| 41 | + ```bash |
| 42 | + node -e "require('child_process').execSync('npx vitest run --reporter=json 2>/dev/null', {timeout:300000, encoding:'utf8'})" 2>/dev/null | node -e "const d=JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'));console.log('Tests:',d.numPassedTests,'passed,',d.numFailedTests,'failed,',d.numTotalTestSuites,'suites')" |
| 43 | + ``` |
| 44 | + |
| 45 | +### Step 2: Audit each document |
| 46 | + |
| 47 | +For each document, evaluate every section against the evidence: |
| 48 | + |
| 49 | +#### CLAUDE.md audit checklist: |
| 50 | +- [ ] **Commands section**: Do all listed commands still work? Any new important ones missing? |
| 51 | +- [ ] **Project structure**: Does the tree match actual `src/` layout? New directories? |
| 52 | +- [ ] **Key files**: Are file paths still correct? Any important new files? |
| 53 | +- [ ] **Validation steps**: Still accurate? Test counts roughly right? |
| 54 | +- [ ] **Deploy section**: Still accurate? Any new steps? |
| 55 | +- [ ] **Conductor section**: Data files, learning loop, template variables all current? |
| 56 | +- [ ] **Task delegation model**: Categories still make sense given recent work? |
| 57 | + |
| 58 | +#### MEMORY.md audit checklist: |
| 59 | +- [ ] **Each memory entry**: Is it still true? Has the codebase changed underneath it? |
| 60 | +- [ ] **Missing knowledge**: Are there patterns from recent commits that should be captured? |
| 61 | +- [ ] **Stale entries**: Any memories about removed features, old APIs, or resolved issues? |
| 62 | +- [ ] **Duplicates**: Any memories that overlap or contradict each other? |
| 63 | + |
| 64 | +#### Agent docs audit: |
| 65 | +- [ ] **Each doc**: Does it reference current APIs, file paths, patterns? |
| 66 | +- [ ] **Coverage**: Any major subsystem lacking documentation? |
| 67 | + |
| 68 | +### Step 3: Propose changes |
| 69 | + |
| 70 | +Present findings as a structured report: |
| 71 | + |
| 72 | +``` |
| 73 | +## Context Audit Report — {date} |
| 74 | +
|
| 75 | +### Stale (remove or update) |
| 76 | +- MEMORY.md line X: "{entry}" — reason it's stale |
| 77 | +- CLAUDE.md section Y: outdated because Z |
| 78 | +
|
| 79 | +### Missing (should add) |
| 80 | +- New pattern learned: {description} — evidence: {commit/file} |
| 81 | +- New gotcha discovered: {description} |
| 82 | +
|
| 83 | +### Accurate (no change needed) |
| 84 | +- {section}: still valid ✓ |
| 85 | +``` |
| 86 | + |
| 87 | +### Step 4: Apply changes |
| 88 | + |
| 89 | +After presenting the report, ask: "Apply these changes?" If confirmed: |
| 90 | + |
| 91 | +1. **Update MEMORY.md** — edit stale entries, add missing ones, remove obsolete |
| 92 | +2. **Update individual memory files** — create/update/delete as needed |
| 93 | +3. **Update CLAUDE.md** — fix outdated sections (commands, paths, structure) |
| 94 | +4. **Update agent_docs/** — fix stale references |
| 95 | + |
| 96 | +### Rules |
| 97 | + |
| 98 | +- **Never delete memories about rejected integrations** — those prevent re-evaluation |
| 99 | +- **Never delete gotchas** — they prevent repeat mistakes |
| 100 | +- **Preserve dates** on memory entries so staleness is visible |
| 101 | +- **Add dates** to any new entries: `(2026-MM-DD)` |
| 102 | +- **Keep MEMORY.md under 200 lines** — it's loaded into every conversation |
| 103 | +- **Progressive disclosure**: If a topic needs >5 lines, put it in a dedicated memory file and link from MEMORY.md |
| 104 | +- **Don't rewrite CLAUDE.md from scratch** — make surgical updates. The structure is intentional. |
| 105 | +- **Commit changes** with message: `chore(docs): weekly context audit — {summary}` |
0 commit comments