An agent asks about src/cairn/router.py before editing it.
Source: the Impact page's context-served log.
Cairn is institutional memory for coding agents. It gives Claude Code, Codex, Gemini, Cursor, Copilot and more what a senior engineer carries in their head: who calls this code, why it is shaped this way, what broke last spring, what the team agreed and what the last agent did.
$ uv tool install --python 3.12 cairn-brain$ cd your-repo && cairn# Cairn brief: cairn Map 873 files, 16,822 nodes hubs: QueryExecutor, EntityNode, GraphDriver Specs 001-cairn-core · 75/75 tasks done Timeline 3 fixes in router.py this week Memory [gotcha] Memory seeding gets the deep tier's wall-clock cap [decision] 12 core tools by default [convention] Every model call goes through cairn.router Sessions last: "launch video v2 shipped" Drift 49 open findings · run cairn drift Before editing: call cairn_context.
Each film is recorded on Cairn's own repository and its real interface. Start with the one-minute version.
Agents are capable but amnesiac. The context a teammate picks up over months is gone when the session ends, so they burn tokens re-reading and still miss what was never in the files.
Opens 33 files to understand router.py before it writes a line. Next session, it does it again.
Asks cairn_context and gets the dependents, co-changing files and owning task in one pack.
Changes a signature. Grep found the direct callers; the 137 dependents in 40 files did not fit in context.
cairn impact walks the code graph built from Tree-sitter ASTs and lists the tests likely to break.
Proposes the change the team rolled back last spring. The reason lives in a commit message nobody will read.
The timeline carries fixes, reverts and co-change patterns, and surfaces them as historical warnings.
The convention was settled in a pull request thread. The agent never saw it and the reviewer explains it again.
Memory is seeded from ADRs, style docs and git history, and grows each time someone runs cairn remember.
A new chat starts blank. You paste the plan back in, or the agent re-derives it from the diff.
Sessions are captured and summarised. The next one starts with a brief of what earlier agents did and learned.
Each context pack an agent receives is logged with its own size and the size of the files behind it. These numbers come from running Cairn on its own repository. The bars are drawn to scale.
src/cairn/router.py before editing it.Source: the Impact page's context-served log.
Source: the Sessions page. 17,761,951 tokens kept out of future sessions.
cairn recap to see the receipt for your own repository.
Every model call is in cairn models --ledger.
None of these needs a model call. Each one is on by default and can be turned off.
When Claude Code compacts, a resume snapshot under 2 KB hands back the last request, files changed, open tasks, decisions and rejected approaches.
Refused tool calls, error-then-fix pairs, retry loops and your corrections are recorded as their own observations, so the next agent finds them.
A memory no agent has used in 90 days is marked stale and ranks lower. Nothing is deleted, and conventions and decisions never age.
Build a resume briefing from a captured session and start Claude, Codex, Gemini, OpenCode, Cline or Cursor on it.
Session notes cost far fewer model tokens on the new default fast model. Overview shows tokens measured and dollars estimated from your own ledger.
Wire Claude Code, Codex, Cursor, Gemini CLI, OpenCode, Copilot CLI and Antigravity at user level. Repositories without Cairn get a one-line offer.
Cairn stacks five kinds of knowledge about your repository. Each answers one question an agent should ask before it touches code. Pick a stone.
A graph of files, symbols, calls and imports from Tree-sitter ASTs (25 grammars built in), plus docs, schemas and rationale comments. It is how Cairn knows the caller three hops away.
cairn trace path · cairn hubs · cairn areas
A spec-driven workflow of constitution, spec, plan and tasks, traced to the files that implement them. Drift checks find closed tasks whose code moved on.
cairn specs · cairn drift
Git history read for meaning: fixes, reverts, files that change together. With a model, facts with validity windows, like "true from March until the May refactor".
cairn timeline · cairn why <file>
Conventions, decisions, gotchas and preferences from people, agents and the repository itself. New memories update, merge with or retire the ones they overlap.
cairn remember "…" --kind convention · cairn recall
Prompts, files read and changed, and commands from every captured agent session, turned into observations and summaries the next session starts with.
cairn sessions search <query>
cairn
It adds the spec workflow, wires every agent it detects to the Cairn MCP server, installs git hooks and runs the first sync.
$ cairn ✓ agents Claude Code, Codex, Gemini ✓ hooks post-commit, post-merge … ✓ sync 873 files mapped → page http://127.0.0.1:4747
Sessions open with a short brief. Before touching a file, the agent calls cairn_context, cairn_impact or cairn_why over MCP.
agent → cairn_impact router.py HIGH 137 dependents · 40 files 3 past fixes · 5 co-change owner: T006 (FR-017) 391 tokens served
A commit never waits on Cairn. Captured sessions become observations, so next week's agent knows what this week's agent learned.
$ git commit -m "fix: lock on Windows" [cairn] re-sync queued (background) + timeline fix recorded + memory 1 gotcha reconciled + sessions summary written
This is real output from Cairn's own repository. None of it needs a model: it is all built from the code graph, git history, specs and memory.
Impact: src/cairn/router.py HIGH 137 dependents in 40 other files; 3 past fix/reverts; 5 files usually change with it Dependents (+64 more) • Cairn.__init__() core.py:208 calls Router • make_router() recall/worker.py:81 • semantic() drift.py:92 calls Budget • run() sync.py:142 calls Budget Changes together • engines/__init__.py 2 commits (100%) • store.py 2 commits (67%) Historical warnings • 973abd33 fix: Windows worker-lock detection • f3ea2a9e fix: read and write text as UTF-8 Intent • FR-017 route every model call through one layer • T006 model router with tiers and ledger (done) Memory • [convention] Every model call goes through cairn.router with a task name in TASK_TIER
Cairn connects them, keeps them current from git, and hands the agent only the part it needs for the task in front of it.
| The agent knows… | Rules file (AGENTS.md) | Chat or vector memory | Code search index | Cairn |
|---|---|---|---|---|
| Who calls this code, across files | — | — | ~Text matches | ✓Call and import graph |
| What the code was meant to do | ~If someone wrote it down | — | — | ✓Specs traced to files |
| Past fixes and reverts | — | — | — | ✓From git history |
| Team conventions | ✓Kept by hand | ~Per user | — | ✓Seeded and reconciled |
| What earlier agent sessions did | — | ~Chat snippets | — | ✓Observations and summaries |
| Stays current without upkeep | — | ~ | ✓ | ✓Git hooks re-sync |
| Works with no API key | ✓ | ~Varies | ~Varies | ✓Deterministic core |
Impact, why, drift, the map and seeded memory are built from ASTs and git. Evidence is tagged EXTRACTED or INFERRED so the agent knows what to trust.
Python 3.11–3.13 and git. No Docker, no database server. Without a model, nothing leaves your machine.
An Anthropic or OpenAI-compatible key, a local endpoint, or your signed-in Claude Code plan. Each job goes to the cheapest tier that does it well.
Model spend is capped per sync and recorded. cairn uninstall removes everything setup added.
The same server serves a team. A convention one developer records reaches every agent on every laptop the next time it asks.
$ cairn team init --email [email protected] $ cairn serve --team $ cairn project add https://github.com/acme/api.git $ cairn team invite [email protected] --role member # on each laptop $ cairn agents connect --server https://cairn.acme.dev
Not without a model. The map, impact, why, drift and seeded memory are computed locally. If Cairn finds a model, it calls the provider you configured, or your signed-in Claude Code CLI, and records every call in the ledger.
Claude Code, Codex, Gemini CLI, Cursor, OpenCode and GitHub Copilot get the MCP server and a session-start brief. Claude Code also gets session capture hooks, a status line, slash commands and sub-agents. Other agents can turn on capture with cairn sessions integrate install <agent>.
No. The core is deterministic. A model adds summaries, timeline facts with validity windows, narrated answers and semantic drift checks, and Cairn can use your Claude Code plan for those with no key.
Each sync's timeline work is capped at 150,000 tokens by default. Change it with [deep] budget_tokens, or turn it off. Small jobs go to the fast tier; only synthesis uses the deep one. Since 0.3, session notes cost 93–96% less per tool event, and Overview shows your spend from the ledger.
No. Git hooks queue a background re-sync and return straight away.
Run cairn uninstall. It removes the hooks, agent wiring and files that setup added.
Two commands. Your next session starts with what the last hundred learned.
$ uv tool install --python 3.12 cairn-brain