Coding agents
MindGraph's coding profile turns the graph into a durable work substrate for coding agents: identity-stable code anchors, graph-managed tasks/plans/iterations with fenced leases, and a deterministic work brief that lets a fresh session resume exactly where the last one stopped — across sessions, crashes, and machines. Claude Code gets full automation via hooks; Codex gets the full tool surface via MCP.
Install (Claude Code)
npx -y mindgraph-mcp install-code --api-key mg_your_key --hooks
This registers the MCP server with MINDGRAPH_PROFILE=coding and installs the Claude Code session hooks. Connection settings persist to ~/.mindgraph/hooks.json (mode 600, user-level) so hooks work regardless of shell environment — the API key is never written into project settings. Prefer separate steps? install-code alone registers just the server; install-hooks --harness claude-code --scope user --api-key … adds hooks later (or --scope project --project-dir … for a single repository).
Optional: enable code intelligence
Install codegraph and run codegraph init in your repositories. This powers mindgraph_code's symbol anchors and live callers/impact federation. The installer tells you which state you're in; without codegraph, memory and work tools function fully and code anchoring returns typed unavailable results — never silent failure.
Teams: one graph, per-member identity
Several people can share one org graph on the same codebase: anchored knowledge converges automatically (identity keys off the git remote, so every clone resolves to the same code entities). Give each member a distinct agent identity so task leases and resume briefs stay per-person — with identical ids, a team is one logical agent and members lease-recover each other's active tasks:
npx -y mindgraph-mcp install-code --api-key mg_your_key --hooks --agent-id claude-code:yourname
The command generated in your dashboard includes your identity automatically.
Install (Codex)
codex mcp add mindgraph \
--env MINDGRAPH_API_KEY=mg_your_key \
--env MINDGRAPH_PROFILE=coding \
--env MINDGRAPH_HARNESS=codex \
-- npx -y mindgraph-mcp@latest
Codex gets all ten tools today. The hooks adapter (automatic session lifecycle and brief injection) is planned; until then, ask the agent to call mindgraph_plan resume_work at the start of a session — the tool description teaches it to.
What the coding profile adds
mindgraph_code—anchor/recall/expand/affected: identity-stable code entities (repository, file, symbol, route) plus live structural federation over your local codegraph index. Identity is the symbol, not the line number, so anchors survive refactors; staleness and wrong-index states are reported explicitly.mindgraph_sync— idempotent, resumable import of the markdown memory files you already have (.claude/agent-memory/**and friends), with content-hash drift tracking, conflict surfacing (never a silent clobber), and a retirement report that tells you when a file entry is superseded by the graph.- Durable-work composites on
mindgraph_plan—resume_work,claim_task,heartbeat,start_iteration,checkpoint_iteration,block_task,complete_task,abandon_iteration. Leases fence writes (a stale writer gets a typed409 version_conflictorlease_conflict), iterations are idempotent on retry keys, and a task whose last iterations all failed is flagged for escalation in the brief.
The hook lifecycle (Claude Code)
- SessionStart — opens or rebinds your session and injects one bounded work brief: active task, plan, next unblocked steps, recent executions, blockers, and the version/lease data needed to continue. Includes crash recovery: an expired lease from a dead session is taken over with a full audit trail.
- PreToolUse — stamps MindGraph calls with verified session, repo, branch, and commit provenance. It fills missing work-targeting fields from the session ledger but never overwrites what the model chose.
- Stop — one reflection checkpoint per session: if substantial work is uncheckpointed, the agent is prompted once to checkpoint the iteration, capture a durable lesson, or state that nothing durable changed.
- SessionEnd — cleanup only. Correctness never depends on it firing.
First run: import the memory you already have
If you've accumulated agent-memory markdown (lessons, fragile-path notes, audits), ask your agent to sync it — the agent reads each file and captures typed, code-anchored knowledge; the sync tool handles discovery, hashing, idempotency, and drift:
Scan my memory files with mindgraph_sync and import them into the graph.
Map lessons to Lessons, fragile-path notes to risks + claims, and anchor
them to the code they describe.
Server compatibility
mindgraph-server 1.11.0+ (build from source). The default general profile — 8 tools, no coding surface — works against any 1.10+ server.Environment reference
MINDGRAPH_PROFILE—general(default) orcodingMINDGRAPH_HARNESS—claude-code,codex, orgenericMINDGRAPH_CODEGRAPH_BIN— explicit codegraph path (PATH and~/.local/binare probed)MINDGRAPH_BASE_URL— self-hosted server override
See also: the mindgraph-mcp reference for the full tool surface, and the coding overview for the cross-session scenario and measured numbers.