gitwtfhub

wtf is capn-hook?

cyrusnuevodia/capn-hook — explained in plain English

Analysis updated 2026-05-18

88TypeScriptAudience · developer

TL;DR

cap'n hook gives coding agents like Claude Code persistent memory of where things live in a codebase, saving discoveries as hash verified answers that self delete when the underlying files change.

Mindmap

mindmap
  root((capn hook))
    What it does
      Persistent agent memory
      Ask before searching
      Auto deletes stale answers
    Tech stack
      TypeScript
      Node.js
      Bun
      SQLite
    Use cases
      Faster repeat questions
      Token savings
      Self healing cache
    Audience
      Coding agent users

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Save an AI coding agent's hard won discovery about where code lives so future sessions can recall it instantly.

REASON 2

Cut down repeated token heavy codebase exploration across coding agent sessions.

REASON 3

Automatically invalidate saved answers the moment their backing files change or disappear.

What's in the stack?

TypeScriptNode.jsBunSQLite

How it stacks up

cyrusnuevodia/capn-hookfayazara/pdfstudiopablogdcr/daily-crumple
Stars888987
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasymoderate
Complexity2/54/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

Wtf does this do

cap'n hook, usually called capn, gives AI coding agents like Claude Code or Codex a kind of persistent memory about a codebase. Normally, when an AI assistant spends time figuring out where something lives in a project, such as which file handles payment webhooks, that knowledge disappears once the session ends. The next time someone asks a similar question, the agent has to search the whole codebase again from scratch. Capn saves that hard won answer so it can be recalled instantly instead. The tool works through a simple three step loop. Before searching, the agent asks capn a question in plain language, and if a matching saved answer exists, capn returns the exact files that answer it right away. If there is no match, the agent explores the codebase as usual and then saves what it learned, listing the specific files involved and any helpful notes, such as a line number or a tricky detail. Each saved file is fingerprinted using a hash, so capn can tell later if that file has changed. This is the key trick behind the memory staying trustworthy: if a file backing a saved answer ever changes or is deleted, that answer is automatically deleted too, rather than being edited or left stale. So an agent either gets a valid, still true answer, or it gets nothing and falls back to exploring again, which is exactly what would have happened without the tool. According to the project's own testing across sixty real developer questions on five existing open source codebases, using capn's saved answers cut token usage by about seventy seven percent compared to searching cold, with every answer still correct. Setup is done through a command line tool installed with npm or Bun. Running one setup command adds a hook that tells the coding agent, at the start of every session, to check capn before searching and to save discoveries afterward. Saved answers are stored as small local markdown files that a person can also open and read directly, and the whole memory folder is excluded from version control by default, so it stays local to each developer's own working copy.

Yoink these prompts

Prompt 1
Explain how content hashing can be used to detect when a cached answer about a codebase has gone stale.
Prompt 2
How would I write a SessionStart hook for Claude Code that injects instructions before the agent starts working?
Prompt 3
Show me a CLI tool design that saves question and answer pairs as local markdown files with frontmatter metadata.
Prompt 4
What is the difference between semantic search and keyword BM25 search for recalling saved text?

Frequently asked questions

wtf is capn-hook?

cap'n hook gives coding agents like Claude Code persistent memory of where things live in a codebase, saving discoveries as hash verified answers that self delete when the underlying files change.

What language is capn-hook written in?

Mainly TypeScript. The stack also includes TypeScript, Node.js, Bun.

Who is capn-hook for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.