darwin-memo for Claude Code
darwin-memo is a self-curating lesson store: every lesson must keep earning its place through measured outcomes, and lessons that stop paying their way starve and die. This plugin wires that store into Claude Code as the project's outcome-settled memory. Lessons are consulted at session start, deterministic outcome signals are captured while you work, and the session's ticket is settled at session end.
Settlement is never model-discretionary. The model is told an outcome ticket is open and told to leave it alone; the plugin settles from recorded exit codes and nothing else. The plugin never invents outcome deltas.
Install
/plugin marketplace add rogermsc/darwin-memo-claude-plugin
/plugin install darwin-memo@darwin-memo
The hooks and the bundled MCP server drive the darwin-memo package, which you install once per machine:
pip install "darwin-memo>=0.5.0"
For the bundled MCP server you need the mcp extra:
pip install "darwin-memo[mcp]>=0.5.0"
Hooks require python3 on your PATH (stdlib only, no extra packages).
Per-project setup
The plugin is dormant until a project has a store. Create one by adding a first lesson:
darwin-memo ledger .darwin-memo/lessons.json add \
"what should this coding session keep in mind" \
"Run the full test suite before declaring a task done."
The store lives at .darwin-memo/lessons.json relative to the project. Set DARWIN_MEMO_STORE to move it. The host repo owns its store: commit .darwin-memo/lessons.json if you want the lessons shared, and ignore .darwin-memo/sessions/ (the plugin drops a .gitignore in there for you).
What each hook does
SessionStart (also on resume, clear, and compact): if the store exists, the hook mints one ledger decide ticket for the question "what should this coding session keep in mind", injects the rendered lessons into context, and records the open ticket id in a sidecar file under .darwin-memo/sessions/. No store means no output and no writes. A re-fired SessionStart reuses the session's existing ticket instead of minting another.
PostToolUse on Bash: pattern-matches deterministic outcome commands (pytest, npm test, cargo test, go test, ruff, eslint, tsc, mypy, make test) and appends each run's exit code to the sidecar. Capture only; this hook never settles. Interrupted or aborted runs are skipped because a run that was cut short measured nothing.
SessionEnd: settles the open ticket from the recorded signals, runs one ledger tick (the session boundary is the natural upkeep point), and clears the sidecar. SessionEnd is the event installed plugins use for end-of-session work; Stop fires after every assistant turn and would settle one session many times over.
The settlement rule
Deterministic by construction:
- Signals are grouped by check kind (pytest, ruff, tsc, and so on).
- Per kind, the first and last exit codes of the session are compared. Fail then pass is one improvement; pass then fail is one regression. A kind seen once, or unchanged, contributes zero.
- delta = improvements minus regressions. With at least one signal the ticket settles at that delta; a measured net of zero (checks held steady) is a real measurement and settles as zero.
- With zero signals the ticket is abandoned: nothing was measured, and absence of measurement must never be settled as evidence.
Token SLO
Active memory never exceeds the render budget, because weak memories starve. Selection enforces the budget for you: lessons that keep producing good outcomes hold their energy and stay in the rendered set, lessons that stop paying their way lose energy at every tick and drop out, then die. You never prune by hand and the context injection cannot grow without bound.
The SessionStart hook prefers darwin-memo render, the budget-capped renderer. Until that subcommand ships in a release, the hook falls back to formatting darwin-memo top --json (the top ten surviving lessons); the fallback is marked for removal in hooks/session_start.py. On v0.5.0, which predates the observe commands, both are absent and the context degrades gracefully to the decide answer alone.
Bundled MCP server
The plugin bundles the darwin-memo MCP server pointed at the same store, so the model can query lessons mid-session (memory_query), add new ones (memory_add), and inspect the population (memory_stats, memory_obituary). Tickets the model opens through MCP are its own to settle or abandon per the server's instructions; the session ticket belongs to the hooks and the model is told not to touch it.
Honest scope