Local code knowledge for agents

Know the code before you edit.

Cortex indexes a repository into a local semantic graph so agents can resolve ownership, inspect callers, trace dependencies, and estimate blast radius before they edit code.

Answer structural questions directly

Resolve who owns a symbol, where it is used, what calls it, and what sits in its immediate dependency neighborhood without walking raw grep output.

Keep everything local

Cortex builds and queries a persistent graph on your machine. No hosted indexing service, background sync, or remote vendor dependency is required.

Designed for agent workflows

Use the CLI for one-off orientation or keep the daemon warm for editors, automations, and coding agents that need repeated graph lookups.

Grounded in actual measurements

The repository ships a reproducible benchmark harness and published artifacts comparing Cortex against a raw text-search baseline on real open-source repositories.

Install

Install Cortex.

Use the one-line installer for a release binary, or build from source if you want to work on the monorepo.

macOS / Linuxcurl -fsSL https://raw.githubusercontent.com/Blu3Ph4ntom/cortex/main/scripts/install.sh | sh
Windows (PowerShell)irm https://raw.githubusercontent.com/Blu3Ph4ntom/cortex/main/scripts/install.ps1 | iex
Build from sourcegit clone https://github.com/Blu3Ph4ntom/cortex.git cd cortex cargo install --path crates/cortex-cli cargo install --path crates/cortex-daemon
Binary locations

The release installers place binaries in a common local path: ~/.local/bin on Unix and $HOME\.cortex\bin on Windows.

Windows toolchain

Use the MSVC Rust toolchain if your GNU installation does not include gcc.exe and dlltool.exe.

Quick start

Index once, query before you edit.

The practical loop is simple: build the graph, resolve the owner, inspect callers, then check likely blast radius.

Index a repositorycortex index --repo /path/to/repo
Resolve a symbol ownercortex query --repo /path/to/repo find-symbol --name RepositorySession
Check callers before a changecortex query --repo /path/to/repo callers --target open_session
Inspect dependencies and impactcortex query --repo /path/to/repo dependencies --target RepositorySession --direction both --depth 1 cortex query --repo /path/to/repo impact --target open_session --depth 1
Agent workflows

Use it where agents usually guess.

Cortex is strongest before edits, during refactors, and when review context needs real structure instead of filename heuristics.

Pre-edit orientation

Resolve the canonical owner of a symbol before an agent starts patching an unfamiliar codebase.

Refactor safety checks

Inspect callers and dependencies before changing a signature or behavior that might ripple across the repository.

Review context

Attach structural neighbors and likely blast radius to a patch review so the summary is grounded in code relationships.

Local automation

Keep a daemon warm for repeated lookups from editor tooling, local automations, and agent loops.

Good fit

Repository orientation, targeted edits, change review, bounded impact checks, and machine-readable architecture discovery.

Not a fit

Compiler-grade proof, runtime data-flow certainty, or heavy framework indirection that only resolves through execution.

Query model

A small query surface on purpose.

Cortex keeps the query model narrow so agents can learn it quickly and reuse it across repositories.

find-symbol

Resolve the canonical owner candidate for a symbol and get back a file path plus span.

callers / callees

Walk the call chain before you change behavior or when you are tracing outward from a function.

dependencies

Inspect the local inbound and outbound structural neighborhood around a symbol or file.

references / impact / explain

Get conservative reference sets, likely blast radius, and a summary of why a symbol matters in the current graph.

Owner lookupcortex query --repo /path/to/repo find-symbol --name PaymentService
Caller tracecortex query --repo /path/to/repo callers --target update_status
Explain a symbolcortex query --repo /path/to/repo explain --target PaymentService
Agent skill

Install the skill, then let agents use structure.

The website renders the human-facing guide here. The repository root keeps the agent-facing `SKILL.md` that coding agents can install and use directly.

Install the skill

Skill installernpx skills add https://github.com/Blu3Ph4ntom/cortex --skill cortex
Direct raw filehttps://raw.githubusercontent.com/Blu3Ph4ntom/cortex/main/SKILL.md

Tell an agent to use it

Instruction snippetUse the Cortex skill before editing this repository. Index the repo, resolve the owner of the target symbol, inspect callers or dependencies, then run impact before you patch code.
What the root SKILL.md teaches

When to use Cortex, which queries to sequence first, how to quote structural results, and how to report uncertainty honestly when runtime behavior exceeds syntax.

Why this section exists

Humans can review the workflow here on the website, while coding agents can consume the real source file directly from the repository.

Daemon API

Keep the graph warm for tools.

Use the local daemon when another process needs repeated structural access without shelling out for each query.

