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 PATH behavior

The PowerShell installer adds the default install directory to the current session PATH immediately and persists it for new shells. If you set CORTEX_INSTALL_DIR, it uses that directory but leaves your user PATH unchanged.

Windows toolchain

Build from source with 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.

Corpus26 repos / 27 scenarios

9087 files, 63161 symbols, and 727716 indexed edges across the benchmark set.

Candidate narrowing1914.22x fewer raw hits

34456 grep hits across 4379 files dropped to 18 structural answers.

Rust / Cortex23 files / 289 symbols / 2669 edges

Cold index median: 178.84 ms

Rust / mini-redis28 files / 303 symbols / 2512 edges

Cold index median: 143.18 ms

Python / requests50 files / 759 symbols / 6595 edges

Cold index median: 263.83 ms

Go / chi76 files / 433 symbols / 5811 edges

Cold index median: 282.34 ms

JavaScript / axios298 files / 4442 symbols / 39501 edges

Cold index median: 1209.77 ms

TypeScript / redux223 files / 16022 symbols / 227388 edges

Cold index median: 7155.1 ms

Java / retrofit927 files / 7770 symbols / 101459 edges

Cold index median: 4355.44 ms

Kotlin / kotlinx.coroutines1098 files / 78 symbols / 1429 edges

Cold index median: 1043.47 ms

C# / Newtonsoft.Json947 files / 8435 symbols / 136192 edges

Cold index median: 6894.25 ms

C / curl1050 files / 907 symbols / 17178 edges

Cold index median: 2126.93 ms

C++ / fmt89 files / 107 symbols / 913 edges

Cold index median: 1327.34 ms

Swift / swift-argument-parser169 files / 2067 symbols / 11716 edges

Cold index median: 540 ms

Objective-C / AFNetworking88 files / 22 symbols / 171 edges

Cold index median: 222.5 ms

Ruby / jekyll295 files / 94 symbols / 1045 edges

Cold index median: 263.3 ms

PHP / composer589 files / 4771 symbols / 14347 edges

Cold index median: 1164.51 ms

Scala / twitter-util757 files / 7155 symbols / 83211 edges

Cold index median: 4203.7 ms

Elixir / phoenix215 files / 1531 symbols / 15950 edges

Cold index median: 732.59 ms

Erlang / cowboy193 files / 0 symbols / 193 edges

Cold index median: 372.47 ms

Dart / http410 files / 351 symbols / 2825 edges

Cold index median: 1988.99 ms

Lua / luarocks174 files / 1004 symbols / 5165 edges

Cold index median: 563.94 ms

R / dplyr217 files / 1124 symbols / 2575 edges

Cold index median: 555.2 ms

Julia / DataFrames.jl80 files / 0 symbols / 80 edges

Cold index median: 1007.6 ms

Haskell / aeson135 files / 2 symbols / 139 edges

Cold index median: 342.35 ms

OCaml / base597 files / 39 symbols / 769 edges

Cold index median: 914.59 ms

Clojure / clojure335 files / 5298 symbols / 47543 edges

Cold index median: 3307.14 ms

Bash / nvm24 files / 158 symbols / 340 edges

Cold index median: 118.37 ms

ScenarioCortex medianBaseline medianCortex resultsGrep hitsGrep filesReduction
Resolve RepositorySession owner Cortex / Rust102.03 ms17.86 ms2511525.5x
Trace open_session callers Cortex / Rust90.12 ms23.81 ms428117x
Trace read_frame callers mini-redis / Rust85.32 ms17.71 ms2743.5x
Resolve requests.Session owner requests / Python148.44 ms55.95 ms114010140x
Resolve chi.NewRouter owner chi / Go162.04 ms30.27 ms112037120x
Resolve axios.dispatchRequest owner axios / JavaScript564.23 ms33.28 ms1535x
Resolve redux.createStore owner redux / TypeScript2882.81 ms47.69 ms133355333x
Resolve Retrofit owner retrofit / Java1499.76 ms72.55 ms116914981691x
Resolve CoroutineScope owner kotlinx.coroutines / Kotlin76.6 ms80.08 ms06451940x
Resolve JsonConvert owner Newtonsoft.Json / C#2114.09 ms66.65 ms120612112061x
Resolve curl_easy_init owner curl / C353.41 ms192.7 ms09267670x
Resolve fmt::format owner fmt / C++97.12 ms24.14 ms02581920x
Resolve ArgumentParser owner swift-argument-parser / Swift216.7 ms27.01 ms02041160x
Resolve AFHTTPSessionManager owner AFNetworking / Objective-C57.05 ms24.28 ms088160x
Resolve Jekyll owner jekyll / Ruby67.95 ms53.06 ms022794280x
Resolve Composer owner composer / PHP242.21 ms85.15 ms164286256428x
Resolve Future owner twitter-util / Scala1385.72 ms82.77 ms127451722745x
Resolve Phoenix.Endpoint owner phoenix / Elixir213.85 ms36.75 ms0501710x
Resolve cowboy_req owner cowboy / Erlang54.01 ms37.61 ms013701600x
Resolve Client owner http / Dart290.86 ms48.62 ms125060250x
Resolve Rockspec owner luarocks / Lua195.73 ms46.61 ms0152520x
Resolve filter owner dplyr / R159.58 ms33.28 ms0874910x
Resolve DataFrame owner DataFrames.jl / Julia53.44 ms23.92 ms06804770x
Resolve ToJSON owner aeson / Haskell53.55 ms72.95 ms0391380x
Resolve Base owner base / OCaml62.62 ms37.87 ms04111750x
Resolve clojure.core owner clojure / Clojure715.67 ms28.06 ms015261070x
Resolve nvm owner nvm / Bash55.24 ms31.91 ms118452941845x
Cortex / RustResolve RepositorySession owner

