Skip to content

fix(installer): stop duplicating agent instructions; MCP server is the single source of truth (#529)#538

Merged
colbymchenry merged 1 commit into
mainfrom
fix/529-drop-duplicate-agent-instructions
May 28, 2026
Merged

fix(installer): stop duplicating agent instructions; MCP server is the single source of truth (#529)#538
colbymchenry merged 1 commit into
mainfrom
fix/529-drop-duplicate-agent-instructions

Conversation

@colbymchenry
Copy link
Copy Markdown
Owner

Summary

Closes #529.

The installer wrote a ## CodeGraph usage block into each agent's instructions file (CLAUDE.md, AGENTS.md, GEMINI.md, Cursor .cursor/rules/codegraph.mdc, Kiro steering doc) that duplicated — almost verbatim — the guidance the MCP server already emits in its initialize response. Agents that surface MCP instructions (Claude Code does) read the same playbook twice every turn. The MCP server instructions are now the single source of truth.

What changed

  • All 6 instruction-writing targets (claude, cursor, codex, opencode, gemini, kiro) stop writing the block. (Hermes and Antigravity never wrote one.)
  • Self-heal: install now strips a block a previous version wrote (uninstall already did). So the next codegraph install / codegraph uninstall cleans up an existing install — re-install always runs the strip (no "already configured, skip" early-return). Simply upgrading the npm package does not trigger it (the shim is a launcher with no postinstall); the leftover block is harmless (just redundant) until the user re-runs the installer.
  • server-instructions.ts is the single source of truth. Ported the two steers that were unique to the old template: the explicit "trust codegraph — don't re-verify with grep" anti-pattern and the not-initialized → codegraph init -i hint.
  • Dead code removed: INSTRUCTIONS_TEMPLATE / CLAUDE_MD_TEMPLATE, claude-md-template.ts, writeClaudeMd / hasClaudeMdSection, and the Cursor-only wireProjectSurfaces bootstrap (its only job was writing the rules file). instructions-template.ts keeps just the markers needed to find/strip legacy blocks. The install log learned a Removed verb.
  • The "update all three" house rule collapses to edit server-instructions.ts and nowhere else.

Tests

  • Rewrote the instruction-specific installer tests to the new contract (install does not write; install + uninstall self-heal) and added self-heal coverage for both mechanisms (marker-strip for shared files, file-delete for Cursor .mdc / Kiro steering). 140/140 installer tests pass.
  • Full suite green except the 5 pre-existing npm-shim download tests, which fail identically on main (local-HTTPS/environment, unrelated).
  • tsc --noEmit clean, npm run build clean.

🤖 Generated with Claude Code

…e single source of truth (#529)

The installer wrote a `## CodeGraph` usage block into each agent's
instructions file (CLAUDE.md / AGENTS.md / GEMINI.md / .cursor/rules /
Kiro steering) that duplicated, almost verbatim, the guidance the MCP
server already emits in its `initialize` response — so agents that
surface MCP instructions (Claude Code) read the same playbook twice
every turn.

All 6 instruction-writing targets (claude, cursor, codex, opencode,
gemini, kiro) now stop writing the block. install self-heals by
stripping a block a previous version wrote (uninstall already did), so
the next `codegraph install`/`uninstall` cleans up existing installs;
upgrading the package alone does not (the leftover block is harmless).
server-instructions.ts is now the single source of truth — the two
steers unique to the old template ("trust codegraph, don't re-verify
with grep" and the not-initialized -> `init -i` hint) are ported there.

Removes the now-dead INSTRUCTIONS_TEMPLATE / CLAUDE_MD_TEMPLATE,
claude-md-template.ts, writeClaudeMd / hasClaudeMdSection, and the
Cursor-only wireProjectSurfaces bootstrap. The install log learned a
"Removed" verb. Tests rewritten to the new contract + self-heal
coverage (140/140 installer tests pass).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@colbymchenry colbymchenry merged commit a9c9e76 into main May 28, 2026
@colbymchenry colbymchenry deleted the fix/529-drop-duplicate-agent-instructions branch May 28, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLAUDE.md instructions duplicate MCP server instructions — wastes tokens every turn

1 participant