Problem
CodeGraph injects its usage instructions into the agent context twice per session:
- MCP
SERVER_INSTRUCTIONS — emitted in the MCP initialize response, surfaced by Claude Code as a system reminder (## codegraph block). This is automatic for any MCP server.
INSTRUCTIONS_TEMPLATE — written into CLAUDE.md (global or project-level) by codegraph init, wrapped in <!-- CODEGRAPH_START --> / <!-- CODEGRAPH_END --> markers.
Both contain ~90% identical content (tool selection table, rules of thumb, anti-patterns, staleness banner guidance). The CLAUDE.md version is loaded into the system prompt alongside the MCP server instructions, so the agent reads the same advice twice on every single turn.
Token cost
The CLAUDE.md block is ~35 lines / ~1,500 tokens of input. Since it duplicates what the MCP server already provides, it burns ~1,500 extra input tokens per message for no benefit.
Source files
SERVER_INSTRUCTIONS in mcp/server-instructions.ts — the MCP-level injection
INSTRUCTIONS_TEMPLATE in installer/instructions-template.ts — the CLAUDE.md injection
writeInstructionsEntry() in installer/targets/claude.ts — writes the template into CLAUDE.md on codegraph init
Suggested fix
Since the MCP server instructions are always injected by the MCP protocol, the CLAUDE.md block is redundant for Claude Code. Options:
- Skip the CLAUDE.md write for Claude Code — the MCP server instructions already cover it. Other targets (Cursor
.mdc, Kiro) may still benefit from their own instruction files since they don't surface MCP server instructions the same way.
- Make the CLAUDE.md write opt-in — add a
--no-instructions flag to codegraph init so users can skip it.
- Deduplicate the content — have the CLAUDE.md block contain only a one-liner like "CodeGraph is configured — see MCP server instructions" instead of the full template.
Option 1 seems cleanest since Claude Code already surfaces SERVER_INSTRUCTIONS reliably.
Problem
CodeGraph injects its usage instructions into the agent context twice per session:
SERVER_INSTRUCTIONS— emitted in the MCPinitializeresponse, surfaced by Claude Code as a system reminder (## codegraphblock). This is automatic for any MCP server.INSTRUCTIONS_TEMPLATE— written intoCLAUDE.md(global or project-level) bycodegraph init, wrapped in<!-- CODEGRAPH_START -->/<!-- CODEGRAPH_END -->markers.Both contain ~90% identical content (tool selection table, rules of thumb, anti-patterns, staleness banner guidance). The CLAUDE.md version is loaded into the system prompt alongside the MCP server instructions, so the agent reads the same advice twice on every single turn.
Token cost
The CLAUDE.md block is ~35 lines / ~1,500 tokens of input. Since it duplicates what the MCP server already provides, it burns ~1,500 extra input tokens per message for no benefit.
Source files
SERVER_INSTRUCTIONSinmcp/server-instructions.ts— the MCP-level injectionINSTRUCTIONS_TEMPLATEininstaller/instructions-template.ts— the CLAUDE.md injectionwriteInstructionsEntry()ininstaller/targets/claude.ts— writes the template into CLAUDE.md oncodegraph initSuggested fix
Since the MCP server instructions are always injected by the MCP protocol, the CLAUDE.md block is redundant for Claude Code. Options:
.mdc, Kiro) may still benefit from their own instruction files since they don't surface MCP server instructions the same way.--no-instructionsflag tocodegraph initso users can skip it.Option 1 seems cleanest since Claude Code already surfaces
SERVER_INSTRUCTIONSreliably.