A local code analysis tool that parses codebases with Tree-sitter and builds a knowledge graph.
The ccg MCP server registered in .mcp.json provides 17 tools:
parse_project,build_or_update_graph,run_postprocessget_node,search,query_graph,list_graph_stats,list_namespaces,get_minimal_contextget_impact_radius,trace_flowdetect_changes,get_affected_flows,list_flowsget_annotationget_doc_content,search_docs
ccg serve is the local stdio MCP entry point. Self-hosted HTTP mode is provided by
the separate ccg-server binary, which serves /mcp, /health, /ready, /status,
and /webhook.
Webhooks are enabled in ccg-server when allowed repositories are configured with the --allow-repo flag.
Per-repository branch filtering: --allow-repo "org/api:main,develop" (glob patterns; defaults to main/master when omitted).
Compatible with GitHub (X-Hub-Signature-256) and Gitea (X-Gitea-Signature, X-Gitea-Event).
Push event pipeline: receive push event -> automatic clone/pull -> graph build -> DB persistence.
Graceful shutdown: SIGINT/SIGTERM propagates context cancellation to in-progress clone/build work.
| Skill | Description |
|---|---|
/ccg |
Core build and search: parsing, graph build, query, search |
/ccg-analyze |
Code analysis: impact radius, flow tracing, and change risk |
/ccg-annotate |
Annotation system: AI annotation workflow and tag reference |
/ccg-docs |
Documentation: generation, DB-backed discovery, and lint |
/ccg-namespace |
Namespace isolation for multi-project graph data |
Skill files are located under skills/ and are written so coding agents such as Codex and Claude Code
can use them as slash-command style workflows.
Main commands:
ccg build [dir]- build the code graph (supports--exclude,--no-recursive)ccg serve- start the local MCP server over stdioccg-server- start the self-hosted HTTP MCP/webhook serverccg docs [--out dir]- generate Markdown documentation and the Wiki compatibility indexccg search <query>- full-text search (includes annotations)ccg lint [--strict]- check documentation quality/ccg-annotate annotate [file|dir]- AI annotation generation workflow
Use .ccg.yaml to manage project defaults such as exclude patterns and DB settings.
When looking for code locations, related implementations, call relationships, impact radius, or architecture context, use ccg MCP tools and Agent Skills first.
- For natural-language code understanding and module exploration, prefer the
/ccg-docsskill: usesearch_docsto find relevant docs, thenget_doc_contentto read one. - For exact symbol locations, call relationships, and graph metadata, use ccg MCP
query_graph,get_node,get_minimal_context, or the/ccgskill. - For annotation/keyword-based candidate search, use ccg MCP
searchorccg searchas a supplement. - For impact radius, flows, and change-risk analysis, prefer the
/ccg-analyzeskill and related MCP tools (get_impact_radius,trace_flow,detect_changes,get_affected_flows). - For simple string checks, file existence checks, or cases where the ccg index is missing or stale, use
rgas a supplement. If needed, refresh the graph withccg build .orccg update ..
See the guide/ directory for detailed documentation:
- CLI Reference - all commands, flags, and config files
- MCP Tools - 17 MCP tools, Agent Skills, AI-Driven Annotation
- Annotations - annotation tags, examples, and search
- Webhook - webhook sync, branch filtering, HMAC, graceful shutdown
- Docker - Docker builds, MCP server, PostgreSQL deployment
- Development - development guide, integration tests, project structure
- Runtime Layout -
ccg,ccg-server, and sharedccg-coreownership boundaries - Architecture - data flow, components, DB schema
- TDD: Red -> Green -> Refactor
- Tidy First: separate structural changes from behavioral changes
- Use GORM queries only (no raw SQL)
- Tests:
CGO_ENABLED=1 go test -tags "fts5" ./... -count=1 - Integration test:
./scripts/integration-test.sh(full Gitea + PostgreSQL + ccg Docker pipeline)
When creating new code or making meaningful behavior changes to existing code, add CCG annotations as well.
Priority:
- Use
// @index ...when the package/file role should be discoverable. - Use
// @intent ...for new public types/functions/methods, MCP handlers, CLI commands, and service methods. - Use
// @param,// @returnwhen input/output contracts matter. - Use
// @requires,// @ensureswhen preconditions or guarantees matter. - Use
// @sideEffectwhen the code mutates external state such as files, DB, network, cache, logs, or processes. - Use
// @mutateswhen the receiver or argument values are modified. - Use
// @domainRulefor business rules, operational policies, and false-positive/false-negative criteria. - Use
// @seewhen related handlers, services, or models exist.
Annotations must match the code behavior and should not exaggerate the explanation. Do not force annotations onto simple getters/setters or obvious one-line helpers.
After completing code generation or code modifications, run the following by default:
ccg build .
ccg docs --out docs
ccg lintIf the change modifies behavior or touches DB/search/parser/MCP handlers, also run Go tests:
CGO_ENABLED=1 go test -tags "fts5" ./... -count=1For documentation-only changes, prioritize regenerating docs with ccg docs and running ccg lint.
Code tests may be skipped depending on the change scope.
- When writing, modifying, or reviewing code, apply
coding-quality-guardrailsas the quality gate. - When debugging bugs, regressions, flaky behavior, or failing tests, use
diagnosing-bugsbefore changing behavior. - Before implementing new logic with branching, side effects, resource lifecycles, or ordering constraints, use
flow-designand keep the design note in the task workspace. - When designing module boundaries, refactoring, or shaping interfaces, use
codebase-design. - When aligning terminology or modeling the domain, use
domain-modeling. - When a plan is fuzzy, high-impact, or lacks testable acceptance criteria, use
planning-grillto sharpen scope, acceptance, and failure modes before decomposing it. - For multi-step or multi-agent work, use
decompose-and-dispatchto split the work into bounded units. Useexecute-dispatch-unitonly for a clearly assigned unit with scope, dependencies, and verification. - When preparing context for human or AI code review, use
ready-code-review; do not use it to perform the review itself. - To record a session, distill completed work into a replayable recipe, or replay a
recipe.yaml, usesession-recipe.
agent-team bundles its own skills; restrict them as follows so methodology stays single-sourced:
- Use only agent-team's CLI operation skills (the
agent-team-*prefix: run/task/message/inbox/sync/event commands), and loadagent-team-sharedbefore any command-specific one — it defines the state directory, global flags, and error handling they all assume. Never use itsrecipe-*andpersona-*skills — the skills routed above own all methodology, even where an excluded skill looks like a closer match (worker checkpoints →execute-dispatch-unit's Ledger Checkpoints; plan sharpening /recipe-agent-team-planning-grill→planning-grill; decomposition →decompose-and-dispatch; architecture →codebase-design; terminology →domain-modeling). - When executing an assigned unit, follow
execute-dispatch-unitfor scope, verification, and reporting; its Ledger Checkpoints section defines whichagent-team-*calls to make. - When planning,
decompose-and-dispatchowns decomposition and executor mapping, and its Durable Ledger section defines the run/task registration calls. - Do not route by the word "recipe": here it means a replayable session recipe (
session-recipe,recipe.yaml); agent-team'srecipe-*skills are excluded above.