Start the daemoncortexd --repo /path/to/repo --bind 127.0.0.1:8787
Resolve a symbol over HTTPcurl "http://127.0.0.1:8787/graph/find_symbol?name=RepositorySession"
Ask for callers over HTTPcurl "http://127.0.0.1:8787/graph/callers?target=open_session"
Architecture

A small Rust monorepo with hard boundaries.

The codebase is split so the core graph engine stays reusable while the CLI and daemon stay thin.

cortex-core

Graph model, parser extractors, indexer, storage layer, and typed query engine.

cortex-cli

Index, doctor, export, watch, and query commands for local use and scripting.

cortex-daemon

Local HTTP surface for tools that want a long-lived process instead of spawning the CLI for each lookup.

Current semantic shape

Repositories, files, symbols, and edges such as defines, contains, imports, references, calls, depends_on, and owned_by.

Current tradeoff

Cortex is intentionally conservative and syntax-driven. That makes it useful for navigation and pre-edit context, but not compiler-grade proof.

Contributing

Treat it like infrastructure.

Contributor ergonomics, repeatable tests, and benchmark artifacts matter because Cortex is meant to support real engineering workflows.

Developer loop

Format, lint, test, and self-checkcargo fmt cargo clippy --all-targets --all-features -- -D warnings cargo test --all-targets powershell -ExecutionPolicy Bypass -File .\scripts\self-test.ps1

What ships with the repo

AGENTS.md

Repository-specific contributor instructions for working on Cortex itself.

SKILL.md

Agent-facing instructions for using Cortex on arbitrary codebases.

Benchmarks

Reproducible benchmark artifacts and the PowerShell harness that generated them.

Project status

Cortex is already useful for local structural awareness and agent workflows. It is still OSS beta software, not yet a compiler-accurate or fleet-scale autonomous editing platform.

Benchmarks

Measured against raw text search.

The benchmark harness in this repository compares Cortex warm-query results against `git grep -n -w` on the same structural tasks.

What is being measured

Cold indexing on a fresh local store, warm structural queries on a prepared store, and a raw grep baseline over the same repositories and targets.

How to read the results

Grep is often faster to start, but Cortex wins by collapsing the search surface into a much smaller set of structural answers that an agent can actually use.

Corpus5 repos / 6 scenarios

343 files, 4749 symbols, and 42690 indexed edges across the benchmark set.

Candidate narrowing34.9x fewer raw hits

349 grep hits across 78 files dropped to 10 structural answers.

Rust / Cortex13 files / 323 symbols / 2914 edges

Cold index median: 324.01 ms

Rust / mini-redis27 files / 249 symbols / 2254 edges

Cold index median: 147.67 ms

Python / requests36 files / 759 symbols / 5373 edges

Cold index median: 286.48 ms

Go / chi74 files / 433 symbols / 5809 edges

Cold index median: 277.88 ms

JavaScript / axios193 files / 2985 symbols / 26340 edges

Cold index median: 777.7 ms

ScenarioCortex medianBaseline medianCortex resultsGrep hitsGrep filesReduction
Resolve RepositorySession owner Cortex / Rust59.83 ms43.55 ms1491449x
Trace open_session callers Cortex / Rust45.41 ms42.5 ms428107x
Resolve requests.Session owner requests / Python68.5 ms45.63 ms114010140x
Trace read_frame callers mini-redis / Rust46.82 ms43.68 ms2743.5x
Resolve chi.NewRouter owner chi / Go81.59 ms47.2 ms112037120x
Resolve axios.dispatchRequest owner axios / JavaScript180.34 ms42.2 ms1535x
Cortex / RustResolve RepositorySession owner

RepositorySession resolves to crates\cortex-core\src\indexer.rs:38.

Cortex: 59.83 ms. Grep: 43.55 ms. Candidate reduction: 49x.

Cortex / RustTrace open_session callers

open_session resolves to main, run_index, run_query, run_watch.

Cortex: 45.41 ms. Grep: 42.5 ms. Candidate reduction: 7x.

requests / PythonResolve requests.Session owner

Session resolves to src\requests\sessions.py:357.

Cortex: 68.5 ms. Grep: 45.63 ms. Candidate reduction: 140x.

mini-redis / RustTrace read_frame callers

read_frame resolves to next_message, read_response.

Cortex: 46.82 ms. Grep: 43.68 ms. Candidate reduction: 3.5x.

chi / GoResolve chi.NewRouter owner

NewRouter resolves to chi.go:60.

Cortex: 81.59 ms. Grep: 47.2 ms. Candidate reduction: 120x.

axios / JavaScriptResolve axios.dispatchRequest owner

dispatchRequest resolves to lib\core\dispatchRequest.js:34.

Cortex: 180.34 ms. Grep: 42.2 ms. Candidate reduction: 5x.