Cairn
Keeps AI coding agents consistent with the decisions your project already made.

Plugin for Claude Code, Cursor, and Codex · MCP server · pre-commit and CI checks
The problem
Monday you tell your agent "auth tokens expire after 24 hours." It ships.
Friday, new session. The agent reads auth/tokens.ts, sees nothing about
expiry, and "improves" it to a 7-day refresh. You catch it in review, or you
don't.
The model isn't bad. It has no memory of what you decided. A bigger context
window only delays the problem. Cairn keeps a version-controlled record of
your decisions in the repo, loads the relevant ones into every agent session,
and checks every diff against them at commit time and again in CI.
20-second example
A decision recorded with a machine-checkable assertion:
{
"title": "Auth tokens expire after 24 hours",
"scope_globs": ["src/auth/**"],
"assertions": [{ "id": "a1", "kind": "text_must_match",
"pattern": "TOKEN_TTL_SECONDS = 24 \\* 60 \\* 60;",
"in_globs": ["src/auth/tokens.ts"] }]
}
Then a change that drifts from it:
$ git diff -U0 -- src | tail -2
-export const TOKEN_TTL_SECONDS = 24 * 60 * 60;
+export const TOKEN_TTL_SECONDS = 7 * 24 * 60 * 60;
$ git commit -am "perf(auth): extend token TTL to 7 days"
ERROR decision-assertions: DEC-674be42/a1 text_must_match `TOKEN_TTL_SECONDS = 24 \* 60 \* 60;` — no file under src/auth/tokens.ts matches
Cairn pre-commit gate FAILED — 1 hard finding(s). Fix them, then re-commit (or `git commit --no-verify` to bypass; the bypass is flagged at the next session and caught by CI).
That output is real, captured from @isaacriehm/[email protected] installed
from npm into a fresh repo. The full transcript also shows a
compliant edit to the same file committing cleanly, a throw new Error("not implemented") stub being blocked, and the CI check catching a
--no-verify bypass.
In daily use you don't write that JSON. The agent records decisions through
Cairn's MCP tools, and adoption pulls existing ones out of your docs, code
comments, and CLAUDE.md / AGENTS.md. Most decisions carry no assertion.
They work by being loaded into the agent's context before it touches
in-scope files.
Quick start
Requires Node 22+ and git.
In your agent (recommended)
Claude Code
/plugin marketplace add isaacriehm/cairn
/plugin install cairn@isaacriehm-cairn
/reload-plugins
Codex (CLI and Desktop)
codex plugin marketplace add isaacriehm/cairn
codex plugin add cairn@cairn
In Codex Desktop, restart after adding the source, open Plugins, and
install Cairn. Codex asks you to trust the bundled hooks before they run.
Cursor
Settings → Cursor → Plugins → Add from GitHub → isaacriehm/cairn
Then open a session in any git repo. Cairn's SessionStart hook offers to
adopt the project. Accept once. Adoption runs inline and reads your docs,
source comments, and agent rule files into .cairn/. The run time depends
on repo size. From then on every session starts with the relevant decisions
loaded, and Cairn wires its git hooks into each clone at session start.
The plugin bundles its own CLI and MCP server, so there's nothing to
npm install. Model-backed steps go through the CLI of the host that loaded
the plugin (claude, cursor-agent, or codex), so no separate API key is
needed.
In Claude Code, turn off the built-in auto-memory (/memory → Disable Auto-Memory). Cairn is the memory layer, and the two conflict.
CLI only
npm install -g @isaacriehm/cairn
cd your-repo
cairn init # interactive adoption
cairn join # activates the git hooks in this clone
cairn doctor # health check
git add -A && git commit -m "chore: adopt cairn"
cairn init --no-prompt adopts without prompts for scripts and CI. It skips
the model-backed mapper and doc ingestion, so it starts with an empty
decision ledger. Each new clone runs cairn join once. The plugin does this
automatically at session start.
How it works