oxagenDocs
CLI

Code graph from the CLI

Build a repository's code graph on your machine, serve it to your agents over MCP, and upload CI reports to the Oxagen code graph.

The code graph is a map of your code. Each function, table, test, doc, environment variable, and deploy step is a node, and each link between two of them is an edge. Agents ask the graph questions through MCP tools instead of opening files one at a time.

The code graph commands sit under oxagen graph and do two jobs:

  • init, status, rebuild, and stop build and manage graphs of your repositories on this machine.
  • upload sends the data only CI has, such as coverage and test reports, to the Oxagen code graph.

Use oxagen graph in scripts and CI jobs. The oxagen codegraph command has been removed.

Commands

CommandWhat it doesWhat it calls
oxagen graph init [path]Gives each agent on the machine the oxagen MCP entry, then builds the code graph of the working tree at path.The Oxagen daemon on this machine, which asks Oxagen for the workspace's embedding key (get_code_graph_embedding_key) and the base document (get_code_graph_base). While the workspace's embeddings are off, init also asks Oxagen for the embedding estimate (get_code_graph_embedding_estimate).
oxagen graph statusLists every code graph built on this machine.The Oxagen daemon on this machine.
oxagen graph rebuild [path]Builds the working tree's code graph again, even when it has not changed.The Oxagen daemon on this machine, which asks Oxagen for the workspace's embedding key (get_code_graph_embedding_key) and the base document (get_code_graph_base). rebuild writes no MCP entries and asks for no embedding estimate.
oxagen graph stopStops the local code graph server.The Oxagen daemon on this machine.
oxagen graph uploadUploads CI reports for the commit a pipeline ran on.POST https://api.oxagen.sh/codegraph/upload, signed in with the CI provider's token.

Local graph

The CLI builds the local graph on your machine, from whatever the working tree holds, and keeps it on that machine. Nothing it builds is uploaded. The machine asks Oxagen for two things: the workspace's embedding key, and the base facts described below. The oxagen MCP entry then answers code graph questions from the local graph.

The local graph reads the working tree as it stands when the build runs: committed files, staged and unstaged changes, and untracked files that .gitignore does not exclude.

A copy's pin is the HEAD commit plus a SHA-256 hash of the paths and contents of every file that differs from it, written 9f31c2e+d41c07. A hash is a short code made from the content, and any change gives a different code. A clean tree's pin is the commit alone, so it matches the cloud copy of that commit.

The local graph runs the same build steps as the cloud, including git history: the files and functions that change together, who changed them, and the commits that did. A file you edited keeps the history of its last commit.

Daemon and server

The Oxagen daemon is the collector service that oxagen agent enroll installs. init, status, rebuild, and stop ask it first, and it runs the one local code graph server. When no daemon answers, init, status, and rebuild start their own server and stop it when they end. A graph built that way stays on disk, and the daemon serves it once it starts.

The server needs the codegraph program. An install from npm, Homebrew, or Scoop downloads it to ~/.oxagen/bin the first time a build needs it, and an earlier Oxagen desktop app ships it beside oxagen. The first build also fetches the grammar pack, the language parsers the build uses.

Local graphs live in ~/.oxagen/codegraph. Set OXAGEN_CODEGRAPH_ROOT to keep them somewhere else.

The server gets a quarter of the machine's memory for its builds, at least 2048 MiB and at most 8192 MiB. A machine with 16 GB gives it 4096 MiB. Set OXAGEN_CODEGRAPH_MEMORY_MB to a whole number of at least 256 to choose the limit yourself. A build that needs more than the limit stops and says so.

Builds at session start

When an agent session starts in a working tree, the daemon checks the tree's local graph in the background, and the session does not wait. It starts a build when the tree's graph was built at another commit than HEAD, or when the tree is a new git worktree of a repository this machine has built. Each working tree of a repository has its own graph, and the server keeps the graphs of a repository's three newest trees. A fourth tree gets no build at session start, so it never drops another tree's graph, and its reads go to the cloud copy. A tree is asked for once per commit. A tree whose last build failed gets no build at session start, and neither does a tree whose graph has not changed since the last build a session start asked for, such as one the system stopped for memory. So a build that fails is not repeated all day. Run oxagen graph rebuild to try it again. The daemon keeps those requests in session-start.json in the graph folder, so a restart keeps them.

