Build or incrementally update the persistent code index (codegraph, .codegraph/ in the project root) for the current repository.
Core Rules
- The tool is the
codegraphCLI (npm@colbymchenry/codegraph). Checkcodegraph --helponce; a missing subcommand -> skip it, never invent flags. - Missing CLI -> do not install here. Report
Graph: unavailableand let/safe-codehandle the one-time install question (see the safe-code skill'sreferences/graph-integration.md). - Writes only
<project-root>/.codegraph/(self-gitignored). Never runcodegraph installunless the user answered yes to safe-code's one-time install question, and then only--target <this agent> --location global --yes(never--target all); neveruninstall. Otherwise print the command (safe-codereferences/graph-integration.md). - Telemetry: on first use in a session, print once: "codegraph sends anonymous usage stats; turn off with
codegraph telemetry offorDO_NOT_TRACK=1." Never set it for the user. - If the index cannot be built, do not block the parent workflow. Report it and continue with manual repo inspection.
Workflow
- No
.codegraph/->codegraph init -yfrom the project root (full build) — only when invoked to build (/safe-code --codegraph, or Step 3f with graph evidence in scope); an existing index is synced, never re-initialised. .codegraph/exists ->codegraph sync(incremental).fullargument, branch switch, or obviously wrong results ->codegraph index(full rebuild).- "Index is locked" from a crashed run ->
codegraph unlock, retry once. - Verify with
codegraph status: files, nodes, edges, languages, "Index is up to date". - Report build status and any language coverage gaps.
Output
Graph: <ready | stale | unavailable | partial> (safe-code Step 8 vocabulary)
Files: <count>
Nodes: <count>
Edges: <count>
Languages: <list>
Notes: <coverage gaps, or fallback used: manual>