Runs maintenance on your agent's memory files when they get messy. Splits bloated files over 300 lines into focused topics, merges duplicates, prunes stale task references and outdated project statuses, and cleans up directory structures. The guide suggests running it weekly or when MEMORY.md hits 500 lines. Nice touch that it preserves raw daily notes as an audit trail and includes a planning step before making changes. Basically defragmentation for knowledge files. If you're working with agents that accumulate memory over time, this keeps things from turning into an unsearchable mess.
npx -y skills add basicmachines-co/basic-memory-skills --skill memory-defrag --agent claude-codeInstalls into .claude/skills of the current project.
Reorganize memory files for clarity, efficiency, and relevance. Like filesystem defragmentation but for knowledge.
Inventory all memory files:
MEMORY.md — long-term memory
memory/ — daily notes, tasks, topical files
memory/tasks/ — active and completed tasks
For each file, note: line count, last modified, topic coverage, staleness.
Look for these common issues:
| Problem | Signal | Fix |
|---|---|---|
| Bloated file | >300 lines, covers many topics | Split into focused files |
| Duplicate info | Same fact in multiple places | Consolidate to one location |
| Stale entries | References to completed work, old dates, resolved issues | Remove or archive |
| Orphan files | Files in memory/ never referenced or updated | Review, merge, or remove |
| Inconsistencies | Contradictory information across files | Resolve to ground truth |
| Poor organization | Related info scattered across files | Restructure by topic |
| Recursive nesting | memory/memory/memory/... directories | Delete nested dirs (indexer bug artifact) |
Before making edits, write a brief plan:
## Defrag Plan
- [ ] Split MEMORY.md "Key People" section → memory/people.md
- [ ] Remove completed tasks older than 30 days from memory/tasks/
- [ ] Merge memory/bm-marketing-ideas.md into memory/competitive/
- [ ] Update stale project status entries in MEMORY.md
Apply changes one at a time:
After changes:
## Memory Defrag (HH:MM)
- Files reviewed: N
- Split: [list]
- Merged: [list]
- Pruned: [list]
- Net result: X files, Y total lines (was Z lines)
memory/YYYY-MM-DD.md files — they're the audit trail.people.md, project-status.md, competitive-landscape.md — not notes-2.md.memory/tasks/ and memory/competitive/ are fine; memory/work/projects/active/basic-memory/notes/ is not.status: done older than 14 days can be removed. Their insights should already be in MEMORY.md via reflection.(review needed) tag rather than deleting.juliusbrussee/caveman
mattpocock/skills
shadcn/improve
obra/superpowers
forrestchang/andrej-karpathy-skills
vercel-labs/skills