A repository this machine has never built gets no build at session start. Set OXAGEN_CODEGRAPH_BUILD_ON_START to always to build every git tree with an origin remote that a session starts in, or to off to stop these builds.

A build at session start embeds new functions like any other build. On Oxagen's embedding provider those embeddings are billed to the workspace. A card the machine embedded before is reused, so a build after a few commits pays for the functions those commits changed.

Embeddings

Embeddings let search_code_graph match a plain-language question to code. The server reads the workspace's embedding key from Oxagen with the machine's host key, and holds it in memory only. status reports the embedding mode:

ModeMeaning
workspaceThe build uses the workspace's embedding key.
overrideThe build uses this machine's own embedding endpoint.
noneThe build makes no embeddings. status gives the reason, such as this machine is not enrolled.

To use your own endpoint, set OXAGEN_CODEGRAPH_EMBED_URL and OXAGEN_CODEGRAPH_EMBED_KEY, and optionally OXAGEN_CODEGRAPH_EMBED_MODEL and OXAGEN_CODEGRAPH_EMBED_DIMENSIONS, in the environment of the process that runs the server. That is the daemon, or the command itself when no daemon runs.

Base facts

Some facts come only from the cloud: the database schema, the test index, the ADR index, and domain tags, briefs and behavior statements. A local graph takes them from a base document. That's the cloud copy of the newest commit on the tracked branch that HEAD contains.

  1. Oxagen builds a copy of each commit on the branch your workspace tracks for the repository, its default branch unless the workspace picks another, and writes a base document beside it. Oxagen keeps the full graph of only the newest two commits and a few others, and keeps each commit's base document for 30 days, so a branch cut a few merges back still gets one.
  2. Before each local build on an enrolled machine, the server asks Oxagen for the base document. It sends only the repository's owner/name, the IDs of HEAD's 50 newest first-parent commits, and a repository key for each remote, such as github.com/acme/platform. A key is the remote URL's host and path, with any user name or token dropped. No code or file names leave the machine.
  3. The server saves the answer as base/<commit>.json in the repository's folder under ~/.oxagen/codegraph, and deletes older ones.
  4. The build uses those facts for every file that hasn't changed since that commit. It drops them for each changed file and marks the file baseFacts: missing.

status names the base commit a build used. A machine that isn't enrolled, a checkout with no origin remote, or a repository Oxagen has no copy of builds without a base, and status says the base is missing.

Public IDs

Every node in a graph has a public ID, gn_ and 26 letters and digits, that stays the same in the cloud and on your machine. You can pass one to any call that names a node, such as find_definition with { "id": "gn_..." }. The ID is made from the repository's key, so a local graph needs the key of the repository you connected in Oxagen.

  1. Oxagen answers the base request with the connected repository that matches one of the checkout's remotes, origin first. A fork whose origin isn't connected still matches its upstream.
  2. The server writes that key to binding.json in the repository's folder.
  3. The build makes every public ID from it, so they match the cloud's.

When no remote matches a connected repository, or the machine isn't enrolled, the build makes a key from the origin remote. Its IDs are provisional, because they may never match the cloud's. status says whether a graph's IDs are bound or provisional.

oxagen graph init

bash
oxagen graph init [path] [--force] [--json]

Builds the code graph of the repository at path, the current folder by default. It needs an enrolled machine. On a machine that is not enrolled it stops and tells you to run oxagen agent enroll --all first.

First it gives each agent on the machine the oxagen MCP entry, which serves the code graph tools:

  • Claude Code already has the entry from enrollment.
  • Codex gets it in config.toml, and Cursor gets it in mcp.json, when they are set up on the machine. Enrolling Codex or Cursor writes the same entry, so init finds it there and changes nothing.
  • Stella gets it in $STELLA_HOME/mcp.toml (~/.stella/mcp.toml by default), as one marked block. Enrolling Stella writes it, and init writes it when Stella is set up on the machine. Stella 0.9.491 or newer reads that file. The entry holds no token, loads in every checkout, and changes no file in your repository.

