Why
Reading a whole file adds up
Reading this 2,336-line file to find one function signature adds about 21,000 tokens to the conversation. That leaves less room for the task and earlier decisions. code-kb can show the signature or the function's context on its own.
Read the file
cat crates/code-kb-core/src/telemetry.rs
- Lines
- 2,336
- Tokens
- ≈ 20,900
- Needed
- one signature
Ask code-kb
file_skeleton("telemetry.rs")
get_symbol_context("sanitize_error_message")
- Skeleton
- ≈ 2,400 tokens, 88% less
- Context slice
- ≈ 420 tokens, 98% less
- Query time
- ≈ 5 ms skeleton, ≈ 110 ms context
What it does
What your agent can find
- File outlines
file_skeletonlists a file's types and function signatures without the implementation. On a folder, it gives a short directory overview.- Function context
get_symbol_contextshows a function's code and return type, its callers with their evidence, the tests to run with their commands, the markers its sibling symbols share, the signatures of functions it calls, and related types, in one call.- Callers and tests
find_referenceslists every caller site, andblast_radiusfollows callers across the repository to the tests to run. Use them when you need the full list. With no target,blast_radiuschecks your uncommitted changes.- Post-edit check
- After you edit,
check_editlists the symbols whose shape changed and every call, construction, or match that your diff did not reach.code-kb hook Stopruns it when the agent stops and blocks once if a site still uses the old shape. - Up-to-date results
- Edit files as usual. code-kb picks up changes automatically and refreshes a file before showing its body or outline.
- Usage stats
- Run
code-kb statsto see estimated tokens saved, tool calls, and errors across sessions. - Windows support
- Every release includes a Windows binary tested on NTFS. Results show paths with forward slashes on every platform.
- Structural facts
- Find routes, queries, config keys, and more with the
code-kb factscommand. It lists the categories indexed in your repository. - Agent hooks
code-kb hook SessionStarttells the agent when to use each tool and records the commit the session started at.code-kb hook Stopandcode-kb hook SubagentStoprun the edit check. The hooks run from the binary without a script runtime.
Languages
42 supported languages
The bundled julie-extract 3.12.0 indexes these languages and file formats. What it can extract varies by language.
- Code and scripts
- Bash, C, C++, C#, Dart, Elixir, Erlang, F#, GDScript, Go, Java, Kotlin, Lua, PHP, PowerShell, Python, R, Ruby, Rust, Scala, Swift, VB.NET, Zig.
- Web and UI
- CSS, HTML, JavaScript, JSX, QML, qmldir, Razor, TSX, TypeScript, Vue.
- Data and documents
- go.mod, go.sum, JSON, Markdown, regex, SQL, TOML, XML, YAML.
Find more than names
Structural facts are indexed details beyond symbol names. Examples include Express and FastAPI routes, SQL statements, TOML keys, Go module dependencies, and QML bindings. Run code-kb facts to see the categories found in your repository, or code-kb facts route to list routes. See the extractor's supported-language list for more detail.
Compared
code-kb and manual file search
| Task | With code-kb | Reading and searching files |
|---|---|---|
| Prompt tokens per lookup | 61–99% fewer than a full-file read in measured examples | 5,000–15,000 per file read |
| Find a signature | file_skeleton, bodies removed |
Find and copy the relevant lines |
| Search by concept | Search indexed names and signatures | Search file text, including comments and logs |
| Prepare an edit | get_symbol_context, one call |
Find the function and related code separately |
| Calls outside the project | Common runtime calls filtered across source languages | Filter matches yourself |
| Predict which tests to run | get_symbol_context lists the tests to run; blast_radius walks further |
Find relevant tests yourself |
| Select an overloaded symbol | Choose the exact result by its symbol_id |
Narrow it down by name and file path |
| Query time | 1–100 ms for most warm queries; check_edit takes seconds on a real diff |
Depends on the file and search command |
| Memory held by the server | About 25–40 MB; 50–60 MB after a large callers report | No server process |
| Context left for the task | Less file text added to the conversation | Full file reads use more of the conversation |
Steps
From first look to tested change
Here's one way to use code-kb when you start work in an unfamiliar repository.
-
Orient
Directory tree and the main exports, in a few hundred tokens.
file_skeleton("src") -
Find the interface
Signatures and traits with bodies removed. Search by concept when the name is unknown.
file_skeleton("src/server.rs") lookup_symbol("auth token validation") -
Get the context
Before you change a symbol: its body, its callers, the tests to run with their commands, the markers its siblings share, its callees' signatures, and its types in one call.
get_symbol_context("handle_request") -
Edit
Read the file you will edit, since the editor needs it, and edit with your usual tools. code-kb picks up file changes automatically.
-
Check the edit
The symbols whose shape changed and every site that your diff did not reach. For the full list of callers or tests, call
find_referencesorblast_radius.check_edit()
-
Verify
Run the tests that the context listed. Check usage with
code-kb stats.cargo test handle_request code-kb stats
Tools
Seven tools, each with a matching command
Every MCP tool has a one-to-one CLI command, so you can check any answer from the terminal.
Every tool also requires project_root, the absolute path of the project or git worktree you work in. The Accepts column lists the other parameters. The CLI takes the same value as --root, which defaults to the current directory.
| MCP tool | CLI command | Returns | Accepts |
|---|---|---|---|
file_skeleton | code-kb skeleton <file>or code-kb outline [path] for a folder | File outline, bodies removed; a folder returns its layout; public_only hides private rows | file_path (a file or a folder), public_only |
lookup_symbol | code-kb lookup <query> | Name, prefix, or concept; a query that names no symbol exactly also gets ranked matches; a query that names one definition with a short body also gets that body; a query with /, ., {, or : also lists matching routes and config keys; each result row includes id=<symbol_id> | query, path, kind, is_test, limit |
get_symbol_body | code-kb body [symbol]or code-kb body --symbol-id <id> | Source of one symbol | symbol_name or symbol_id, file_path |
get_symbol_context | code-kb context [symbol]or code-kb context --symbol-id <id> | Body and return type, callers summary, tests to run with commands, callee signatures, types, open ends | symbol_name or symbol_id, file_path, include_external |
find_references | code-kb refs [symbol]or code-kb refs --symbol-id <id> | Every caller site, labeled by its evidence, or callees with stdlib calls filtered | symbol_name or symbol_id, file_path, direction (default callers), include_external, offset, limit |
blast_radius | code-kb blast-radius [symbol]or code-kb blast-radius --symbol-id <id>or code-kb blast-radius --file <file> | Multi-hop callers and tests to run | symbol, symbol_id, or file (omitted target reads git changes), depth (default 2), include_low_signal, offset, limit |
check_edit | code-kb check [--base REV] | After you edit: the symbols whose shape changed, and every site of each that your diff did not reach | base (default: the session base, else HEAD), offset, limit |
Four query commands have no MCP tool: code-kb outline [path] prints a folder's layout, which file_skeleton on a folder also returns, code-kb search <query> prints the ranked search with each row's score (--explain adds the score breakdown), code-kb facts [category] lists routes, queries, models, and config keys, and code-kb stats reports token savings and tool errors.
Install
Connect it to your agent
Choose your agent below for setup steps. The plugin needs Node.js 18 or newer. On first use, it downloads code-kb and the matching julie-extract for your platform.
You can also download the release archive, put both binaries on PATH, and register the server yourself. The same code-kb serve command works in GUI apps and terminal agents. --root is optional; it only prepares that project's index at start. See the README for more setup options.
Install the plugin, skill, and hooks with these two commands:
/plugin marketplace add anortham/code-kb
/plugin install code-kb@code-kb
For manual setup across projects on this machine:
claude mcp add --scope user code-kb -- code-kb serve
For one project, in .mcp.json:
{
"mcpServers": {
"code-kb": {
"command": "code-kb",
"args": ["serve"]
}
}
}
Install the plugin, skill, and hooks:
grok plugin install anortham/code-kb --trust
# or from a local checkout:
grok plugin install /path/to/code-kb --trust
For one project, in .mcp.json:
{
"mcpServers": {
"code-kb": {
"command": "code-kb",
"args": ["serve"]
}
}
}
Install the plugin, skill, and hook:
agy plugin install https://github.com/anortham/code-kb
Or by hand, from the command line:
agy mcp add code-kb code-kb serve
Or in ~/.gemini/config/mcp_config.json with eager tools. The same config works for the AGY CLI and the Antigravity IDE:
{
"mcpServers": {
"code-kb": {
"command": "code-kb",
"args": ["serve"],
"disabled": false,
"eager": true,
"force_all_tools_eager": true
}
}
}
In ~/.gemini/config/hooks.json (Antigravity uses PreInvocation):
{
"code-kb": {
"PreInvocation": [
{
"command": "code-kb hook PreInvocation",
"timeout": 10,
"type": "command"
}
]
}
}
Link the skill so the agent knows when to use each tool:
ln -sf /path/to/code-kb/skills/code-kb ~/.gemini/config/skills/code-kb
Install the plugin, skill, and hooks:
codex plugin marketplace add anortham/code-kb
codex plugin add code-kb@code-kb
Run codex, open /hooks, and trust the four code-kb hooks.
To update, refresh the marketplace snapshot first. codex plugin remove followed by codex plugin add reinstalls the version already in the snapshot:
codex plugin marketplace upgrade
codex plugin remove code-kb@code-kb
codex plugin add code-kb@code-kb
Or by hand, in ~/.codex/config.toml:
[mcp_servers.code-kb]
command = "code-kb"
args = ["serve"]
Add this to .cursor/mcp.json in your repository:
{
"mcpServers": {
"code-kb": {
"command": "code-kb",
"args": ["serve"]
}
}
}
code-kb hook prints the routing instructions the agent reads at session start. No Node.js or shell needed. Supports SessionStart, SubagentStart, and PreInvocation (Antigravity). Stop and SubagentStop read the hook JSON on stdin and run the edit check: they block the stop when a proven site still uses the old shape (never for a likely site, a signature change, or a JavaScript parameter change), skip the diff they checked or blocked on last, and print nothing otherwise. The SessionStart hook records the session base in .code-kb/sessions/.
code-kb hook SessionStart
code-kb hook SubagentStart
code-kb hook PreInvocation
code-kb hook Stop
code-kb hook SubagentStop
# Manual equivalent of the plugin's hooks/claude-codex-hooks.json (code-kb on PATH):
{
"hooks": {
"SessionStart": [
{
"matcher": "startup|resume|clear|compact",
"hooks": [{ "type": "command", "command": "code-kb hook SessionStart" }]
}
],
"SubagentStart": [
{
"hooks": [{ "type": "command", "command": "code-kb hook SubagentStart" }]
}
],
"Stop": [
{
"hooks": [{ "type": "command", "command": "code-kb hook Stop" }]
}
],
"SubagentStop": [
{
"hooks": [{ "type": "command", "command": "code-kb hook SubagentStop" }]
}
]
}
}