Context Manager
Manage the Claude Code memory hierarchy and audit the full markdown landscape of a project. Produces well-organised memory files, detects documentation overlap, and reports the total context footprint.
Four Context Layers
| Layer |
Location |
Purpose |
What this skill does |
| Memory |
./CLAUDE.md, subdirs, .claude/rules/*.md |
Project context, commands, architecture, rules |
Audit, score, maintain |
| Project docs |
ARCHITECTURE.md, DATABASE_SCHEMA.md, API_ENDPOINTS.md, docs/**/*.md |
Technical documentation |
Check existence per project type, flag staleness, detect CLAUDE.md overlap |
| Session |
SESSION.md, PROJECT_BRIEF.md |
Temporary progress tracking |
Report presence + size (managed by dev-session) |
| Public |
README.md, CONTRIBUTING.md, other root .md |
Public-facing docs |
Detect CLAUDE.md duplication |
Auto-memory (~/.claude/projects/*/memory/MEMORY.md) is also scanned for awareness but managed by Claude automatically.
Operating Modes
Mode 1: Session Capture
When: End of session, "capture learnings", "update CLAUDE.md with what we learned"
- Review the conversation for discoveries worth preserving:
- Commands that worked (or didn't)
- Gotchas and workarounds found
- Architecture decisions made
- Configuration quirks discovered
- Patterns that would help future sessions
- Categorise each discovery using the placement decision tree below
- Draft all changes as diffs in a single batch
- Present the batch — apply after a single yes/no confirmation
Keep it concise: one line per concept. No verbose explanations, no generic advice.
Mode 2: Full Audit
When: "audit context", "audit memory", "check project docs", periodic maintenance, working in a neglected project
- Run the audit script:
python3 plugins/dev-tools/skills/context-manager/scripts/audit_memory.py [repo-path]
- Review the output:
- Memory layer: CLAUDE.md sizes, quality scores, rules file sizes
- Project docs: existence, staleness, overlap with CLAUDE.md
- Session/public: presence and size
- Markdown footprint: total KB by layer
- Overlap warnings: sections duplicated between files
- Generate changes autonomously — create, update, or flag files as needed
- Present all changes as a single batch for approval
- Apply approved changes
- Check if the commit capture hook is installed — if not, offer to set it up (see references/commit-hook.md)
For large repos, delegate to a sub-agent:
Task(subagent_type: "general-purpose",
prompt: "Run python3 plugins/dev-tools/skills/context-manager/scripts/audit_memory.py /path/to/repo
and summarise the findings.")
Mode 3: Restructure
When: "restructure memory", root CLAUDE.md over 200 lines, first-time memory setup
- Run full audit (Mode 2) first
- Split oversized files:
- Extract topic sections from root CLAUDE.md into
.claude/rules/<topic>.md
- Extract directory-specific content into sub-directory CLAUDE.md files
- Move detailed technical content from CLAUDE.md to
docs/ or ARCHITECTURE.md if it's reference material, not operational context
- Resolve overlaps: if CLAUDE.md duplicates ARCHITECTURE.md or docs/, remove the duplication
- Create missing documentation files based on project type
- Present the restructure plan, apply after approval
Placement Decision Tree
Would this still apply if I switched to a completely different project?
├── YES → ~/.claude/rules/<topic>.md
│ (correction rules, API patterns, coding standards)
└── NO → Is it specific to a subdirectory?
├── YES → <dir>/CLAUDE.md
│ (integrations, directory-specific gotchas)
└── NO → Is it reference documentation or operational context?
├── Reference → ARCHITECTURE.md or docs/
│ (system design, schemas, detailed flows)
└── Operational → ./CLAUDE.md (project root)
(identity, stack, commands, critical rules)
Size Targets
| File Type |
Target |
Maximum |
| Root CLAUDE.md |
50-150 lines |
200 |
| Sub-directory CLAUDE.md |
15-50 lines |
80 |
| Rules topic file |
20-80 lines |
120 |
What Belongs Where
Root CLAUDE.md
- Project name, purpose, owner
- Tech stack summary
- Build/deploy/test commands (copy-paste ready)
- Directory structure overview
- Critical "never do X" rules
- Key integrations and secrets locations
Sub-directory CLAUDE.md
- External service integrations for that component
- Non-obvious configuration specific to this area
- Directory-specific commands
- Gotchas when working in this directory
Don't create when: parent covers it, directory is self-explanatory, content would be under 10 lines.
.claude/rules/ topic files
- Correction rules bridging training cutoff (e.g. API changes, deprecated patterns)
- Coding patterns and standards
- Platform-specific formatting rules
- Error prevention patterns
docs/ and ARCHITECTURE.md
- Detailed system architecture (component diagrams, data flows)
- Database schemas and migration guides
- API endpoint catalogues
- Content that Claude should read on demand, not every session
Rule of thumb: If it's needed every session, put it in CLAUDE.md. If it's reference material consulted occasionally, put it in docs/.
What to delete
- Content Claude already knows from training
- Verbose explanations of standard frameworks
- Changelogs or version history (use git)
- Duplicated content (between CLAUDE.md and docs/, ARCHITECTURE.md, or README.md)
- "TODO" items that were never completed
- Generic advice not specific to the project
Project Type Detection
The audit script detects project type from file presence and suggests appropriate documentation:
| Indicator |
Type |
Suggested Docs |
wrangler.jsonc / wrangler.toml |
Cloudflare Worker |
ARCHITECTURE.md |
vite.config.* + .tsx files |
Vite/React |
ARCHITECTURE.md |
next.config.* |
Next.js |
ARCHITECTURE.md |
MCP patterns in src/index.ts |
MCP Server |
ARCHITECTURE.md, API_ENDPOINTS.md |
src/routes/ or src/api/ |
API Project |
API_ENDPOINTS.md, DATABASE_SCHEMA.md |
| Drizzle/Prisma config |
Database |
DATABASE_SCHEMA.md |
All projects get CLAUDE.md. Additional docs only when the project type warrants them. See references/project-types.md for full detection heuristics and doc templates.
Autonomy Rules
- Just do it: Run audit, detect project type, identify gaps, draft changes
- Brief confirmation: Apply changes (single batch yes/no, not item-by-item)
- Ask first: Delete existing content, major restructures (moving 50+ lines), create new project docs from scratch where there's ambiguity about content
Quality Scoring
The audit script scores each CLAUDE.md on 6 criteria (100 points):
| Criterion |
Points |
What it measures |
| Commands/Workflows |
20 |
Build, test, deploy documented |
| Architecture Clarity |
20 |
Structure, relationships, entry points |
| Non-Obvious Patterns |
15 |
Gotchas, quirks, warnings |
| Conciseness |
15 |
Dense content, no filler |
| Currency |
15 |
References valid, commands work |
| Actionability |
15 |
Copy-paste ready, real paths |
See references/quality-criteria.md for the full rubric.
Reference Files
| When |
Read |
| Scoring CLAUDE.md quality |
references/quality-criteria.md |
| Detecting project type and expected docs |
references/project-types.md |
| Creating new CLAUDE.md or rules files |
references/templates.md |
| Setting up automatic capture on commit |
references/commit-hook.md |
Scripts
scripts/audit_memory.py — Scan all four layers, score quality, detect project type, report footprint and overlap
python3 audit_memory.py [repo-path] — human-readable report
python3 audit_memory.py [repo-path] --json — structured JSON output
1---2name: context-manager-23description: Audit and manage the full project context landscape: CLAUDE.md memory hierarchy, project documentation, markdown footprint, and content overlap. Detects project type, scores quality, flags stale docs, and reports total context cost. Trigger with 'audit context', 'audit memory', 'update CLAUDE.md', 'restructure memory', 'session capture', 'check project docs', 'markdown footprint', or 'what docs does this project need'.4---5
6# Context Manager
7
8Manage the Claude Code memory hierarchy and audit the full markdown landscape of a project. Produces well-organised memory files, detects documentation overlap, and reports the total context footprint.
9
10## Four Context Layers
11
12| Layer | Location | Purpose | What this skill does |
13|-------|----------|---------|---------------------|
14| **Memory** | `./CLAUDE.md`, subdirs, `.claude/rules/*.md` | Project context, commands, architecture, rules | Audit, score, maintain |
15| **Project docs** | `ARCHITECTURE.md`, `DATABASE_SCHEMA.md`, `API_ENDPOINTS.md`, `docs/**/*.md` | Technical documentation | Check existence per project type, flag staleness, detect CLAUDE.md overlap |
16| **Session** | `SESSION.md`, `PROJECT_BRIEF.md` | Temporary progress tracking | Report presence + size (managed by dev-session) |
17| **Public** | `README.md`, `CONTRIBUTING.md`, other root `.md` | Public-facing docs | Detect CLAUDE.md duplication |
18
19Auto-memory (`~/.claude/projects/*/memory/MEMORY.md`) is also scanned for awareness but managed by Claude automatically.
20
21## Operating Modes
22
23### Mode 1: Session Capture
24
25**When**: End of session, "capture learnings", "update CLAUDE.md with what we learned"
26
271. Review the conversation for discoveries worth preserving:
28 - Commands that worked (or didn't)
29 - Gotchas and workarounds found
30 - Architecture decisions made
31 - Configuration quirks discovered
32 - Patterns that would help future sessions
332. Categorise each discovery using the placement decision tree below
343. Draft all changes as diffs in a single batch
354. Present the batch — apply after a single yes/no confirmation
36
37**Keep it concise**: one line per concept. No verbose explanations, no generic advice.
38
39### Mode 2: Full Audit
40
41**When**: "audit context", "audit memory", "check project docs", periodic maintenance, working in a neglected project
42
431. Run the audit script:
44 ```bash
45 python3 plugins/dev-tools/skills/context-manager/scripts/audit_memory.py [repo-path]
46 ```
472. Review the output:
48 - **Memory layer**: CLAUDE.md sizes, quality scores, rules file sizes
49 - **Project docs**: existence, staleness, overlap with CLAUDE.md
50 - **Session/public**: presence and size
51 - **Markdown footprint**: total KB by layer
52 - **Overlap warnings**: sections duplicated between files
533. Generate changes autonomously — create, update, or flag files as needed
544. Present all changes as a single batch for approval
555. Apply approved changes
566. Check if the commit capture hook is installed — if not, offer to set it up (see [references/commit-hook.md](references/commit-hook.md))
57
58For large repos, delegate to a sub-agent:
59```
60Task(subagent_type: "general-purpose",
61 prompt: "Run python3 plugins/dev-tools/skills/context-manager/scripts/audit_memory.py /path/to/repo
62 and summarise the findings.")
63```
64
65### Mode 3: Restructure
66
67**When**: "restructure memory", root CLAUDE.md over 200 lines, first-time memory setup
68
691. Run full audit (Mode 2) first
702. Split oversized files:
71 - Extract topic sections from root CLAUDE.md into `.claude/rules/<topic>.md`
72 - Extract directory-specific content into sub-directory CLAUDE.md files
73 - Move detailed technical content from CLAUDE.md to `docs/` or `ARCHITECTURE.md` if it's reference material, not operational context
743. Resolve overlaps: if CLAUDE.md duplicates ARCHITECTURE.md or docs/, remove the duplication
754. Create missing documentation files based on project type
765. Present the restructure plan, apply after approval
77
78## Placement Decision Tree
79
80```
81Would this still apply if I switched to a completely different project?
82├── YES → ~/.claude/rules/<topic>.md
83│ (correction rules, API patterns, coding standards)
84└── NO → Is it specific to a subdirectory?
85 ├── YES → <dir>/CLAUDE.md
86 │ (integrations, directory-specific gotchas)
87 └── NO → Is it reference documentation or operational context?
88 ├── Reference → ARCHITECTURE.md or docs/
89 │ (system design, schemas, detailed flows)
90 └── Operational → ./CLAUDE.md (project root)
91 (identity, stack, commands, critical rules)
92```
93
94## Size Targets
95
96| File Type | Target | Maximum |
97|-----------|--------|---------|
98| Root CLAUDE.md | 50-150 lines | 200 |
99| Sub-directory CLAUDE.md | 15-50 lines | 80 |
100| Rules topic file | 20-80 lines | 120 |
101
102## What Belongs Where
103
104### Root CLAUDE.md
105- Project name, purpose, owner
106- Tech stack summary
107- Build/deploy/test commands (copy-paste ready)
108- Directory structure overview
109- Critical "never do X" rules
110- Key integrations and secrets locations
111
112### Sub-directory CLAUDE.md
113- External service integrations for that component
114- Non-obvious configuration specific to this area
115- Directory-specific commands
116- Gotchas when working in this directory
117
118**Don't create when**: parent covers it, directory is self-explanatory, content would be under 10 lines.
119
120### .claude/rules/ topic files
121- Correction rules bridging training cutoff (e.g. API changes, deprecated patterns)
122- Coding patterns and standards
123- Platform-specific formatting rules
124- Error prevention patterns
125
126### docs/ and ARCHITECTURE.md
127- Detailed system architecture (component diagrams, data flows)
128- Database schemas and migration guides
129- API endpoint catalogues
130- Content that Claude should read on demand, not every session
131
132**Rule of thumb**: If it's needed every session, put it in CLAUDE.md. If it's reference material consulted occasionally, put it in docs/.
133
134### What to delete
135- Content Claude already knows from training
136- Verbose explanations of standard frameworks
137- Changelogs or version history (use git)
138- Duplicated content (between CLAUDE.md and docs/, ARCHITECTURE.md, or README.md)
139- "TODO" items that were never completed
140- Generic advice not specific to the project
141
142## Project Type Detection
143
144The audit script detects project type from file presence and suggests appropriate documentation:
145
146| Indicator | Type | Suggested Docs |
147|-----------|------|---------------|
148| `wrangler.jsonc` / `wrangler.toml` | Cloudflare Worker | ARCHITECTURE.md |
149| `vite.config.*` + `.tsx` files | Vite/React | ARCHITECTURE.md |
150| `next.config.*` | Next.js | ARCHITECTURE.md |
151| MCP patterns in `src/index.ts` | MCP Server | ARCHITECTURE.md, API_ENDPOINTS.md |
152| `src/routes/` or `src/api/` | API Project | API_ENDPOINTS.md, DATABASE_SCHEMA.md |
153| Drizzle/Prisma config | Database | DATABASE_SCHEMA.md |
154
155All projects get CLAUDE.md. Additional docs only when the project type warrants them. See [references/project-types.md](references/project-types.md) for full detection heuristics and doc templates.
156
157## Autonomy Rules
158
159- **Just do it**: Run audit, detect project type, identify gaps, draft changes
160- **Brief confirmation**: Apply changes (single batch yes/no, not item-by-item)
161- **Ask first**: Delete existing content, major restructures (moving 50+ lines), create new project docs from scratch where there's ambiguity about content
162
163## Quality Scoring
164
165The audit script scores each CLAUDE.md on 6 criteria (100 points):
166
167| Criterion | Points | What it measures |
168|-----------|--------|-----------------|
169| Commands/Workflows | 20 | Build, test, deploy documented |
170| Architecture Clarity | 20 | Structure, relationships, entry points |
171| Non-Obvious Patterns | 15 | Gotchas, quirks, warnings |
172| Conciseness | 15 | Dense content, no filler |
173| Currency | 15 | References valid, commands work |
174| Actionability | 15 | Copy-paste ready, real paths |
175
176See [references/quality-criteria.md](references/quality-criteria.md) for the full rubric.
177
178## Reference Files
179
180| When | Read |
181|------|------|
182| Scoring CLAUDE.md quality | [references/quality-criteria.md](references/quality-criteria.md) |
183| Detecting project type and expected docs | [references/project-types.md](references/project-types.md) |
184| Creating new CLAUDE.md or rules files | [references/templates.md](references/templates.md) |
185| Setting up automatic capture on commit | [references/commit-hook.md](references/commit-hook.md) |
186
187## Scripts
188
189- `scripts/audit_memory.py` — Scan all four layers, score quality, detect project type, report footprint and overlap
190 - `python3 audit_memory.py [repo-path]` — human-readable report
191 - `python3 audit_memory.py [repo-path] --json` — structured JSON output