TLDRocket
Sign in

Capn-Hook

GitHub

A new tool called capn-hook gives coding AI agents persistent memory of your codebase, so they stop re-exploring the same files every session. In tests it cut token use by 77% while staying just as accurate.

Based on reporting by GitHub — read the original for the full story.

Summary, retelling and take written by AI under human oversight; images are AI-generated illustrations. How we work · Report an error

Anyone who's watched an AI coding agent burn through a context window just to rediscover where webhook handlers live knows the pain. Every new session starts from zero. The agent greps around, reasons its way to an answer, and then forgets everything the moment the chat ends. Tomorrow it pays the same tax again. Capn-hook, a new open-source CLI, is built specifically to kill that tax.

The idea is almost embarrassingly simple: let the agent save its own hard-won answers, and automatically throw them out the instant they stop being true. capn init drops a session-start hook into Claude Code or Codex that nudges the model to ask capn before searching and to chart its findings after a costly discovery. A capn ask for something like 'where are payment webhooks handled' either returns the exact files instantly or fails fast with a one-second miss, pushing the agent back to normal exploration. A capn chart records the question, the files that answer it, and optional notes like line numbers — each file gets a sha256 fingerprint at save time.

That fingerprinting is the clever part. Capn never edits an entry. It either still points at unchanged files, or it's deleted outright the moment any backing file changes or vanishes. The project leans into a coastline metaphor: charts get thrown out when the terrain shifts, and the agent re-charts on its next pass. Worst case, you're back to exploring cold, which is just the status quo without the tool.

The numbers behind this aren't hand-wavy. Across 60 real developer questions run against five actual production codebases — Dub, Polar, PostHog, Twenty, and Documenso — an agent recalling from capn used 77% fewer tokens than one exploring from scratch, with every answer correct in both conditions and the right files recalled on all 60 questions. The team behind it says a charting session pays for itself after roughly 1.6 recalls, which is a low bar for a habit that costs almost nothing to form.

Under the hood it's refreshingly unglamorous: no daemon, no server, just a local SQLite index and markdown files sitting in a gitignored .capn/ directory, readable by any human who wants to peek. Recall uses a semantic search pipeline by default, or a fully deterministic BM25 keyword mode if you skip the embedding models. It's MIT licensed, agent-agnostic at the core, and installs in about two commands — which, for a tool solving such a specific and recurring annoyance, feels exactly right.

My take — AI-written commentary, not fact-checked reporting

This is the kind of unglamorous plumbing that actually moves the needle on agent costs, and I'd bet more teams adopt something like it than adopt yet another foundation model upgrade this quarter. The hash-based staleness check is the whole trick — no fuzzy judgment calls, no stale context quietly poisoning your agent's answers months later. If you're running coding agents against any codebase larger than a weekend project and you're not caching discoveries like this, you're just paying the exploration tax on repeat, which is a strange way to save money in 2025.

Read more about this at: GitHub

Related stories

The daily briefing

Every AI story that matters, in your inbox by 8am.

TLDRocket reads all relevant sources, removes duplicate coverage, and summarises the day in two minutes. Follow companies and topics for alerts, or get the briefing in Slack. Free, no spam, unsubscribe anytime.