Skip to Content
Command ReferenceOverview

CLI command reference

This section documents every command registered by the codespine CLI (npx codespine ). There is one page per command; each explains the command’s arguments, options, underlying graph query, output format, and caveats in depth.

Invocation

The published binary is codespine. Every example in these documents runs it with npx (no global install required):

npx codespine <command> [arguments] [options]

The pipeline

The commands fall into groups that run roughly in order — each stage produces an artifact the next stage consumes:

enrich and cluster annotate the database in place.

Build the graph

CommandPurpose
extractParse a TypeScript project into a JSONL knowledge graph.
loadImport the JSONL graph into an embedded Kùzu database.

Enrich the graph

CommandPurpose
enrichIngest a V8 CPU profile and attach measured runtime metrics (metadata.runtime) onto nodes.
clusterDetect code communities with the Leiden algorithm and attach the module index (metadata.community) onto nodes.

Query the graph

CommandPurpose
findResolve a name (substring) to node ids. The entry point for every other query.
who-callsDirect callers of a symbol.
callsWhat a symbol calls directly.
referencesEverything that references a symbol or type (calls, type usage, heritage, instantiation, reads).
neighborsOne-hop neighbourhood of a node, in and out, all edge kinds.
blast-radiusEvery symbol transitively impacted by changing a node.
dead-exportsExported symbols with no inbound references.
hotspotsRank nodes by optimization leverage — runtime self-time, fan-in, call-count, or blast radius.
costPropagate self cost into inclusive cost and rank nodes by share of total; or break one node’s cost into callee/caller attribution.

Verify & measure an edit

CommandPurpose
verifyRun the project’s typecheck + test scripts as one keep/revert gate for an edit; degrades to type-check-only, reported honestly, when there is no test script.
benchmarkMeasure a target node’s runtime metric (profile → enrich → cost) over N runs and report the median + spread, with an advisory baseline→after delta.

Use the graph

CommandPurpose
webviewServe the graph in an interactive web visualisation.
reportWrite a CODEBASE_BRIEF — one snapshot of structure, impact, runtime, and boundary (markdown / JSON / PDF).
installInstall the agent’s slash commands and codespine-query skill into a project’s .claude/.

The autonomous optimization agent is not a CLI command. It is the /codespine-optimize Claude Code  slash command (see Agent), which calls the query commands above to find a verified-safe edit and apply it.

Common conventions

  • Node ids always come from a query. Run find (add --json) or read an id out of another query’s output. Ids encode the declaration line (kind:relPath#name@line) and shift whenever the code moves, so never write them by hand and never reuse them across extractions.
  • -o, --output-folder <dir> defaults to ./.codespine on every command (the database is read from <dir>/graph.kuzu), matching load’s default output. Override it to query a database elsewhere.
  • --json is available on every query command and emits the exact machine-readable shape the optimization agent consumes.

See also: Getting Started, the Static Analysis guide (these commands organised by the analysis question they answer), and the Concepts.

Last updated on