init never edits a server you named oxagen yourself. It prints what it did for each agent, then builds the graph and waits up to 30 minutes for the build to end. A build still running after that keeps going, and status shows when it ends.

When the workspace's embeddings are off, init then prints how many cards the workspace's published code graphs hold and about how many tokens embedding them would send. It asks Turn on embeddings? [y/N] and waits for an answer. A yes tells you to turn them on with the Embeddings switch in Code graph settings, because the switch opens a steering pull request that a machine key cannot open. Any other answer leaves them off. Off a terminal, or with --json, init asks nothing and leaves embeddings off.

FlagDescription
--forceBuilds even when the tree matches the last build.
--jsonPrints the MCP entries, the build, and the status as one JSON object. While embeddings are off, the object also holds embeddingEstimate, with cards and tokens.
bash
cd ~/src/acme-api
oxagen graph init

init exits 0 when the build ended or is still running, and 1 when the machine is not enrolled or the build failed.

oxagen graph status

bash
oxagen graph status [--json]

Lists each local graph with its repository, path, build state, revision, node and edge counts, embedding mode, the base commit its cloud facts come from, and whether its public IDs are bound or provisional. It also says which process serves the graphs, how many builds are running, where the codegraph program is, and the last error.

FlagDescription
--jsonPrints the status as one JSON object.
bash
oxagen graph status --json

oxagen graph rebuild

bash
oxagen graph rebuild [path] [--json]

Builds a fresh copy of the working tree at path, the current folder by default, even when nothing changed since the last build. It reuses every cached step output whose inputs did not change. It does not write MCP entries. Like init, it waits up to 30 minutes and exits 1 when the build fails.

FlagDescription
--jsonPrints the build and the status as one JSON object.
bash
oxagen graph rebuild ~/src/acme-api

oxagen graph stop

bash
oxagen graph stop [--purge]

Stops the local code graph server. The next code graph call starts it again.

FlagDescription
--purgeAlso deletes ~/.oxagen/codegraph: every local graph, the grammar pack, and the server's token. The next build fetches the grammar pack again.
bash
oxagen graph stop --purge

MCP tools on an enrolled machine

The oxagen MCP entry runs on the machine. It lists the Oxagen tools the machine's key may call, which are reads, and adds two tools the hosted server does not have:

ToolInputsWhat it does
build_code_graphpath, force?, wait?Builds the code graph of the working tree that holds path, which must be an absolute path inside a folder the agent works in. With wait, it returns when the build ends, up to 4 minutes. A longer build answers building.
get_code_graph_statusNoneReports every code graph built on this machine and the builds that are running.

Once a tree is built, the entry answers these reads from the local graph, and each result carries source: local:

find_definition, find_references, find_implementations, list_neighbors, rank_symbols, get_repo_map, list_ci_jobs, get_blast_radius, check_change, list_co_changes, list_governing_decisions, get_api_docs, get_env_vars, get_infra, list_scripts, list_unit_tests, get_execution_flow, search_code_graph, trace_spec, get_domain_brief, export_openapi_draft, list_code_graph_releases, list_held_decisions, list_link_labels, get_dataflow_slice, localize_fault, and get_repair_context. The entry builds a file's def-use layer the first time get_dataflow_slice or localize_fault needs it.

localize_fault answers from the local graph when you pass a stack trace or an issue's text. A failure that CI or runtime data recorded lives in the cloud copy, so a call that names a failure goes to Oxagen.

get_repair_context answers from the local graph when you name the suspects. It reads their code from the working tree, and a file you changed since the build shows only its declaration line until you build again. A bundle for a failure goes to Oxagen, and only Oxagen fills the intended behavior section.

The entry sends every other code graph read to Oxagen, which answers from the cloud copy of the repository. These include get_code_graph_settings, list_link_reviews, list_domain_reviews, and get_intended_behavior.

The machine's key cannot write. To call a code graph tool that writes, such as review_link, propose_edge, or create_work_items, connect to the hosted server with an API key. See MCP tools for every code graph tool, its inputs, and whether it writes.

