Doc tree consolidation

From CarlosCaPe/octorato · View interactive version

Doc tree consolidation is an AI agent skill from the GitHub repository CarlosCaPe/octorato. Collapse N fragmented markdown docs into a small canonical set without losing content or breaking cross-references. Distinguishes mandatory-location files from consolidatable docs and dead-weight scaffolding.

How to use this skill

Skill file

Doc Tree Consolidation

What

A workflow for repos where documentation has fragmented over time — multiple READMEs, partial handoff files, scattered subfolders with stub READMEs — into a small canonical set: typically README.md (entry), <TOOLING>.md (commands and structure), and one big topic doc per major subject.

Why

Repos accumulate docs the way a closet accumulates jackets. Each one was important once. Five of them now overlap, three are stale, two reference deleted files. New contributors don't know where to start; existing contributors keep editing the wrong file.

Consolidation:

The Three File Classes

Every .md in the repo is exactly one of three classes. Classify before you touch anything.

1. Mandatory-location files — DO NOT TOUCH

These live at paths that tools/agents/CI assume by convention:

If you delete or rename one of these, you break the convention silently. They are not part of the consolidation set.

2. Consolidatable docs — the actual fragmentation problem

Project docs that have grown by accretion: README.md, HANDOFF.md, ARCHITECTURE.md, competitive-landscape.md, team.md, tdd-plan.md, scattered poc/*.md, etc.

These are the consolidation set.

3. Dead weight — delete on sight

Workflow

1. Inventory

find . -name "*.md" -not -path "*/node_modules/*" \
  -not -path "*/output/*" -not -path "*/.git/*" \
  | sort
wc -l <each-file>

Classify each file into the three classes above.

2. Propose target structure

For consolidatable docs, the typical landing pattern is 3 files:

| File | Purpose | Length target |

|---|---|---|

| README.md | Top entry — what this is, where to go for what, status snapshot | 50–100 lines |

| <COMMANDS>.md (often CLAUDE.md) | How to use the repo — quick commands, folder structure, conventions | 100–200 lines |

| <TOPIC>.md (often POC.md, ARCHITECTURE.md, RUNBOOK.md) | The big content document — merged from N source files | 1000–2000 lines acceptable |

Anything beyond 3 canonical files is justified by domain (e.g., a separate SECURITY.md that compliance audits explicitly want as its own file).

3. Build a Change Manifest BEFORE writing anything

Required format:

| # | Action | File | Reason |
|---|---|---|---|
| 1 | CREATE | README.md | Top entry that doesn't exist today |
| 2 | MODIFY | CLAUDE.md | Slim to commands + structure |
| 3 | CREATE | TOPIC.md | Unified merge of poc/* + HANDOFF.md durable parts |
| 4 | DELETE | HANDOFF.md | Folded into TOPIC.md |
| 5 | DELETE | poc/README.md | Folded |
| ...
| N | DELETE | brain/ (entire dir) | 3-line stub + unused Python scaffolds |

Then stop and wait for explicit user confirmation. No writes before approval.

4. Execute (only after confirmation)

5. Verify

# Count change
find . -name "*.md" | grep -v "/users/\|/output/\|/.claude/\|/node_modules/" | wc -l

# Stale references gone?
grep -rn "<deleted-file-1>\|<deleted-file-2>" --include="*.md" --include="*.json"

# Mandatory-location files untouched
git diff --stat | grep -E "^\.claude/|/SKILL\.md|/commands/" && echo "WARNING: mandatory-location file modified"

Anti-patterns

| Anti-pattern | Why it fails |

|---|---|

| Touching mandatory-location files in a consolidation pass | Breaks tool/agent conventions silently. CI suddenly fails for unrelated reasons. |

| Skipping the Change Manifest | Aggressive deletes without preview = lost work. Manifest is the gate. |

| Merging without updating cross-references | knowledge.json.docs_location still points at deleted folder. Reader follows dead link. |

| Deleting "dead weight" without grep-confirming nothing references it | One stale-looking file is referenced by an automation you forgot about. |

| Versioned filenames (*_v2.md, *_old.md) preserved "just in case" | git is the version history. The filename clutter implies the new version isn't trusted. |

| Combining 5 docs into 1 without preserving citation tags from source-citation-tagging | Audit trail is lost. The merged doc reads as "trust the merger" instead of "here's the source for each claim." |

| Renaming CLAUDE.md → INSTRUCTIONS.md because it "looks better" | It's a mandatory-location convention. Don't rename. |

Composability

Lessons Learned

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.