Welcome to the gograph documentation portal. gograph is a local-only Go static analysis, call-graph, blast-radius, and CI architecture-gate CLI for Go engineers, with a built-in zero-step MCP server for AI coding agents.
Documentation Map#
Install gograph, build your first AST or type-checked (--precise) call graph, and run blast-radius and targeted test queries.
- Topics: Homebrew and
go install, AST vs. --precise --strict, stats, stale, impact, tests --uncommitted.
Exhaustive manual covering every CLI command, flag, output mode (--json, --files-only, --mermaid), federated workspaces, and the CLI/MCP parity matrix.
- Topics: Indexing, call-graph traversal, interface resolution, HTTP/SQL extraction, security flow, test attribution, and CI gates.
Enforce Go package boundaries, fan-in/fan-out coupling limits, cyclomatic complexity ceilings, and exported API drift in CI pipelines.
- Topics:
gograph/boundaries.json, .gograph.yml, gograph gate, gograph api --since, gograph validate, and GitHub Actions YAML.
An honest engineering breakdown of how gograph complements gopls, golangci-lint, go-callvis, and ripgrep.
- Topics: Structural graphs vs. LSP cursor navigation vs. file-level linters vs. visual call graphs vs. text search.
Step-by-step operational playbooks for onboarding, safe refactoring, package splits, security-flow triage, and CI quality gates.
- Topics: Plan-to-review edit lifecycle, transitive test selection, coverage-gap audits, and CI baselines.
Connect gograph’s built-in stdio MCP server to Claude Code, Cursor, Codex, Copilot, Antigravity, and OpenCode.
- Topics: Zero-step in-memory refreshes,
--persist-refresh, Mermaid output, and PreToolUse hook guards.
Install a platform-specific local MCP Bundle (io.github.ozgurcd/gograph) in MCPB-capable clients.
- Topics: MCPB vs. Homebrew/
go install, supported OS/arch targets, and local data handling.
Install gograph, index a Go module, and run your first call-graph, test-selection, and architecture queries.
Requirements Go 1.27.0 or newer on PATH A local Go module (go.mod) or Go workspace (go.work) 1. Install the CLI Install with Homebrew or go install:
# Homebrew brew install --cask ozgurcd/tap/gograph # Or via Go toolchain go install github.com/ozgurcd/gograph/cmd/gograph@latest Verify the installed binary and check for PATH shadowing:
gograph version gograph doctor --json To build from source:
...
This reference documents every command available in the gograph CLI, compiled directly from the production source code.
Global Flags Global flags may appear before or after the command:
--json: Structured output for query/composed-analysis commands and workspace build, status, query, path, and impact. --files-only: Deduplicated paths for the commands listed under Output Modes; an empty result writes zero lines. --mermaid: Mermaid output for callers, callees, impact, endpoint, dependents, deps, path, and coupling. Bare gograph --mermaid is shorthand for gograph diagram. -i <message> / --intention <message>: Technical rationale recorded with CLI command telemetry. It is mandatory for analytical commands while an the caller selects an active audit session; session, MCP startup, build, installation, help, version, doctor, stale, stats, capabilities, wiki, and doc commands do not require it. --rev <ref>: Answer a graph query from the tree of a Git commit, branch or tag instead of the working tree (gograph --rev 3b37747 source internal/app/client.go, gograph callers Run --rev origin/main). The first query for a commit extracts the project with git archive into .gograph/revs/<commit>/ (a standalone repository, so the scanner applies only the commit’s own ignore rules) and builds an AST graph there; later queries reuse it. The graph uses the working graph’s recorded build tags and exclusions unless --tags or GOFLAGS -tags select others, which rebuilds it. Not accepted by build, mcp, stale or workspace, or with --uncommitted/--since. CLI only. Delete .gograph/revs to reclaim space. --no-refresh: Answer from the persisted graph even when it is stale (with the stale warning). Without it, a CLI graph query rebuilds a stale graph first: changed packages only, with the recorded precision, build tags and excluded directories, noted on stderr (or in warning under --json). GOGRAPH_NO_REFRESH=1 does the same for every call. A different build context, another caller’s active session and --rev never rebuild, nor do stale, stats, changes and the enforcement commands gate, check and boundaries (gate still fails on a stale graph). --session-id ID / GOGRAPH_SESSION=ID: Select the caller’s session returned by session create. The flag overrides the environment. Omission keeps a read-only caller outside other agents’ audits; writes still refuse when another caller owns an active session. Independent callers may create concurrently. CLI commands answer from the persisted graph. When selected files or the Go build context changed since the last build, graph-backed commands print a WARNING on stderr naming the changed files and asking for gograph build .; JSON output carries the same text in warning and reports graph_state.freshness: "stale". stale, stats and changes report freshness themselves and add no warning.
...
Linters such as golangci-lint catch local defects and style issues inside individual files, whereas architectural drift occurs across package boundaries: an HTTP handler imports a database package directly, a core struct accumulates dozens of methods, or a pull request raises cyclomatic complexity in a hot path.
gograph provides deterministic CLI gates that enforce repository-wide structure directly from the compiled call and import graph.
1. Package Boundary Enforcement (gograph boundaries) Define allowed import layers in a committed gograph/boundaries.json file so local runs and CI enforce the same architecture.
...
gograph does not replace your language server, linter, or text search tool. Each tool answers a different class of question; gograph covers repository-wide structural queries, transitive impact, and CI architecture gates.
Comparison Matrix Capability gograph gopls golangci-lint go-callvis ripgrep (rg) Primary Role Persisted call graph, blast radius & CI architecture gates Live editor LSP (autocomplete, rename, diagnostics) File/package lint rules & style checks Graphviz call-graph rendering Literal & regex text search Non-Compiling Code Yes (AST mode); --precise adds CHA/SSA Partial (requires valid workspace) No (most linters require type-checking) No (requires full SSA build) Yes Transitive Blast Radius (impact) Built-in CLI & MCP Single-hop references No Visual only No Change-Scoped Test Selection Built-in (tests --uncommitted --format go-test) No No No No CI Package Layer Boundaries Built-in (boundaries, gate, validate) No Via plugins (depguard) No No HTTP Route / SQL / Env / Flow Census Built-in No Limited (per-linter) No Regex heuristic only Machine-Readable JSON & Mermaid Native (--json, --mermaid, --files-only) LSP protocol / experimental MCP Lint reports (JSON/SARIF) DOT / SVG / PNG Line matches Built-In MCP Server 70 project + 4 workspace tools Experimental MCP No No No gograph vs gopls gopls is the official Go language server. It handles cursor-level, live compiler operations inside an editor: go-to-definition, rename refactoring, hover types, live diagnostics, and exact single-hop references.
...
To maximize efficiency, reduce latency, and guarantee safety when modifying codebases, we recommend following these standardized workflows. These steps can be programmed into AI system instructions or executed manually.
Workflow 1: Onboarding to a New Repo When opening an unfamiliar Go repository, use this workflow to get oriented in seconds:
Verify Index Status: gograph stats gograph stale If stale or missing, run gograph build .. Find High-Risk Hotspots: gograph hotspot --top 10 Identifies the most heavily referenced functions in the codebase. Map Package Coupling: gograph coupling Gives a high-level table showing package stability and dependencies. Inspect the Global API Surface: gograph skeleton Exposes every package signature with bodies stripped. Workflow 2: Safe-Edit Symbol Lifecycle Before changing the signature or behavior of any function, method, or struct, follow this cycle:
...
gograph is an agent-oriented static-analysis tool. Humans can use the CLI, while MCP clients such as Claude Code, Cursor, Copilot, Antigravity, and OpenCode can request the same structured repository evidence. Results follow the documented AST, precise-analysis, and heuristic limits; they are not runtime proof.
Text search, gopls, and gograph have different jobs For Codex, see the Codex MCP setup guide, including matching build/startup exclusions for symlinked skills directories.
rg, grep, and find are appropriate for literal text, documentation, configuration, generated content, and non-Go files. Text matching alone cannot resolve Go interface satisfaction or distinguish a call expression from a comment or string.
...
gograph is published to the official Model Context Protocol Registry under this server ID:
io.github.ozgurcd/gograph The server ID is a Registry identifier, not a web address. You can inspect its active versions in the official Registry API.
The official Registry is currently in preview. Its API, stored data, and client support may change before general availability.
Registry installation is a separate path Homebrew and go install place the normal gograph CLI on PATH. You then configure an MCP client to run gograph mcp <project-directory>. The Claude Code marketplace entry supplies workflow guidance but still needs that binary and a project registration.
...