RepositorySession resolves to crates/cortex-core/src/indexer.rs:40.

Cortex: 102.03 ms. Grep: 17.86 ms. Candidate reduction: 25.5x.

Cortex / RustTrace open_session callers

open_session resolves to main, run_index, run_query, run_watch.

Cortex: 90.12 ms. Grep: 23.81 ms. Candidate reduction: 7x.

mini-redis / RustTrace read_frame callers

read_frame resolves to next_message, read_response.

Cortex: 85.32 ms. Grep: 17.71 ms. Candidate reduction: 3.5x.

requests / PythonResolve requests.Session owner

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

Cortex: 148.44 ms. Grep: 55.95 ms. Candidate reduction: 140x.

chi / GoResolve chi.NewRouter owner

NewRouter resolves to chi.go:60.

Cortex: 162.04 ms. Grep: 30.27 ms. Candidate reduction: 120x.

axios / JavaScriptResolve axios.dispatchRequest owner

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

Cortex: 564.23 ms. Grep: 33.28 ms. Candidate reduction: 5x.

redux / TypeScriptResolve redux.createStore owner

createStore resolves to src/createStore.ts:96.

Cortex: 2882.81 ms. Grep: 47.69 ms. Candidate reduction: 333x.

retrofit / JavaResolve Retrofit owner

Retrofit resolves to retrofit/src/main/java/retrofit2/Retrofit.java:65.

Cortex: 1499.76 ms. Grep: 72.55 ms. Candidate reduction: 1691x.

kotlinx.coroutines / KotlinResolve CoroutineScope owner

CoroutineScope resolves to .

Cortex: 76.6 ms. Grep: 80.08 ms. Candidate reduction: 0x.

Newtonsoft.Json / C#Resolve JsonConvert owner

JsonConvert resolves to Src/Newtonsoft.Json/JsonConvert.cs:53.

Cortex: 2114.09 ms. Grep: 66.65 ms. Candidate reduction: 2061x.

curl / CResolve curl_easy_init owner

curl_easy_init resolves to .

Cortex: 353.41 ms. Grep: 192.7 ms. Candidate reduction: 0x.

fmt / C++Resolve fmt::format owner

format resolves to .

Cortex: 97.12 ms. Grep: 24.14 ms. Candidate reduction: 0x.

swift-argument-parser / SwiftResolve ArgumentParser owner

ArgumentParser resolves to .

Cortex: 216.7 ms. Grep: 27.01 ms. Candidate reduction: 0x.

AFNetworking / Objective-CResolve AFHTTPSessionManager owner

AFHTTPSessionManager resolves to .

Cortex: 57.05 ms. Grep: 24.28 ms. Candidate reduction: 0x.

jekyll / RubyResolve Jekyll owner

Jekyll resolves to .

Cortex: 67.95 ms. Grep: 53.06 ms. Candidate reduction: 0x.

composer / PHPResolve Composer owner

Composer resolves to src/Composer/Composer.php:27.

Cortex: 242.21 ms. Grep: 85.15 ms. Candidate reduction: 6428x.

twitter-util / ScalaResolve Future owner

Future resolves to util-core/src/main/scala/com/twitter/util/Future.scala:1503.

Cortex: 1385.72 ms. Grep: 82.77 ms. Candidate reduction: 2745x.

phoenix / ElixirResolve Phoenix.Endpoint owner

Endpoint resolves to .

Cortex: 213.85 ms. Grep: 36.75 ms. Candidate reduction: 0x.

cowboy / ErlangResolve cowboy_req owner

cowboy_req resolves to .

Cortex: 54.01 ms. Grep: 37.61 ms. Candidate reduction: 0x.

http / DartResolve Client owner

Client resolves to pkgs/http/lib/src/client.dart:36.

Cortex: 290.86 ms. Grep: 48.62 ms. Candidate reduction: 250x.

luarocks / LuaResolve Rockspec owner

Rockspec resolves to .

Cortex: 195.73 ms. Grep: 46.61 ms. Candidate reduction: 0x.

dplyr / RResolve filter owner

filter resolves to .

Cortex: 159.58 ms. Grep: 33.28 ms. Candidate reduction: 0x.

DataFrames.jl / JuliaResolve DataFrame owner

DataFrame resolves to .

Cortex: 53.44 ms. Grep: 23.92 ms. Candidate reduction: 0x.

aeson / HaskellResolve ToJSON owner

ToJSON resolves to .

Cortex: 53.55 ms. Grep: 72.95 ms. Candidate reduction: 0x.

base / OCamlResolve Base owner

Base resolves to .

Cortex: 62.62 ms. Grep: 37.87 ms. Candidate reduction: 0x.

clojure / ClojureResolve clojure.core owner

defn resolves to .

Cortex: 715.67 ms. Grep: 28.06 ms. Candidate reduction: 0x.

nvm / BashResolve nvm owner

nvm resolves to nvm.sh:3123.

Cortex: 55.24 ms. Grep: 31.91 ms. Candidate reduction: 1845x.