-
-
Notifications
You must be signed in to change notification settings - Fork 0
Assistant Integration
codegraph install wires the CodeGraph skill into a host AI assistant so it
queries the graph before falling back to broad file exploration. It writes a
per-platform skill file (where the platform has one), injects an always-on
instructions section into the platform's instructions file, and (for Claude
Code) registers PreToolUse hooks in .claude/settings.json. All writes are
idempotent and target the current working directory.
The companion codegraph uninstall reverses it, and codegraph skill check/bless guard the generated artifacts against drift (a dev/CI tool).
codegraph install [platform]
platform defaults to claude. Files are written under the current directory
(the repo root). The command prints each path it wrote.
codegraph install
codegraph install agents
codegraph install copilot
| Argument(s) | Skill file | Always-on instructions file | settings.json hooks |
|---|---|---|---|
claude |
.claude/skills/codegraph/SKILL.md |
CLAUDE.md |
yes |
agents, agent, codex, opencode
|
none | AGENTS.md |
no |
gemini |
none | GEMINI.md |
no |
cursor |
none | .cursorrules |
no |
copilot, github-copilot
|
none | .github/copilot-instructions.md |
no |
kilo, kilocode
|
none | .kilocode/rules/codegraph.md |
no |
Platform names are case-insensitive. codex and opencode both map onto the
agents platform because both read AGENTS.md. Only Claude gets a dedicated
SKILL.md; the other platforms consume the always-on instructions file directly.
Any needed parent directories (for example .github/, .kilocode/rules/) are
created.
-
Skill file (Claude only):
.claude/skills/codegraph/SKILL.md. It carries frontmatter (name: codegraph) and instructs the assistant to query the graph before grepping or broad reading, listing the build/query CLI commands and the MCP tools (see MCP-Server). -
Always-on section: a marked block injected into the platform's instructions file:
<!-- codegraph:start --> ## CodeGraph This repo has a CodeGraph knowledge graph (`codegraph-out/graph.json`). Query it before broad file exploration: `codegraph query "<question>"`, `codegraph affected <node>`, or run `codegraph serve` for the MCP tools. Rebuild with `codegraph extract .` / `codegraph update <files>`. <!-- codegraph:end -->The block is delimited by
<!-- codegraph:start -->and<!-- codegraph:end -->. On reinstall it is replaced in place (never duplicated), and any prose around it is preserved. A new instructions file is created if none exists. -
PreToolUse hooks (Claude only): two entries merged into
.claude/settings.jsonunderhooks.PreToolUse(see below).
Install can be run repeatedly without piling up duplicates:
- The always-on block is matched by its marker and replaced in place. A truncated or hand-edited block (a dangling start marker) is repaired into a single clean block.
- The settings hooks are matched by matcher plus the literal
codegraphin the body; any prior CodeGraph hooks are removed before the current pair is appended, so a reinstall keeps exactly two. Foreign hooks and unrelated top-level settings keys are preserved. A corruptsettings.jsonis treated as empty and rewritten.
For Claude, two PreToolUse hooks are written into .claude/settings.json. They
nudge, never block (they fail open, so a legitimate tool call always
proceeds), and they only fire when codegraph-out/graph.json exists. Each hook's
shell snippet parses the tool input with python3.
-
Bash matcher: fires when a shell command looks like a search
(
grep,rg,ripgrep,find,fd,ack,ag). It injects additional context telling the assistant to runcodegraph query "<question>"before grepping raw files. -
Read|Glob matcher: fires when a
Read/Globtargets a source or doc file (by extension, for example.py .js .ts .go .rs .java .mdand many others) outsidecodegraph-out/. It injects context telling the assistant to runcodegraph query/codegraph explain/codegraph pathfirst, and to carry the same rule into subagent prompts.
When a hook fires, Claude Code receives the additionalContext text as a
PreToolUse hook output, steering the assistant toward the graph before it reads
or greps. Because the hook is gated on codegraph-out/graph.json, nothing fires
until a graph has been built (see Quickstart and
Extraction).
codegraph uninstall [platform]
codegraph uninstall --all
platform defaults to claude. Uninstall removes the dedicated skill file (if
any), tidies now-empty skill directories, and strips the always-on marker block
from the instructions file. If nothing else remains in that file, the file is
removed; otherwise the surrounding prose and its blank-line spacing are
preserved. For Claude it also removes exactly the CodeGraph PreToolUse hooks,
leaving foreign hooks intact. --all uninstalls from every supported platform.
The skill artifacts are generated by pure slot substitution over an embedded
template, with a committed golden snapshot tree (expected/) next to the
skillgen crate source. These commands are dev/CI tools run from a repo checkout:
codegraph skill check
codegraph skill bless
-
codegraph skill checkre-renders every artifact (one per platform plus the shared always-on section) and byte-diffs it against the committed snapshots (ignoring line-ending style). It printsskill artifacts are in sync with expected/.when clean, or lists each drift and exits non-zero. Acargo testrun also fails on drift. -
codegraph skill blessrewrites the committed snapshot tree from the current render, printing the paths written. Run it after an intentional template change.
Note: because the snapshot tree is resolved relative to the crate source, these commands are meaningful only from a repo checkout; an installed binary reports the snapshots missing by design.
-
MCP-Server -- run
codegraph serveand the tools the skill points an assistant at. - Quickstart -- build a graph first so the hooks activate.
- Configuration -- environment variables and settings.
- Commands -- the full CLI reference.
Getting started
Concepts
Using CodeGraph
- Commands
- Extraction
- Querying
- Cross-Language Edges
- Analysis and Reports
- Output Formats
- Visualizations
Integrations
Scaling
Reference