Jul 15, 2026 ai-code

cap'n hook Review 2026: Persistent Memory for Coding Agents That Auto-Expires When Files Change

In-depth review of cap'n hook — a lightweight local memory tool that lets coding agents save answers and recall them across sessions, with automatic cache-busting via sha256 file fingerprints. Claude Code and Codex native, 77% token savings.

Every developer who uses coding agents knows the ritual: you spend the first ten minutes of each session re-explaining your codebase structure, re-discovering where certain logic lives, and re-answering questions the agent solved yesterday. Agents are amnesiacs — when the session ends, everything resets. cap’n hook is a delightfully simple answer to this problem.

cap'n hook

The idea is elegant: when a coding agent figures out where something lives or how something works, it saves the answer as a Markdown file in a local .capn/ directory. Next session, instead of re-exploring, the agent recalls the answer with a single command. The killer feature is cache-busting: each saved answer is fingerprinted with the sha256 hash of its backing files. The moment any of those files change, the memory is automatically deleted. You’re never working from stale information.

What cap’n hook Does

cap’n hook is a lightweight, local-first CLI tool that installs as a SessionStart hook for Claude Code and Codex. When an agent answers a question — say, “where does authentication middleware live?” — cap’n hook saves the relevant files and a summary. Next session, the agent can recall that answer instantly via the .capn command. Under the hood, it stores human-readable Markdown entries in a gitignored directory, supports hybrid or BM25 search across saved memories, and maintains a graph of which files answer which questions. In benchmarks across five production codebases and 60 real developer questions, agents using cap’n hook recalled answers with 77% fewer tokens than cold exploration, at equal correctness.

Use Cases

  • Codebase onboarding persistence: When an agent spends 20 minutes tracing a complex data flow, save the result. Next developer (or next session) gets the answer in seconds.
  • Recurring debugging patterns: If you keep asking “how does the payment pipeline handle retries,” save the answer once and recall it every time you touch that module.
  • Multi-session architecture exploration: An agent incrementally maps a large codebase across sessions, building a persistent mental model rather than starting from zero each time.
  • Team knowledge sharing: The .capn/ directory is local, but you can commit and share selected entries as team documentation.

Key Features

Persistent Recall with One Command

When your agent figures something out, one command saves the answer. Next session, .capn [question] retrieves it instantly. No re-exploration, no re-reading half the codebase.

Auto Cache-Bust via File Fingerprints

Each memory is linked to the sha256 hashes of its source files. When a file changes, its associated memories are automatically invalidated and deleted. You never get a stale answer about code that has since been refactored.

Lightweight, Zero-Wrapper

Installs as a SessionStart hook — no middleware, no API server, no external dependencies beyond the embedding model downloaded on first run. The agent just knows about .capn and uses it naturally.

Human-Readable Memory Graph

All entries live as plain Markdown files in .capn/entries/. You can browse, edit, or delete them manually. They’re gitignored by default but can be shared selectively.

Pricing

cap’n hook is free and open source under the MIT license. There are no paid tiers, no SaaS, and no accounts. The only cost is the one-time download of an embedding model (300MB–2GB depending on the model chosen) on first run.

Common Questions

What happens if I refactor code that has saved memories? The memories tied to changed files are automatically deleted. Next time your agent encounters that code, it will re-explore and save fresh answers. The system errs on the side of correctness — a forgotten answer is better than a wrong one.

Does this work with agents other than Claude Code and Codex? The official SessionStart hooks are currently for Claude Code and Codex, but the core CLI is agent-agnostic. Any agent that can call shell commands can use capn recall and capn save. Support for additional agents is likely as the project matures.

Verdict

cap’n hook solves a narrow but universal pain point in AI-assisted development with remarkable elegance. The sha256 cache-busting is the right design decision — it turns memory from a liability (stale answers) into a reliable asset. The 77% token savings figure from their benchmark aligns with intuition: agents spend a huge fraction of their context window re-learning things they already “knew” in previous sessions. For developers who use Claude Code or Codex daily, this is a no-brainer install. The main limitations are modest: first-run model download, local-only scope, and reliance on the agent actually using the hook — but none of these diminish the core value proposition. Simple, focused, and immediately useful.

Explore the best AI Coding tools

Related Articles

Subscribe to the 9bests weekly — get the full list free

Hand-picked AI tool reviews and updates every week. Subscribe to receive this full list + 7 more quick-reference sheets (writing / image / video / audio / chat models / data / API cost).

Subscribe free & get it →

Independent reviews — ratings aren't influenced by vendor payments · double opt-in · unsubscribe anytime