Claude Code forgets everything between sessions. Built-in auto-memory exists but: - It's opaque (Claude decides what's "meaningful") - Limited to 200 lines loaded at startup - Not tightly integrated into the agentic loop - No hierarchical organization (scales poorly) A skill-based memory protocol with: - Hierarchical storage: core.md summaries → topics/ .md details - Background agents: Memory ops
Add this skill
npx mdskills install hanfang/claude-memory-skillWell-structured hierarchical memory system with clear architecture but lacks actual skill implementation details
1# claude-memory-skill23```4╔══●══●══●══════════════════════════════════════════════╗5║ ║6║ > tree ~/.claude/memory ║7║ ║8║ ├── core.md claude-memory-skill ║9║ ├── topics/ ─────────────────── ║10║ │ └── *.md a skill is all you need ║11║ └── me.md ║12║ ║13╚═══════════════════════════════════════════════════════╝14```1516> *An embarrassingly simple and minimal implementation for agentic memory.*17>18> No databases. No embeddings. No semantic search. Just markdown files and a skill that teaches Claude when to read and write.1920## The Problem2122Claude Code forgets everything between sessions. Built-in auto-memory exists but:23- It's opaque (Claude decides what's "meaningful")24- Limited to 200 lines loaded at startup25- Not tightly integrated into the agentic loop26- No hierarchical organization (scales poorly)2728## The Solution2930A skill-based memory protocol with:31- **Hierarchical storage**: `core.md` summaries → `topics/<topic>.md` details32- **Background agents**: Memory ops don't block the main agent33- **Categorized entries**: No dumping ground, everything has a topic34- **Filesystem-based**: Robust, inspectable, git-trackable3536## Installation3738```bash39curl -fsSL https://raw.githubusercontent.com/hanfang/claude-memory-skill/main/install.sh | bash40```4142Or clone and run locally:4344```bash45git clone https://github.com/hanfang/claude-memory-skill.git46cd claude-memory-skill47./install.sh48```4950## What Gets Installed5152```53~/.claude/54├── CLAUDE.md # Hook added (or created)55├── commands/56│ └── mem.md # The memory skill57└── memory/58 ├── core.md # Summaries + pointers (always loaded)59 ├── me.md # About you (always loaded)60 ├── topics/ # Detailed entries by topic61 │ └── <topic>.md62 └── projects/ # Project-specific memories63 └── <project>.md64```6566## Architecture6768```69┌─────────────────────────────────────────────────────┐70│ Main Agent │71│ - Focuses on user's task │72│ - Spawns memory agent when needed │73│ - Doesn't wait (background) │74└─────────────────────┬───────────────────────────────┘75 │ spawn (background)76 ▼77┌─────────────────────────────────────────────────────┐78│ Memory Agent │79│ - Reads core.md + relevant topics │80│ - Writes to topic files │81│ - Updates core.md summaries │82└─────────────────────────────────────────────────────┘83```8485## How It Works8687### Agent-Initiated (Automatic)8889These run automatically — you don't invoke them:9091| Action | When | Blocking |92|--------|------|----------|93| `load` | Session start | No |94| `save` | Claude learns something useful | No |95| `recall` | Claude needs context | No |9697### User-Initiated (Manual)9899These are for you to inspect and manage memory:100101| Command | Description |102|---------|-------------|103| `/mem show` | Display memory structure and contents |104| `/mem forget <topic>` | Remove a topic or specific entries |105106### Tell Claude What to Remember107108Just say it naturally:109- "Remember that we use pnpm, not npm"110- "Save that the API requires auth headers"111- "Note that tests need Redis running"112113### Fill In Your Profile114115Edit `~/.claude/memory/me.md` with facts about yourself:116117```markdown118# About the User119120- AI researcher, focus on agents and RL121- Prefer explicit code over clever abstractions122- Python, PyTorch, JAX123```124125### Hierarchical Memory126127**core.md** (always loaded):128```markdown129# Core Memory130131## Debugging132Mostly async/timing issues. Prefer explicit logging.133→ topics/debugging.md134135## RL Research136PPO tuning, reward shaping experiments.137→ topics/rl.md138```139140**topics/debugging.md** (loaded on demand):141```markdown142## Async race condition fix [2024-01-15]143Added explicit locks around shared state access.144145## Redis timeout debugging [2024-01-10]146Default timeout was too short for large payloads.147```148149### Write Flow1501511. Learn something → spawn background memory agent1522. Agent categorizes → finds or creates topic file1533. Agent appends entry with timestamp1544. If significant, agent updates core.md summary155156### Read Flow1571581. Session start → agent reads core.md + me.md in background1592. When stuck → agent follows pointers to relevant topics1603. Returns context to main agent161162## Design Principles163164- **Background ops**: Memory doesn't block the main agent165- **Hierarchical**: Summaries in core.md, details in topics166- **Categorized**: Every entry belongs to a topic167- **Atomic entries**: One `##` block = one memory168- **No semantic search**: Deterministic, grep-based retrieval169- **User editable**: Plain markdown, edit anytime170171## Uninstall172173```bash174rm -rf ~/.claude/memory175rm ~/.claude/commands/mem.md176# Manually remove the memory hook from ~/.claude/CLAUDE.md177```178179## License180181MIT182
Full transparency — inspect the skill content before installing.