cairn

Local, symbol-aware code index for AI coding agents. Cairn keeps a
daemon-backed structural index of the repos you've registered —
definitions, references, impls, imports, source bodies — so agents can
ask precise code questions without waking a full IDE or scraping text.
Status: 0.8.9. Wire schemas (JSON-RPC + MCP), on-disk format,
and CLI flags follow SemVer 0.x rules — minor releases may break
compatibility. 1.0 will tag once these surfaces stabilize.
Why
AI coding agents need to answer structural questions about code: where
the function foo is defined, who calls bar, what Display is
implemented for, or what a handler calls next. Text search can find
tokens; Cairn gives agents a small, local, queryable model of the
codebase.
The long-lived daemon keeps registered repos indexed as they change.
The query surface is JSON-RPC over a Unix domain socket, and the same
binary ships a stdio MCP front-end so Claude Code, Codex, and other
agents can use those structural facts directly. Tier-3 enrichment can
call each language's local LSP listed in the Languages table; Cairn
does not require a hosted index or cloud service.
Installation
Binary
Homebrew (macOS)
brew tap naoto256/cairn
brew install cairn
Debian / Ubuntu
Download cairn_<version>-1_amd64.deb from the
latest release,
then:
sudo apt install ./cairn_*.deb
The Debian package includes the user systemd unit at
/usr/lib/systemd/user/cairn.service.
Prebuilt binary (any OS / target in the matrix)
Download the tarball for your target from
Releases, extract,
and put cairn on your PATH:
tar -xzf cairn-v<version>-<target>.tar.gz
install cairn-v<version>-<target>/cairn ~/.local/bin/
From source (Rust 1.88+, working git)
cargo install --git https://github.com/naoto256/cairn cairn
Optional runtime dependencies for Tier-3 cross-file resolution are the
local LSP binaries listed in the Languages table. Make sure they are
visible to the daemon; cairn ctl daemon doctor reports which Tier-3
analyzers are discoverable and how to fix missing tools.
Daemon
All query and control commands talk to the running daemon. Homebrew and
Debian installs can run it as a user service; prebuilt / source
installs can either run cairn daemon in a terminal or install one of
the sample service files from contrib/.
Homebrew registers the daemon as a user LaunchAgent:
brew services start cairn
Debian / Ubuntu installs include a user systemd unit:
systemctl --user enable --now cairn.service
The packaged service definitions request a 4096 file-descriptor soft limit.
Direct daemon launches also raise the soft limit to 4096 when the process hard
limit allows it.
Claude Code and Codex plugin
Install the Cairn plugin in your agent host after the binary is on
PATH and the daemon is running. The plugin registers cairn mcp
and, via a SessionStart hook, injects
plugin/SERVER_INSTRUCTIONS.md into each session so the agent
reaches for cairn's structural tools (find_symbols, get_outline,
find_references, etc.) before grep / Read on structure questions.
The guidance is loaded once per session (matchers:
startup|resume|clear|compact), not per tool call.
Claude Code:
claude plugin marketplace add naoto256/cairn
claude plugin install cairn@naoto256-cairn
Codex:
codex plugin marketplace add naoto256/cairn
codex plugin add cairn@naoto256-cairn
For a local checkout, replace naoto256/cairn with the absolute path
to this repository. Restart the agent session after install so the
MCP server registration and the SessionStart hook take effect.
Use
MCP
After installing the plugin, you can ask your agent directly:
Add this repo to cairn.
Understand this codebase's structure.
cairn mcp is a stdio JSON-RPC front-end intended to be spawned by an
MCP client. It gives AI coding agents structural tools over the repos
you register: