This protocol is for AI agents and automation using an existing codegraph
output as a planning aid.
The graph is a first-orientation tool. It should narrow the search space and surface relationships before source inspection begins. It does not replace reading the source when a change must be made.
- Run
codegraph status <output> --json. - If freshness is not
current, refresh the graph or stop and report staleness. - Run
codegraph doctor <output> --json. - If doctor status is not
passed, treat the graph as unsafe for planning. - Run
codegraph overview <output> --limit 20. - Choose entrypoints from
agent_entrypoints,architecture, orimportant_files. - When a narrower machine-readable slice is useful, run
codegraph query <output> --node <entrypoint>with focused traversal. - Read source files after the graph has narrowed the likely area.
PROVEN: direct extractor evidence. Safe as planning evidence when fresh.DERIVED: deterministic resolution based on proven facts. Safe for planning, but verify before edits.INFERRED: architecture or heuristic enrichment. Use for orientation and hypothesis generation.UNRESOLVED: attempted extraction with incomplete resolution. Treat as a warning and inspect source.
Never present stale graph data as current.
codegraph query is a graph subgraph inspector, not a search engine. Use it
after overview has identified a concrete node, file, feature, layer, role,
domain, symbol, concept, claim, or external module to inspect.
Default behavior is intentionally compact:
- outgoing traversal
- no containment traversal
- all confidence classes included
Use broader traversal deliberately:
codegraph query graph-out --node layer:screens --direction in --depth 1
codegraph query graph-out --node feature:Billing --direction in --depth 2
codegraph query graph-out --node src/app.py --confidence PROVEN --confidence DERIVEDAvoid --include-containment unless the task is explicitly about directory
shape. Containment can expand quickly on large targets.
passed:
- Use the graph normally.
- Still verify source before editing.
partial:
- Use the graph for orientation.
- Surface the coverage warning in your plan or report.
- Prefer
PROVENandDERIVEDedges.
untrusted:
- Do not rely on the graph for planning.
- Report the failing doctor or quality gates.
- Fall back to direct investigation.
- Start with the changed file, symbol, feature, layer, or external module.
- Inspect incoming edges first to find dependents.
- Inspect outgoing edges to find dependencies.
- Inspect evidence on critical edges.
- Read only the files returned by the focused subgraph before broad search.
Example:
codegraph query graph-out --node imported-symbol:legacy-sdk#OldClient --direction in --depth 1- Inspect the old API or symbol with a focused subgraph.
- Rank returned files by feature and layer from
overview. - Migrate one feature/layer slice at a time.
- Refresh the graph after the migration.
- Inspect the old API again to confirm no known usages remain.
When reporting graph-backed findings to a human, include:
- freshness
- doctor status
- quality status
- focused graph command used
- confidence class of important edges
- any partial/untrusted warnings