Memory Manager
Manage the full Claude Code memory hierarchy across three layers. Produces well-organised, correctly-placed memory files that follow size guidelines and progressive disclosure.
Three Memory Layers
| Layer |
Location |
Purpose |
Managed by this skill |
| CLAUDE.md hierarchy |
./CLAUDE.md, subdirs, parent dirs |
Project context, commands, architecture, rules |
Yes |
| Rules topic files |
.claude/rules/*.md |
Correction rules, patterns, technical facts |
Yes |
| Auto-memory |
~/.claude/projects/*/memory/MEMORY.md |
Session-specific patterns |
No (Claude manages 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 memory", "check project docs", periodic maintenance, working in a neglected project
- Run the audit script:
python3 skills/memory-manager/scripts/audit_memory.py [repo-path]
- Review the output: sizes, quality scores, project type, missing docs, stale references
- Generate changes autonomously — create, update, or flag files as needed
- Present all changes as a single batch for approval
- Apply approved changes
For large repos, delegate to a sub-agent:
Task(subagent_type: "general-purpose",
prompt: "Run python3 skills/memory-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
- 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 → ./CLAUDE.md (project root)
(identity, stack, commands, architecture, 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
What to delete
- Content Claude already knows from training
- Verbose explanations of standard frameworks
- Changelogs or version history (use git)
- Duplicated content from parent CLAUDE.md files
- "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 |
Scripts
scripts/audit_memory.py — Scan all three layers, score quality, detect project type, flag issues
python3 audit_memory.py [repo-path] — human-readable report
python3 audit_memory.py [repo-path] --json — structured JSON output
1---2name: memory-manager3description: Audit, restructure, and maintain the full Claude Code memory hierarchy: CLAUDE.md files, .claude/rules/ topic files, auto-memory, and project documentation. Detects project type and suggests appropriate docs. Use when CLAUDE.md needs updating, memory needs restructuring, or a project needs its docs audited. Trigger with 'audit memory', 'update CLAUDE.md', 'restructure memory', 'session capture', 'memory cleanup', 'check project docs', or 'what docs does this project need'.4---5
6# Memory Manager
7
8Manage the full Claude Code memory hierarchy across three layers. Produces well-organised, correctly-placed memory files that follow size guidelines and progressive disclosure.
9
10## Three Memory Layers
11
12| Layer | Location | Purpose | Managed by this skill |
13|-------|----------|---------|----------------------|
14| CLAUDE.md hierarchy | `./CLAUDE.md`, subdirs, parent dirs | Project context, commands, architecture, rules | Yes |
15| Rules topic files | `.claude/rules/*.md` | Correction rules, patterns, technical facts | Yes |
16| Auto-memory | `~/.claude/projects/*/memory/MEMORY.md` | Session-specific patterns | No (Claude manages automatically) |
17
18## Operating Modes
19
20### Mode 1: Session Capture
21
22**When**: End of session, "capture learnings", "update CLAUDE.md with what we learned"
23
241. Review the conversation for discoveries worth preserving:
25 - Commands that worked (or didn't)
26 - Gotchas and workarounds found
27 - Architecture decisions made
28 - Configuration quirks discovered
29 - Patterns that would help future sessions
302. Categorise each discovery using the placement decision tree below
313. Draft all changes as diffs in a single batch
324. Present the batch — apply after a single yes/no confirmation
33
34**Keep it concise**: one line per concept. No verbose explanations, no generic advice.
35
36### Mode 2: Full Audit
37
38**When**: "audit memory", "check project docs", periodic maintenance, working in a neglected project
39
401. Run the audit script:
41 ```bash
42 python3 skills/memory-manager/scripts/audit_memory.py [repo-path]
43 ```
442. Review the output: sizes, quality scores, project type, missing docs, stale references
453. Generate changes autonomously — create, update, or flag files as needed
464. Present all changes as a single batch for approval
475. Apply approved changes
48
49For large repos, delegate to a sub-agent:
50```
51Task(subagent_type: "general-purpose",
52 prompt: "Run python3 skills/memory-manager/scripts/audit_memory.py /path/to/repo
53 and summarise the findings.")
54```
55
56### Mode 3: Restructure
57
58**When**: "restructure memory", root CLAUDE.md over 200 lines, first-time memory setup
59
601. Run full audit (Mode 2) first
612. Split oversized files:
62 - Extract topic sections from root CLAUDE.md into `.claude/rules/<topic>.md`
63 - Extract directory-specific content into sub-directory CLAUDE.md files
643. Create missing documentation files based on project type
654. Present the restructure plan, apply after approval
66
67## Placement Decision Tree
68
69```
70Would this still apply if I switched to a completely different project?
71├── YES → ~/.claude/rules/<topic>.md
72│ (correction rules, API patterns, coding standards)
73└── NO → Is it specific to a subdirectory?
74 ├── YES → <dir>/CLAUDE.md
75 │ (integrations, directory-specific gotchas)
76 └── NO → ./CLAUDE.md (project root)
77 (identity, stack, commands, architecture, critical rules)
78```
79
80## Size Targets
81
82| File Type | Target | Maximum |
83|-----------|--------|---------|
84| Root CLAUDE.md | 50-150 lines | 200 |
85| Sub-directory CLAUDE.md | 15-50 lines | 80 |
86| Rules topic file | 20-80 lines | 120 |
87
88## What Belongs Where
89
90### Root CLAUDE.md
91- Project name, purpose, owner
92- Tech stack summary
93- Build/deploy/test commands (copy-paste ready)
94- Directory structure overview
95- Critical "never do X" rules
96- Key integrations and secrets locations
97
98### Sub-directory CLAUDE.md
99- External service integrations for that component
100- Non-obvious configuration specific to this area
101- Directory-specific commands
102- Gotchas when working in this directory
103
104**Don't create when**: parent covers it, directory is self-explanatory, content would be under 10 lines.
105
106### .claude/rules/ topic files
107- Correction rules bridging training cutoff (e.g. API changes, deprecated patterns)
108- Coding patterns and standards
109- Platform-specific formatting rules
110- Error prevention patterns
111
112### What to delete
113- Content Claude already knows from training
114- Verbose explanations of standard frameworks
115- Changelogs or version history (use git)
116- Duplicated content from parent CLAUDE.md files
117- "TODO" items that were never completed
118- Generic advice not specific to the project
119
120## Project Type Detection
121
122The audit script detects project type from file presence and suggests appropriate documentation:
123
124| Indicator | Type | Suggested Docs |
125|-----------|------|---------------|
126| `wrangler.jsonc` / `wrangler.toml` | Cloudflare Worker | ARCHITECTURE.md |
127| `vite.config.*` + `.tsx` files | Vite/React | ARCHITECTURE.md |
128| `next.config.*` | Next.js | ARCHITECTURE.md |
129| MCP patterns in `src/index.ts` | MCP Server | ARCHITECTURE.md, API_ENDPOINTS.md |
130| `src/routes/` or `src/api/` | API Project | API_ENDPOINTS.md, DATABASE_SCHEMA.md |
131| Drizzle/Prisma config | Database | DATABASE_SCHEMA.md |
132
133All 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.
134
135## Autonomy Rules
136
137- **Just do it**: Run audit, detect project type, identify gaps, draft changes
138- **Brief confirmation**: Apply changes (single batch yes/no, not item-by-item)
139- **Ask first**: Delete existing content, major restructures (moving 50+ lines), create new project docs from scratch where there's ambiguity about content
140
141## Quality Scoring
142
143The audit script scores each CLAUDE.md on 6 criteria (100 points):
144
145| Criterion | Points | What it measures |
146|-----------|--------|-----------------|
147| Commands/Workflows | 20 | Build, test, deploy documented |
148| Architecture Clarity | 20 | Structure, relationships, entry points |
149| Non-Obvious Patterns | 15 | Gotchas, quirks, warnings |
150| Conciseness | 15 | Dense content, no filler |
151| Currency | 15 | References valid, commands work |
152| Actionability | 15 | Copy-paste ready, real paths |
153
154See [references/quality-criteria.md](references/quality-criteria.md) for the full rubric.
155
156## Reference Files
157
158| When | Read |
159|------|------|
160| Scoring CLAUDE.md quality | [references/quality-criteria.md](references/quality-criteria.md) |
161| Detecting project type and expected docs | [references/project-types.md](references/project-types.md) |
162| Creating new CLAUDE.md or rules files | [references/templates.md](references/templates.md) |
163
164## Scripts
165
166- `scripts/audit_memory.py` — Scan all three layers, score quality, detect project type, flag issues
167 - `python3 audit_memory.py [repo-path]` — human-readable report
168 - `python3 audit_memory.py [repo-path] --json` — structured JSON output