Phase 1: Discovery
Map directories requiring CLAUDE.md verification:
```bash
# Find all directories (excluding .git, node_modules, __pycache__, etc.)
find . -type d \( -name .git -o -name node_modules -o -name __pycache__ -o -name .venv -o -name target -o -name dist -o -name build \) -prune -o -type d -print
```
For each directory in scope, record:
- Does CLAUDE.md exist?
- If yes, does it have the required table-based index structure?
- What files/subdirectories exist that need indexing?
Phase 2: Audit
For each directory, check for drift and misplaced content:
```
CLAUDE.md exists: [YES/NO]
Has table-based index: [YES/NO]
Files in directory: [list]
Files in index: [list]
Missing from index: [list]
Stale in index (file deleted): [list]
Triggers are task-oriented: [YES/NO/PARTIAL]
Contains misplaced content: [YES/NO] (architecture/design docs that belong in README.md)
README.md exists: [YES/NO]
README.md warranted: [YES/NO] (invisible knowledge present?)
```
Phase 3: Content Migration
Critical: If CLAUDE.md contains content that does NOT belong there, migrate it:
Content that MUST be moved from CLAUDE.md to README.md:
- Architecture explanations or diagrams
- Design decision documentation
- Component interaction descriptions
- Overview sections with prose (beyond one sentence)
- Invariants or rules documentation
- Any "why" explanations beyond simple triggers
- Key Invariants sections
- Dependencies sections (explanatory -- index can note dependencies exist)
- Constraints sections
- Purpose sections with prose (beyond one sentence)
- Any bullet-point lists explaining rationale
Content that MAY stay in CLAUDE.md (operational sections):
- Build commands specific to this directory
- Test commands specific to this directory
- Regeneration/sync commands (e.g., protobuf regeneration)
- Deploy commands
- Other copy-pasteable procedural commands
Test: Ask "is this explaining WHY or telling HOW?" Explanatory content
(architecture, decisions, rationale) goes to README.md. Operational content
(commands, procedures) stays in CLAUDE.md.
Migration process:
- Identify misplaced content in CLAUDE.md
- Create or update README.md with the architectural content
- Strip CLAUDE.md down to pure index format
- Add README.md to the CLAUDE.md index table
Phase 4: Index Updates
For each directory needing work:
Creating/Updating CLAUDE.md:
- Use the appropriate template (ROOT or SUBDIRECTORY)
- Populate tables with all files and subdirectories
- Write "What" column: factual content description
- Write "When to read" column: action-oriented triggers
- If README.md exists, include it in the Files table
Creating README.md (when invisible knowledge exists):
- Verify invisible knowledge exists (semantic trigger, not structural)
- Document architecture, design decisions, invariants, tradeoffs
- Apply the content test: remove anything visible from code
- Keep as concise as possible while capturing all invisible knowledge
- Must be self-contained: do not reference external authoritative sources
Phase 5: Verification
After all updates complete, verify:
- Every directory in scope has CLAUDE.md
- All CLAUDE.md files use table-based index format (pure navigation)
- No drift remains (files <-> index entries match)
- No misplaced content in CLAUDE.md (explanatory prose moved to README.md)
- README.md files are indexed in their parent CLAUDE.md
- CLAUDE.md contains only: one-sentence overview + tabular index + operational sections
- README.md exists wherever invisible knowledge was identified
- README.md files are self-contained (no external authoritative references)