gograph
Give Go coding agents a compiler-aware map for safer refactors.
gograph builds a local structural graph of your Go repository, with optional
type-checked CHA/SSA enrichment. Its CLI and MCP workflows help coding agents
trace callers and interface implementations, plan change impact, and enforce
architecture without embeddings or a hosted code index.
Explore the interactive no-install demo · Review the reproducible benchmark
Companion projects: Scrinium provides repository-owned, evidence-backed knowledge for coding agents, while Rulefloor protects repository-local invariants by binding them to concrete tests and detecting drift. They are independent, optional tools: Scrinium can keep Gograph structural observations and Rulefloor validation results as separate evidence without treating either as proof of unrelated behavior or global project correctness.

Static analysis; no target-code execution. Default indexing parses Go source locally and does not call application services. Descendant links and special files for extensions recognized by
go/buildare excluded, graph-directed source reads are confined to regular files beneath the analyzed repository, and linked/non-regular Go tool metadata (go.mod,go.sum,go.work,go.work.sum, andvendor/modules.txt) is rejected before toolchain invocation; an explicitly symlinked repository root remains supported. Applicablego.work usemembers must stay beneath the workspace directory, and each member directory,go.mod, and optionalgo.sumis validated beforecmd/gostarts. Gograph also reads project metadata such as.gitignore, graph/config JSON, and Git state. Indexing asks the installed Go toolchain for the effective build/module context; precise mode additionally performs package type loading, anddocrunsgo doc. Those operations follow your configured module/cache/network policy. Before repository package loading orgo doc, applicable local module/workspace source trees are preflighted for links thatcmd/gomay inspect;.gitand.gographsubtrees are excluded. Session telemetry is local under.gograph/sessions/; nothing is sent to gograph services.
Quick Start
# Install
brew install --cask ozgurcd/tap/gograph
# or: go install github.com/ozgurcd/gograph/cmd/gograph@latest
# Confirm which installation will run and detect PATH shadowing
gograph doctor --json
# Build a type-enriched precise graph, then verify it
gograph build . --precise
gograph stats
# Start with repository-wide results that require no guessed symbol
gograph summary
gograph hotspot --top 5
gograph flow --no-testsHomebrew and go install install the normal gograph CLI. MCP clients that
support MCP Bundles can instead discover the local stdio server in the
official MCP Registry as
io.github.ozgurcd/gograph. Registry/MCPB installation is a separate
distribution path; it does not install the Homebrew cask or configure the
Claude Code marketplace plugin. The Registry is currently in preview. See
Official MCP Registry and MCPB installation for client
support, target selection, and current limitations.
Choose a real function or method shown by summary, hotspot, or
gograph complexity, then substitute its name below:
gograph context "YourSymbol" # source + callers + callees + tests
# For compilable repositories, enrich the graph before a major refactor
gograph build . --precise
gograph plan "YourSymbol"Build artifacts are written under the target .gograph/ directory. gograph
adds .gograph/ to the enclosing Git repository root .gitignore when
available, falls back to the build target .gitignore outside Git, and exits
without replacing artifacts if no Go files are found or no source file parses
successfully. The update accepts only an absent or regular .gitignore; a
repository-provided link is refused and its target is not modified. Go build
constraints, cmd/go package-directory rules, generated
sources, module-mode ignore directives, and Git ignores use the same scanner
policy for building, freshness checks, and change detection. Source-file
symlinks and other non-regular .go entries are reported and excluded;
linked/non-regular go.mod, go.sum, go.work, go.work.sum, and
vendor/modules.txt entries are rejected before gograph or the Go toolchain
reads them. Applicable go.work use members must remain beneath the workspace
directory; their directories, go.mod, and optional go.sum are validated
before cmd/go starts.
.gograph itself must be a real directory, and graph.json must be a regular
repository-confined file. Graphs with a missing or unsupported confinement
policy marker must be rebuilt with the current binary before graph-backed
commands use them. Older binaries do not enforce this boundary and should not
be used to analyze untrusted repositories.
Each indexed source file stores a SHA-256 content digest. Rebuilds reparse all
selected files in a changed package together and reuse parser records for
unchanged packages; stats reports reused_files and rebuilt_packages.
Precise builds reuse that AST work but still recompute repository-wide
type/CHA/SSA enrichment so cross-package dispatch remains correct.
Machine-readable structural validation
External consumers can validate one closed structural predicate without parsing human CLI output:
gograph version --json
gograph validate --repo /work/project --binding-json '{"schema_version":"gograph.binding.v1","predicate":"symbol_exists","subject":{"language":"go","kind":"symbol","id":"example.com/project/internal/auth::Authorize"},"required_precision":"ast"}' --jsonThe version and result schemas are gograph.version.v1 and
gograph.validation.v1; bindings use gograph.binding.v1. V1 supports only
symbol_exists, package_imports, call_edge_exists, and type_implements.
Validation is read-only and never builds or refreshes the graph. Exit 0 means
pass, exit 1 means a conclusively evaluated fail, and exit 2 means
cannot_evaluate or an invalid request.
Negative results require predicate-specific completeness: symbol and direct
import absence need a current complete AST graph; implementation absence needs
a current precise-complete graph; call absence additionally requires complete
resolution of the subject's relevant call edges. Missing, stale, partial,
ambiguous, or unresolved evidence degrades to cannot_evaluate; a
precise_fallback graph may support AST presence but never evaluated absence.
The result binds the exact graph bytes, selected source/build-context manifest,
and canonical binding with SHA-256 fingerprints.
Gograph validates selected-build-context Go structure. It does not prove
runtime behavior or business correctness. CHA edges are possible static targets,
not runtime dispatch certainty. V1 excludes reachability, unstable or external
symbol identities, unnamed types, and non-Go languages. See the exact
machine-validation contract.
Applicable local module/workspace source roots must remain beneath the explicit
--repo root; v1 returns cannot_evaluate instead of widening that authority.
MCP refreshes stay in memory by default. To publish each successful refresh for CLI consumers and later server processes, start the server explicitly with:
gograph mcp . --persist-refreshThis opt-in mode writes or overwrites .gograph/graph.json and the nine
Markdown reports after a confirmed-fresh refresh. It does not modify
.gitignore, so ignore .gograph/ yourself before enabling it when needed.
The directory holds only the latest published state; it is not a per-branch
cache. If no usable graph exists (including an unsafe or unsupported artifact),
the startup auto-build is published before serving;
a failure there prevents startup. A later tool-triggered publication failure
makes that tool return an error, and the server retries the pending publication
on another refresh-capable call without rebuilding the already-fresh in-memory
graph. Writers coordinate through a local .gograph/.artifacts.lock file; an
existing lock entry must be regular rather than a link or special file.
Reports are replaced first and graph.json is replaced last as the publication
commit marker; the complete ten-file bundle is not a single atomic filesystem
transaction. Same-directory replacement is atomic on Unix-like systems; Go
does not guarantee atomic rename semantics on non-Unix platforms. The lock
file remains as operational coordination state in addition to the ten outputs.
Why gograph?
Illustrative point-in-time output comparison from an earlier gograph revision (counts vary as the repository evolves; these commands return different kinds of evidence):
| Task | grep -rn | gograph | Observed output difference |
|---|---|---|---|
Find callers of loadGraph | 158 matching lines (comments, docs, vars) | 56 AST-derived call-site rows | ~65% fewer rows in that run |
| Locate symbol definitions | 842 lines matching "Symbol" | 83 true type/method declarations | ~90% noise eliminated |
| Read one function body | cat displays 180+ lines of the whole file | source extracts the 12-line function | ~93% fewer source lines in that run |
| Gather common symbol context | Separate node, source, caller, callee, and test queries | context bundles those fields | Five evidence types in one response |
Key Features
Machine and Agent Workflows — callers, callees, reverse test coverage, stable symbol identity, impact, context, plan, review, flow, errorflow, structural validation, orphans, hotspot, coupling, and more. The MCP server registers 67 endpoints including four session lifecycle tools. Full command reference →
Federated Workspaces — model multiple checked-out repositories through independently fingerprinted repository graphs plus a small deterministic cross-repository overlay. Resolution scopes support alternative fleets such as OSS/CE without merging repository ownership. P0 resolves Go modules, ordinary cross-repository Go calls, and first-class HTTP contracts for workspace-wide status, query, path, and impact analysis. The four read-only workspace MCP tools return the same native result values as CLI --json; member refresh and overlay publication remain explicit CLI mutations. Workspace guide →
Native MCP Server — all 63 repository query, analysis, and workflow capabilities have project-MCP equivalents for Claude, Cursor, Copilot, and other MCP clients; four additional endpoints cover session lifecycle (67 project tools total). A separate workspace server provides status, query, path, and impact with the same native results as the corresponding CLI operations. The normal mapping is CLI <command> to MCP gograph_<command>; contract, boundaries --create, and session actions use the documented special mappings. CLI-only process/host/artifact operations are build, validate, doctor, gate, snapshot, plugin/hook installation, project/workspace MCP startup, workspace build
…