oxagen graph upload

bash
oxagen graph upload [flags]

Sends coverage, test reports, runtime profiles, schema dumps, infrastructure plans, and API specs for the commit a pipeline ran on. The command signs in with the CI provider's OpenID Connect token and nothing else. It needs no oxagen login and no enrolled machine.

GitHub Actions mints the token inside the command when the job has permissions: id-token: write. GitLab writes it into OXAGEN_CODEGRAPH_TOKEN when the job declares id_tokens. The token must be one GitHub Actions or gitlab.com minted for the audience oxagen-codegraph-upload.

Each file flag takes lines of the form source=pattern and can repeat. A flag wins over the variable it stands for.

FlagVariableSources
--coverage <source=pattern>OXAGEN_CODEGRAPH_COVERAGEcoverage.py, jacoco, istanbul, go-cover, lcov
--test-report <source=pattern>OXAGEN_CODEGRAPH_TEST_REPORTSjunit
--runtime <source=pattern>OXAGEN_CODEGRAPH_RUNTIMEotel, pprof, py-spy, async-profiler, parca, pyroscope
--schema-dump <source=pattern>OXAGEN_CODEGRAPH_SCHEMA_DUMPSpostgres, mysql, sqlite, mssql
--infra-plan <source=pattern>OXAGEN_CODEGRAPH_INFRA_PLANSterraform-plan, pulumi-preview, cdk-template, helm, kustomize
--api-spec <source=pattern>OXAGEN_CODEGRAPH_API_SPECSopenapi
FlagVariableDescription
--environment <name>OXAGEN_CODEGRAPH_ENVIRONMENTThe deployed environment a runtime profile or schema dump came from.
--api-url <url>OXAGEN_CODEGRAPH_API_URLThe Oxagen API to upload to. The default is https://api.oxagen.sh. The upload sends the CI token with the files, so the command refuses any host but oxagen.sh and its subdomains over https, or a loopback address for a development API.
--fail-on-unconnectedOXAGEN_CODEGRAPH_FAIL_ON_UNCONNECTEDFails the job when no workspace holds this repository. Off by default, so a fork or a repository that is not connected yet passes with a skip.

A pattern with a glob character matches every file under the working directory except node_modules and .git. Every pattern stays inside the working directory. The command refuses a pattern that starts with / or holds .., and it skips a file whose link leads outside the folder.

A coverage.py file is the JSON report coverage json --show-contexts writes after a pytest --cov-context=test run, so each test gets the lines it ran. A JaCoCo, Istanbul, Go, or LCOV file counts as one run of the tests in the nearest folder above it that holds tests, or of the whole repository when no folder does.

An openapi file is the OpenAPI 3 or Swagger 2 document, in JSON or YAML, that a framework such as FastAPI, NestJS, or springdoc writes at build time. Its operations reach get_api_docs, each linked to the handler that serves its route. A schema dump is the schema a database reports, such as pg_dump --schema-only, mysqldump --no-data, or sqlite3 db .schema output. A table the repository already defines keeps what the repository says about it, and a table only the database holds joins the schema graph. A file the worker cannot read is skipped, and the reason shows in the attach run.

Before it sends anything, the command drops every value Terraform marks sensitive, every Pulumi secret, and the data and stringData of every Kubernetes Secret in rendered Helm and Kustomize output. It then runs the Oxagen secret scanner over the text that is left. The server runs the same checks again and reads the repository and commit from the token.

The command exits 0 when every matched file was stored or was already held. It exits 1 when a setting is wrong, no token could be read, no file matched, or an upload failed.

Example for a GitHub Actions job:

bash
oxagen graph upload \
  --coverage "coverage.py=coverage.json" \
  --test-report "junit=reports/junit.xml"

On any other runner, pass the token yourself:

bash
OXAGEN_CODEGRAPH_TOKEN="$CI_OIDC_TOKEN" \
OXAGEN_CODEGRAPH_COVERAGE="lcov=coverage/lcov.info" \
npx @oxagen/cli graph upload

On this page