Show HN: Capn-hook for coding agents – don't grep the same mystery twice Developer CyrusNuevoDia released Capn-hook, an open-source tool that gives coding agents persistent memory by saving file locations for previously answered questions and automatically deleting stale answers when source files change. In evaluations across five production codebases, agents using Capn-hook used 77% fewer tokens than cold-start exploration while maintaining 100% answer accuracy, reducing token costs and session time for recurring developer queries. Don't grep the same mystery twice. Persistent memory for coding agents. When your agent spends ten minutes figuring out where something lives in your codebase, capn saves the files that answer the question. The next session gets them back in one command instead of re-exploring — and the moment the underlying files change, the saved answer deletes itself. Across 60 real developer questions on 5 production codebases Dub, Polar, PostHog, Twenty, Documenso , an agent recalling from capn used 77% fewer tokens than an agent exploring cold — every answer correct in both arms, the right chart recalled on all 60 questions, and a charting session paying for itself in ~1.6 recalls. How the eval was run, full numbers, and raw evidence → /CyrusNuevoDia/capn-hook/blob/main/eval/RESULTS.md · Who capn is for → /CyrusNuevoDia/capn-hook/blob/main/docs/audience.md · Use cases → /CyrusNuevoDia/capn-hook/blob/main/docs/use-cases.md Coding agents forget everything between sessions. The route from "where are payment webhooks handled?" to " src/api/webhooks.ts , handlers in src/billing/handlers/ " costs real time and tokens — and evaporates when the session ends. Tomorrow's session pays for the same discovery again. capn init installs a session-start hook for Claude Code and Codex. Every new session, the agent sees one short note: before searching the codebase, ask capn; after a hard-won discovery, save it. That note capn context is the entire integration — no wrapper, no middleware, no forced behavior. The model reads it and decides. From there the loop is three moves: 1. Ask before searching. capn ask "where are payment webhooks handled?" A hit returns JSONL with the exact files that answer the question, skipping the whole search. A miss exits 1 with a nudge on stderr to explore and chart what it finds — a miss costs seconds; re-exploring costs minutes. 2. Save what was expensive to learn. When the agent works out an answer the hard way, it records a small, answerable question and the files that answer it, with optional details for extras like line numbers or gotchas: capn chart "where are payment webhooks handled?" \ --files src/api/webhooks.ts,src/billing/handlers/stripe.ts \ --details "Router starts near line 40; Stripe handler owns signature checks." Each backing file is fingerprinted sha256 at save time. Good charts are atomic, not giant context dumps. Split separable facts into separate charts, but include multiple files when they jointly answer one focused question. 3. Stale answers delete themselves. If any backing file changes or disappears, the entry is removed before it can ever answer again. Saved answers are never edited — an answer is either still true its files haven't changed or it's worthless. That's why the commands are chart and unchart , not add and update : capn treats your codebase like a coastline. The agent charts what it has explored; when the coastline shifts, the old chart gets thrown out and the agent re-charts on the next encounter. Worst case, an entry is deleted and the agent re-explores — which is exactly what it would have done without capn. npm install -g capn-hook or bun install -g capn-hook cd /path/to/your/project capn init .capn/, capn's QMD index, Claude Code hooks, and Codex hooks capn init --git also install a post-commit hook that prunes The published CLI ships as JavaScript and runs under Bun when Bun is available, falling back to Node.js. Prefer to delegate? Tell your coding agent to fetch and follow INSTALL.md https://github.com/CyrusNuevoDia/capn-hook/blob/main/INSTALL.md — it's written for the agent to execute, not for you to copy by hand. | Agent | File | Hook | Command | Effect | |---|---|---|---|---| | Claude Code | .claude/settings.json | SessionStart | /usr/bin/env capn context | Inject the ask-first charting contract | | Codex | .codex/hooks.json | SessionStart | /usr/bin/env capn context | Inject the ask-first charting contract | Recall runs on QMD https://github.com/tobi/qmd : semantic hybrid search by default, plain keyword BM25 search with capn init --no-embedding . The default path downloads embedding models on first use about 300MB up front, up to ~2GB for the full hybrid pipeline and a cold capn ask can take a few seconds once they're present; the BM25 path downloads nothing and is fully deterministic. Already use qmd yourself? capn's index is its own sqlite under .capn/ — your collections never see it, and it never sees yours. | Command | Description | |---|---| capn init --git --embedding|--no-embedding | Set up .capn/ , capn's QMD index, hooks, and the .capn/ gitignore line | capn context | Print the ask-first charting contract used by the SessionStart hook | capn ask "