Discoverable CodeGraph — official prompt injection + all 20 CLI commands as slash commands, for Codex / ZCode / Kimi / Claude Code.
Three things, and only these three:
- At session start, when
<cwd>/.codegraph/exists, this plugin injects the official CodeGraph prompt block (verbatim from upstreamcodegraph/src/installer/instructions-template.ts) into:- The current session, via
SessionStart.additionalContextJSON output. <cwd>/.claude/CLAUDE.mdif it exists; else<cwd>/AGENTS.md. Uses atomic, marker-fenced section replacement — byte-equal content is a no-op, so this is safe to run alongsidecodegraph install.
- The current session, via
- Exposes all 20 codegraph CLI commands as slash commands in two formats: JSON (
commands/*.json, declared inkimi.plugin.json) and Markdown (kimi-commands/*.md), including the four hidden-but-useful maintenance commands (daemon,unlock,version,telemetry). - Registers a discovery skill (
codegraph-helper) that conditions the agent to use the right CodeGraph MCP tool for the task at hand.
- It does not modify or replace the
codegraphCLI. The upstreamcolbymchenry/codegraph(MIT) is the source of truth. - It does not install the
codegraphCLI. Users runnpm i -g @colbymchenry/codegraph(or the install script) themselves; the plugin just exposes/codegraph-installas a guided wrapper aroundcodegraph installfor MCP wiring. - It does not auto-run
codegraph init. Indexing is the user's decision. The plugin only activates when.codegraph/already exists. - It does not hook
PreToolUse,PostToolUse,UserPromptSubmit, orStop— onlySessionStart. This avoids collisions with codeguard-plugin and other plugins that own those events.
- A working
codegraphCLI inPATH. Install via:curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh | sh # or: npm i -g @colbymchenry/codegraph
- A host agent (Claude Code, Cursor, Codex CLI, opencode, Hermes Agent, Gemini CLI, Antigravity, or Kiro). For MCP-aware tools the host should already have
codegraph installrun once; otherwisecodegraph_explorewill be missing and the slash commands will fall back to CLI. - A
.codegraph/directory in the cwd for the SessionStart hook to activate. Without it the plugin is silent.
20 commands, one per one. Format mirrors codegraph's CLI surface.
| Command | Equivalent CLI | What it does |
|---|---|---|
/codegraph-init |
codegraph init [path] |
Initialize CodeGraph in the current project |
/codegraph-uninit |
codegraph uninit [path] |
Remove the .codegraph/ directory (irreversible) |
/codegraph-install |
codegraph install |
One-time wiring of MCP server into host agents |
/codegraph-uninstall |
codegraph uninstall |
Remove MCP wiring from host agents |
/codegraph-index |
codegraph index [path] |
Rebuild the full index from scratch |
/codegraph-sync |
codegraph sync [path] |
Incrementally sync (watcher auto-runs this) |
/codegraph-status |
codegraph status [path] |
Show index status & statistics |
/codegraph-query |
codegraph query <search> |
Search symbols by keyword |
/codegraph-explore |
codegraph explore <query> |
Multi-symbol source + call paths (primary entry) |
/codegraph-node |
codegraph node <name> |
One symbol's source + caller/callee trail, or one file |
/codegraph-files |
codegraph files |
Show indexed project file tree |
/codegraph-callers |
codegraph callers <symbol> |
Find what calls a symbol |
/codegraph-callees |
codegraph callees <symbol> |
Find what a symbol calls |
/codegraph-impact |
codegraph impact <symbol> |
Find what would be affected by changing a symbol |
/codegraph-affected |
codegraph affected [files] |
Find test files affected by changes |
/codegraph-daemon |
codegraph daemon |
Manage background daemons |
/codegraph-unlock |
codegraph unlock [path] |
Remove a stale lock file |
/codegraph-version |
codegraph version |
Print installed version |
/codegraph-telemetry |
codegraph telemetry [status|on|off] |
View or change telemetry |
/codegraph-upgrade |
codegraph upgrade [version] |
Upgrade codegraph CLI |
Hidden commands (prompt-hook, serve --mcp) are not exposed by this plugin.
[SessionStart]
│
▼
Read cwd from JSON payload (fallback: os.getcwd())
│
▼
Check `<cwd>/.codegraph/` exists?
│
├─ NO → exit 0 silently. (Plugin does nothing; agent continues.)
│
└─ YES → resolve target file:
<cwd>/.claude/CLAUDE.md if exists
else <cwd>/AGENTS.md
(NEVER auto-creates <cwd>/.claude/)
│
▼
Marker-fenced atomic write (byte-equal → no-op)
│
▼
Emit SessionStart additionalContext JSON
with the full CodeGraph prompt block
All exceptions fail-open (exit 0) — the host agent never sees a SessionStart error from this plugin.
Codegraph's own codegraph install writes the same prompt block to ~/.claude/CLAUDE.md (or local ./.claude/CLAUDE.md). The plugin's marker-fenced replacement is byte-equal idempotent, so:
- If the user has already run
codegraph install, the plugin's hook is a no-op on that cluster. - If the user runs
codegraph installafter installing this plugin,codegraph install's own marker-fenced writer (seecodegraph/src/installer/targets/shared.ts:130-194) is also byte-equal idempotent — no overwrite churn.
The plugin's contribution over codegraph install alone:
- Two audiences covered: codegraph's installer only writes files (reaches Task-tool subagents via the project instructions file); the plugin also emits
additionalContextfor the main agent at runtime. - AGENTS.md fallback: if a project doesn't use
.claude/CLAUDE.md, the plugin writes toAGENTS.md(the OpenSpec / multi-agent convention). - Slash commands: codegraph install doesn't expose any; this plugin covers all 20.
- Version bump + manifest sync is mandatory. Run
node scripts/bump-plugin.mjs codegraph patch|minor|majorafter any code change. - Sync from upstream: when codegraph's CHANGELOG mentions
instructions-template.ts, manually re-syncscripts/codegraph_lib/prompt.pyand bump patch. SeeAGENTS.md. - Plugin-local skills are tracked in
plugin-local-skills.json. Theskills.lock.jsonis empty by design — no third-party skills are vendored.
See docs/codegraph-architecture.md for the plugin's layered design.
Apache-2.0. See LICENSE. The official CodeGraph prompt block in scripts/codegraph_lib/prompt.py is verbatim from the upstream colbymchenry/codegraph project (MIT) — see NOTICE for attribution.
See PRIVACY.md. The plugin is client-side only, makes no network calls, reads no user source code, and writes only to host instruction files using marker-fenced replacement.