Consolidate CLAUDE.md and linked documents: map dependency graph, find duplicates and contradictions, propose target structure, execute migration.
Fixes fragmented doc systems: maps dependencies, eliminates duplication, resolves the "source of truth" ambiguity. Stops at 3 user checkpoints.
Phase 1 — Discovery Map the full dependency graph
Phase 2 — Analysis Duplicates, contradictions, decomposition principle
Phase 3 — Proposal Target structure with rationale [CHECKPOINT 1]
Phase 4 — Migration Consolidate into new structure [CHECKPOINT 2]
Phase 5 — Verification No broken refs, no leftover duplicates [CHECKPOINT 3]
Step 1 — Collect all files
Starting from the root file (default: CLAUDE.md):
Read X.md, See X.md, X.md for ..., → X.md, markdown links [text](path)Output: flat list of all files in the graph.
Step 2 — Build dependency graph
For each file in the list:
references: [list of files this file points to]referenced_by: [list of files that point to this file]Identify:
Output: dependency graph summary + cycle list.
Step 3 — Content classification
For each file, classify what content types it contains:
| Content type | Examples |
|---|---|
architecture | directory trees, component descriptions |
conventions | naming rules, file location rules |
commands | CLI commands, bash scripts |
workflow | pipelines, stage sequences |
agent-rules | per-agent instructions, context loading |
project-state | current version, installed agents, status |
external-refs | links to repos, docs, issues |
Note files that contain multiple content types — these are consolidation candidates.
Step 4 — Duplicate detection
For every pair of files, scan for:
Output: duplicate inventory with file pairs and content excerpts.
Step 5 — Contradiction detection
For any topic that appears in 2+ files, check: do they agree?
Common contradiction patterns:
Output: contradiction list with file/line references.
Step 6 — Decomposition principle
Infer the current organizing principle from file names and content:
Rate the current structure: does each file have a single clear responsibility? Are boundaries respected?
Step 7 — Define target structure
Based on the analysis, propose one of:
Option A — Flatten: everything in CLAUDE.md, no external refs. Good for small projects with <5 topics.
Option B — Two-layer: CLAUDE.md (project) + one conventions file. Good for medium projects.
Option C — Role-based hierarchy: files split by audience (agent vs human vs CI). No cycles by design: agents read their file + one shared file.
Option D — Process-based hierarchy: files split by pipeline stage. Each stage doc is self-contained.
For the recommended option, show:
CLAUDE.md → what stays here (project context only)
iEVO.md → what moves here (pipeline conventions)
agents/<name>.md → what moves here (per-agent rules)
Include: what gets deleted, what gets merged, what gets created.
CHECKPOINT 1 → present full proposal. Wait for user approval before any file changes.
Step 8 — Consolidate content
For each file in the new structure:
For each file being deleted or emptied:
# Moved to X.mdStep 9 — Fix cross-references
After all files are written:
CHECKPOINT 2 → show diff summary (files created/deleted/changed). Wait for approval before finalizing.
Step 10 — Section inventory check (content completeness)
Before Phase 4, extract a section inventory from all source files:
## Heading and ### Subheading in every source file, record: file → heading → first 50 chars of contentOutput: table of source section → destination file. Flag any section with no destination as MISSING.
Stop migration and report if any section has no destination. Do not proceed until every section is placed or explicitly discarded by the user.
Step 11 — Graph re-check
Re-run Phase 1 on the new structure:
Step 12 — Duplicate re-check
Re-run Step 4 on new structure: zero duplicates.
Step 13 — Single source of truth audit
For each content type identified in Step 3, confirm: it lives in exactly one file now.
CHECKPOINT 3 → present final report:
Files before: N
Files after: M
Sections total: S (tracked from Step 10)
Sections moved: S (must equal total — zero missing)
Duplicates removed: K
Contradictions resolved: J
Cycles broken: C
Stop and warn if: