A community-driven registry for Claude, Cursor, Windsurf, Cline & more. Not affiliated with Anthropic.
Are you the author? Sign in to claim
Claude Code 的記憶系統 | A memory system built with hooks + markdown. Zero dependencies.
Not just memory — it learns.
Learn from mistakes. Learn to improve.
AI can be a student too, growing through every cycle.
Built with hooks and markdown. No database. No external API.
Just scripts and files. Nothing hiding.
Memory tools can help it "remember." But remembering is not the same as learning.
Memory Engine doesn't just help Claude remember — it teaches Claude to learn like a student:
Think of it like exam prep. I'm trying to make Claude Code act like a student cramming for finals — take notes after every class, organize them, review for patterns, build an error notebook, and do a big end-of-term review. Each cycle, it gets a little better.
In class (automatic, runs every session)
There is no real "end" to a Claude Code conversation — it might close, idle out, or get compressed. So Memory Engine doesn't rely on any single moment. Instead, it saves at three different points:
mid-session-checkpoint) — saves a checkpoint + mini analysis. The most reliable save point, because it counts messages itselfpre-compact) — fires right before context is compressed. Saves a snapshot, detects pitfalls, runs backup. This is when context is fullest, so pitfall detection is most accurate heresession-end) — saves a final summary + backup. Nice to have, but not guaranteed to fire (window might just close)You don't need to remember to run any command before closing — your important stuff is already saved before you close.
On top of that, Claude also:
Final exam review (manual, run /reflect)
After a few days of notes, run /reflect and Claude will:
This isn't a one-time thing. Each cycle makes the notes sharper, the patterns clearer, the mistakes fewer. It's a loop that keeps improving.
Some mistakes don't show up in error logs. You correct its output, and only then does it realize — "oh, that was wrong." These mistakes don't get remembered automatically. Unless someone builds it an error notebook.
Record (/analyze, manual — run right after you correct something)
/analyzeReview (automatic: before each task / manual: type /correct anytime)
/correct — no need to wait for a task or a cycleClean up (/reflect step 6, manual)
But you know that from here on, your AI has grown a little more.
Can I just type /correct directly?
Yes. /correct works anytime — no need to wait for a task or a cycle. It simply opens the error notebook and shows you what's active.
How often should I run /reflect?
There's no fixed schedule. A good rhythm is once a week, or whenever the notebook feels cluttered. Step 6 of /reflect handles cleanup — upgrading repeat offenders to hard rules and clearing ones you've already internalized.
Do I have to run /analyze first before /correct works?
No. /analyze records new mistakes; /correct reviews existing ones. They're independent. Even if you never run /analyze, /correct still shows whatever is already in the notebook.
Smart Context (automatic, no config needed)
Auto Learn (automatic, on session end)
Memory and learning are the core, but day-to-day work needs more:
| Feature | Description |
|---|---|
| Health | /check daily scan + /full-check weekly audit to keep the memory system healthy |
| Tasks | /todo tracks pending items across all projects |
| Backup | /backup /sync connect to GitHub — bidirectional sync, safe even if your machine dies |
| Cross-device | Set up a GitHub memory repo, and your memory works across machines. New device? Run /recover and it's all there |
| Recovery | /recover restores lost memory from GitHub backup |
| Search | /memory-search keyword search across all memory files |
| Bilingual | Every command has an English + Traditional Chinese version (36 files) |
Not sure what commands are available? Type
/overview(/全覽) to see them all.
Daily Operations
| EN | ZH | Function |
|---|---|---|
/save | /存記憶 | Save memory across sessions — auto-dedup and route to the right file |
/reload | /讀取 | Load memory into the current conversation |
/todo | /待辦 | Cross-project task tracking |
/backup | /備份 | Push local memory to GitHub |
/sync | /同步 | Bidirectional sync — push local, pull remote |
Reflection & Learning
| EN | ZH | Function |
|---|---|---|
/diary | /回顧 | Generate a reflection diary |
/reflect | /反思 | Analyze pitfall records and find recurring patterns |
/learn | /學習 | Manually save a pitfall experience |
Health Checks
| EN | ZH | Function |
|---|---|---|
/check | /健檢 | Quick scan — capacity, broken links, orphan files |
/full-check | /大健檢 | Full audit — commands, git repos, environment config |
/memory-health | /記憶健檢 | Memory file line counts, update dates, capacity warnings |
Search & Maintenance
| EN | ZH | Function |
|---|---|---|
/memory-search | /搜尋記憶 | Keyword search across all memory files |
/recover | /想起來 | Restore memory from GitHub backup |
/compact-guide | /壓縮建議 | Guide for when to compress and when not to |
/overview | /全覽 | List all available commands |
Collaboration
You have three Claude Code windows open. One's fixing a bug, one's writing docs, one's cleaning up code. You switch over — and that window has zero clue what you were just doing.
/save is for things you want to remember long-term. /backup pushes everything to GitHub. /handoff is for right now — what you were working on, what's done, what's not.
| EN | ZH | Function |
|---|---|---|
/handoff | /交接 | Generate a handoff file so another session can pick up where you left off |
How it works: Run /handoff in window A. It saves a handoff file with your progress, decisions, and unfinished tasks. Window B picks it up automatically — no command needed on the receiving end. If B is already mid-conversation, it detects the new handoff in real time. If B starts a new conversation, it loads the handoff on startup. Either way, B sees it once and moves on.
Engine maintenance (new in v2.0)
| EN | ZH | Function |
|---|---|---|
/bb-pause | /暫停同步 | Pause SessionEnd auto-commit while refactoring engine internals |
When you're editing memory-backup.sh, hooks/*.js, or CLAUDE.md, the SessionEnd hook might auto-commit a half-finished version. /bb-pause on creates a .bb-pause lock file that makes the script exit early. Run /bb-pause off when you're done.
| Hook | Trigger | What it does |
|---|---|---|
session-start | New conversation | Load last summary + project memory + pending handoffs |
session-end | Conversation ends | Save summary + backup (best-effort, may not fire) |
pre-compact | Context compression (auto or manual) | Save snapshot + pitfall detection + backup — the real safety net |
memory-sync | Every message sent | Detect cross-session memory changes + new handoffs |
write-guard | Before file writes | Sensitive file interception |
pre-push-check | Before git push | Safety check |
mid-session-checkpoint | Every 20 messages | Save checkpoint + mini analysis |
Memory Engine supports cross-device sync through a GitHub repo. Set it up once, and your memory works on every machine.
How it works:
/backup pushes local memory to your private GitHub repo (memory-backup.sh push)/sync does bidirectional sync — pull remote updates, then push local changes (memory-backup.sh sync)/recover on a new device pulls everything back and distributes to all local projects (memory-backup.sh pull)What this means: Switch laptops, reinstall your OS, set up a new workstation — run /recover and Claude picks up right where you left off. No re-explaining your preferences, no lost context.
The GitHub repo is private by default. Your memory never touches any external service beyond your own GitHub account.
v1.6 only synced memory files, which meant your second machine forever ran an older CLAUDE.md, missing slash commands, and stale hooks. v2.0 rewrites the sync as a full environment engine — the entire ~/.claude/ working environment travels with you:
| Synced Artifact | v1.6 | v2.0 |
|---|---|---|
| MEMORY.md + per-project memory | ✅ | ✅ |
| CLAUDE.md (top-level rules) | ❌ | ✅ |
| commands/ (slash commands) | ❌ | ✅ |
| hooks/ (the engine itself) | push only | ✅ bidirectional |
| settings.json (hook registry) | ❌ | ✅ (auto-backup before overwrite) |
| skills/ and skills/learned/ | partial | ✅ |
Core architecture: SYNC_TABLE
A single source-of-truth table inside memory-backup.sh. Both push and pull read the same table, fixing the asymmetric bug where push synced X but pull silently skipped X. Adding a new sync target is one line:
SYNC_TABLE=(
"$CLAUDE_DIR/CLAUDE.md|$REPO_DIR/CLAUDE.md|file|CLAUDE.md (top-level rules)"
"$CLAUDE_DIR/commands|$REPO_DIR/commands|dir-md|slash commands"
# ... add a line, push/pull both pick it up
)
| Feature | Usage | Purpose |
|---|---|---|
| Dry-run | bash memory-backup.sh push --dry-run | Preview what would change before doing it. No real copies. |
| Status | bash memory-backup.sh status | Show local-vs-repo diff + git commits behind/ahead |
| Machine-id | echo "laptop" > ~/.claude/machine-id | Tags commits with machine name for multi-device attribution |
.bb-pause lock | /bb-pause on / off | Pause SessionEnd auto-commit while refactoring engine itself |
.bak.* filter | automatic | settings backup files stay out of the repo |
Step 1 — Create a GitHub repo for memory backup (cross-device sync):
Without a backup repo,
/backup,/sync, and/recoverwon't work. Memory only lives locally — if your machine dies, it's all gone. With a repo, your memory works across devices.
gh repo create claude-memory --private
git clone https://github.com/YOUR_USERNAME/claude-memory.git ~/.claude/claude-memory
Step 2 — Copy files:
cp hooks/*.js ~/.claude/scripts/hooks/
cp hooks/*.sh ~/.claude/scripts/hooks/
cp commands/*.md ~/.claude/commands/
cp -r skill/ ~/.claude/skills/learned/memory-engine/
Step 3 — Create directories:
mkdir -p ~/.claude/sessions/diary
mkdir -p ~/.claude/scripts/hooks
Step 4 — Add hooks config to ~/.claude/settings.json:
{
"hooks": {
"SessionStart": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "node ~/.claude/scripts/hooks/session-start.js"
}
]
}
],
"SessionEnd": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "node ~/.claude/scripts/hooks/session-end.js"
}
]
}
],
"UserPromptSubmit": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "node ~/.claude/scripts/hooks/memory-sync.js"
},
{
"type": "command",
"command": "node ~/.claude/scripts/hooks/mid-session-checkpoint.js"
}
]
}
],
"PreCompact": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "node ~/.claude/scripts/hooks/pre-compact.js"
}
]
}
],
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "node ~/.claude/scripts/hooks/pre-push-check.js"
}
]
},
{
"matcher": "Write",
"hooks": [
{
"type": "command",
"command": "node ~/.claude/scripts/hooks/write-guard.js"
}
]
}
]
}
}
Step 5 — Restart Claude Code. Done!
Done installing? Here's what to do next.
session-start loads your last session's context automaticallysession-end saves a summary if it fires; mid-session-checkpoint and pre-compact already have your back/save stores it in long-term memory/handoff passes your progress to the next window/reflect reviews your notes, finds patterns, cleans upThat's it. Everything else runs in the background.
Memory Engine adds almost no token overhead to your daily usage.
| Hook | When it runs | Token cost |
|---|---|---|
session-start | Once per conversation | ~200–500 tokens (loads last summary + project memory) |
memory-sync | Every message | 0 unless another session changed memory files |
mid-session-checkpoint | Every message | 0 unless it's the 20th message |
write-guard | Before file writes | 0 unless writing a sensitive file |
pre-push-check | Before git push | 0 unless pushing |
session-end / pre-compact | End of conversation / compression | Output not injected into context |
SKILL.md (136 lines) is a learned skill — Claude Code only loads it when relevant, not every conversation.
Bottom line: ~200–500 extra tokens at the start of each conversation. Everything else is zero unless triggered.
| What | Where |
|---|---|
| Context map | Smart Context auto-resolves per-project memory directory (no config needed). Override in session-start.js |
| Keywords | correctionKeywords in shared-utils.js |
| Sensitive files | PROTECTED_PATTERNS in write-guard.js |
| Retention | MAX_SESSIONS in session-end.js (default: 30) |
Why not a database?
.md natively — why add complexity?Why not a Plugin?
.js file is right there to inspectAll code was written from scratch. No code was copied, forked, or adapted from any source project.
| Project | What it inspired |
|---|---|
| contextstream/claude-code | Smart Context, auto-learning from mistakes |
| memvid/claude-brain | Memory statistics, lightweight design |
| rlancemartin/claude-diary | Reflection diary, pattern analysis |
v1.6 — Cross-Device Sync
memory-backup.sh — bidirectional sync script with push, pull, and sync modespull mode distributes global memory files from the backup repo into every local project directory (newer file wins, won't overwrite local changes)push mode auto-detects all project directories instead of hardcoding paths/sync command updated: now runs pull + push in one step/recover command updated: uses memory-backup.sh pull for automatic distributionv1.5.2 — Save System Rewrite
session-end to pre-compact (runs before compression, catches more context)reflect.md, 反思.md, 交接.md generalized for public usev1.5.1 — Quick Reference
/overview (/全覽) to command tables and SKILL.mdv1.5 — Session Handoff + Shared Core
/handoff saves a handoff file, the next session picks it up automatically/analyze compares your edits against rules, logs mistakes, builds an error notebook that auto-reviews before each taskshared-utils.js — extracted shared functions from session-end.js and pre-compact.js, eliminating ~80% duplicated code/backup and /syncv1.4 — The Real Safety Net
/recover on new device pulls everything backv1.3 — The Student Loop
/reflect)/reflect 4-question decision treev1.2 — Full Command Suite
/check + /full-check)v1.1 — Smart Context Auto-detect
claude-memory-engine/
hooks/
session-start.js # New session -> load recall + smart-context + handoff
session-end.js # Session end -> save summary + backup (best-effort)
pre-compact.js # Context compression -> snapshot + pitfall detection + backup
shared-utils.js # Shared functions (transcript, pitfall, backup)
memory-sync.js # Every message -> cross-session memory sync + handoff
write-guard.js # Before file write -> sensitive file warning
pre-push-check.js # Before git push -> safety check
mid-session-checkpoint.js # Every 20 messages -> checkpoint
memory-backup.sh # Bidirectional sync (push/pull/sync) — v1.6
commands/
save.md / 存記憶.md # Save memory across sessions
reload.md / 讀取.md # Load memory
todo.md / 待辦.md # Cross-project tasks
backup.md / 備份.md # Push to GitHub
sync.md / 同步.md # Bidirectional sync
diary.md / 回顧.md # Reflection diary
reflect.md / 反思.md # Pattern analysis
learn.md / 學習.md # Pitfall learning
check.md / 健檢.md # Quick health check
full-check.md / 大健檢.md # Full audit
memory-health.md / 記憶健檢.md
memory-search.md / 搜尋記憶.md
recover.md / 想起來.md
compact-guide.md / 壓縮建議.md
handoff.md / 交接.md # Session handoff
skill/
SKILL.md
references/
smart-context.md
auto-learn.md
MIT — see LICENSE for details.
Made by HelloRuru
Runtime failure resolution for coding agents. Hooks into Claude Code and Codex. Catches loops, dangerous actions, and se
Universal Claude Code workflow plugin with agents, skills, hooks, and commands
Give Claude Code memory that evolves with your codebase via hooks and LLM-compiled knowledge
Blocks dangerous git and shell commands from being executed by AI coding agents