Init Deep — Progressive Disclosure CLAUDE.md
Set up or migrate to a progressive disclosure CLAUDE.md structure using docs/agents/ for topic-specific guidance.
Context Model
Static (root CLAUDE.md) — loaded every conversation, minimal, high-value
Semi-dynamic (docs/agents/) — linked from root, loaded on-demand when relevant
Fully dynamic (skills) — triggered by metadata match, loaded only when invoked
Root CLAUDE.md should be ~40-50 lines. Everything else belongs in docs/agents/ or skills.
Target Structure
CLAUDE.md # Root: identity, tech stack, key rules, workflow, links
docs/agents/
├── tooling.md # e.g. package manager, linting, formatting, hooks
├── commands.md # e.g. script execution, build filters, passing args
├── guardrails.md # e.g. data isolation, secrets, library docs
├── definition-of-done.md # e.g. coverage, lint, type-check, format requirements
└── [topic].md # Additional topic-specific files as needed
Workflow
Step 1: Detect State
Check for:
- CLAUDE.md exists?
- docs/agents/ exists?
- How many lines is CLAUDE.md?
If no CLAUDE.md → Greenfield path
If CLAUDE.md exists → Migration path
Step 2a: Greenfield Path
Ask the user:
- Project name and one-line description
- Tech stack (frontend, backend, database, etc.)
- Package manager (pnpm, npm, yarn, bun)
- Key guardrails (multi-tenancy, secrets, etc.)
- Definition of done (test coverage, lint, types, format)
Then generate:
Root CLAUDE.md with:
- Project identity (1-2 lines)
- Tech stack list
- 3-5 key rules (only things the agent consistently gets wrong)
- 4-stage workflow: Plan → Execute → Validate → Commit
- Links to docs/agents/ files with routing signals
docs/agents/ files based on answers. Common files include:
tooling.md — package manager rules, linting config, hooks
commands.md — how to run scripts, filter by package, pass args
guardrails.md — data isolation, secrets, library docs
definition-of-done.md — specific thresholds and commands
Adjust filenames and topics to match the project's actual needs.
Step 2b: Migration Path
Read existing CLAUDE.md
Classify each section:
- Root-worthy: identity, tech stack, key rules (3-5 max), workflow
- docs/agents/: detailed tooling, commands, guardrails, definition of done
- Skill-worthy: complex workflows, procedures, domain expertise
Present proposed split to user:
ROOT CLAUDE.md:
- Project identity
- Tech stack
- Key rules: [list]
- Workflow (Plan/Execute/Validate/Commit)
- Links to docs/agents/
docs/agents/tooling.md:
- [extracted sections]
docs/agents/commands.md:
- [extracted sections]
... etc
Ask user to confirm or adjust
Create docs/agents/ files
Rewrite root CLAUDE.md
Step 3: Post-Setup
After creating the structure:
- List all created files
- Show the root CLAUDE.md
- Suggest additional improvements:
- "Consider adding CLAUDE.md files in app subdirectories for app-specific rules"
- "Run
/agent-add-rule to add new rules to the right location"
- "Run
/skills to see available skills"
Root CLAUDE.md Template
# Project Context
[One-line project description]
## Tech Stack
- [list technologies]
## Key Rules
- [3-5 rules the agent consistently gets wrong without being told]
## Workflow
Every task follows four stages. Identify which stage you're in and follow its rules.
Plan → Execute → Validate → Commit
↑ |
└── fix ────────────────────────┘
1. **Plan** — Understand the task, research code, design approach. Be concise; list unresolved questions.
2. **Execute** — Implement changes AND write tests together. No implementation is complete without tests.
3. **Validate** — ALL checks must pass with zero errors before moving on:
- [list validation commands]
If ANY check fails → return to Execute, fix, re-validate. Pre-existing errors are NOT exempt.
4. **Commit** — Only after Validate passes completely. Never commit with failing checks.
## Detailed Guidance
When working on tasks involving these topics, read the linked doc:
- [Topic](docs/agents/file.md) — brief routing signal describing when to read this
- Run `/skills` to see available patterns and workflows
Classification Heuristic
When deciding what stays in root vs moves to docs/agents/:
| Criteria |
Root |
docs/agents/ |
| Agent gets wrong without it? |
YES |
maybe |
| Applies to every task? |
YES |
no |
| Under 2 lines? |
YES |
any length |
| Detailed reference? |
NO |
YES |
| Procedural/workflow? |
only the 4-stage loop |
YES |
Principles
- Minimal root: Every line in root costs tokens on every conversation. Only include what the agent consistently gets wrong without being told.
- Routing signals: Each link description helps Claude decide whether to follow it. Be specific: "pnpm conventions, ESLint config" not just "tooling".
- One level deep: All docs link from root. No cross-references between docs/agents/ files.
- docs/agents/ not docs/: The
agents/ subdirectory separates agent instructions from human documentation.
1---2name: agent-init-deep3description: Initialize or migrate to nested CLAUDE.md structure for progressive disclosure. Claude auto-loads CLAUDE.md from any directory it enters, so nested files get discovered automatically. Use when setting up a new project's agent config, refactoring a bloated CLAUDE.md, or adding progressive disclosure to an existing repo. Triggers on: '/agent-init-deep', 'setup progressive disclosure', 'refactor claude.md', 'split claude.md', 'claude.md is too big'.4---5
6# Init Deep — Progressive Disclosure CLAUDE.md
7
8Set up or migrate to a progressive disclosure CLAUDE.md structure using `docs/agents/` for topic-specific guidance.
9
10## Context Model
11
12```
13Static (root CLAUDE.md) — loaded every conversation, minimal, high-value
14Semi-dynamic (docs/agents/) — linked from root, loaded on-demand when relevant
15Fully dynamic (skills) — triggered by metadata match, loaded only when invoked
16```
17
18Root CLAUDE.md should be ~40-50 lines. Everything else belongs in docs/agents/ or skills.
19
20## Target Structure
21
22```
23CLAUDE.md # Root: identity, tech stack, key rules, workflow, links
24docs/agents/
25├── tooling.md # e.g. package manager, linting, formatting, hooks
26├── commands.md # e.g. script execution, build filters, passing args
27├── guardrails.md # e.g. data isolation, secrets, library docs
28├── definition-of-done.md # e.g. coverage, lint, type-check, format requirements
29└── [topic].md # Additional topic-specific files as needed
30```
31
32## Workflow
33
34### Step 1: Detect State
35
36```
37Check for:
38- CLAUDE.md exists?
39- docs/agents/ exists?
40- How many lines is CLAUDE.md?
41```
42
43If no CLAUDE.md → **Greenfield path**
44If CLAUDE.md exists → **Migration path**
45
46### Step 2a: Greenfield Path
47
48Ask the user:
49
501. Project name and one-line description
512. Tech stack (frontend, backend, database, etc.)
523. Package manager (pnpm, npm, yarn, bun)
534. Key guardrails (multi-tenancy, secrets, etc.)
545. Definition of done (test coverage, lint, types, format)
55
56Then generate:
57
58**Root CLAUDE.md** with:
59
60- Project identity (1-2 lines)
61- Tech stack list
62- 3-5 key rules (only things the agent consistently gets wrong)
63- 4-stage workflow: Plan → Execute → Validate → Commit
64- Links to docs/agents/ files with routing signals
65
66**docs/agents/ files** based on answers. Common files include:
67
68- `tooling.md` — package manager rules, linting config, hooks
69- `commands.md` — how to run scripts, filter by package, pass args
70- `guardrails.md` — data isolation, secrets, library docs
71- `definition-of-done.md` — specific thresholds and commands
72
73Adjust filenames and topics to match the project's actual needs.
74
75### Step 2b: Migration Path
76
771. Read existing CLAUDE.md
782. Classify each section:
79 - **Root-worthy**: identity, tech stack, key rules (3-5 max), workflow
80 - **docs/agents/**: detailed tooling, commands, guardrails, definition of done
81 - **Skill-worthy**: complex workflows, procedures, domain expertise
823. Present proposed split to user:
83
84 ```
85 ROOT CLAUDE.md:
86 - Project identity
87 - Tech stack
88 - Key rules: [list]
89 - Workflow (Plan/Execute/Validate/Commit)
90 - Links to docs/agents/
91
92 docs/agents/tooling.md:
93 - [extracted sections]
94
95 docs/agents/commands.md:
96 - [extracted sections]
97
98 ... etc
99 ```
100
1014. Ask user to confirm or adjust
1025. Create docs/agents/ files
1036. Rewrite root CLAUDE.md
104
105### Step 3: Post-Setup
106
107After creating the structure:
108
1091. List all created files
1102. Show the root CLAUDE.md
1113. Suggest additional improvements:
112 - "Consider adding CLAUDE.md files in app subdirectories for app-specific rules"
113 - "Run `/agent-add-rule` to add new rules to the right location"
114 - "Run `/skills` to see available skills"
115
116## Root CLAUDE.md Template
117
118```markdown
119# Project Context
120
121[One-line project description]
122
123## Tech Stack
124
125- [list technologies]
126
127## Key Rules
128
129- [3-5 rules the agent consistently gets wrong without being told]
130
131## Workflow
132
133Every task follows four stages. Identify which stage you're in and follow its rules.
134
135Plan → Execute → Validate → Commit
136↑ |
137└── fix ────────────────────────┘
138
1391. **Plan** — Understand the task, research code, design approach. Be concise; list unresolved questions.
1402. **Execute** — Implement changes AND write tests together. No implementation is complete without tests.
1413. **Validate** — ALL checks must pass with zero errors before moving on:
142 - [list validation commands]
143 If ANY check fails → return to Execute, fix, re-validate. Pre-existing errors are NOT exempt.
1444. **Commit** — Only after Validate passes completely. Never commit with failing checks.
145
146## Detailed Guidance
147
148When working on tasks involving these topics, read the linked doc:
149
150- [Topic](docs/agents/file.md) — brief routing signal describing when to read this
151- Run `/skills` to see available patterns and workflows
152```
153
154## Classification Heuristic
155
156When deciding what stays in root vs moves to docs/agents/:
157
158| Criteria | Root | docs/agents/ |
159| ---------------------------- | --------------------- | ------------ |
160| Agent gets wrong without it? | YES | maybe |
161| Applies to every task? | YES | no |
162| Under 2 lines? | YES | any length |
163| Detailed reference? | NO | YES |
164| Procedural/workflow? | only the 4-stage loop | YES |
165
166## Principles
167
168- **Minimal root**: Every line in root costs tokens on every conversation. Only include what the agent consistently gets wrong without being told.
169- **Routing signals**: Each link description helps Claude decide whether to follow it. Be specific: "pnpm conventions, ESLint config" not just "tooling".
170- **One level deep**: All docs link from root. No cross-references between docs/agents/ files.
171- **docs/agents/ not docs/**: The `agents/` subdirectory separates agent instructions from human documentation.