fix(installer): stop duplicating agent instructions; MCP server is the single source of truth (#529)#538
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #529.
The installer wrote a
## CodeGraphusage 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 itsinitializeresponse. 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
installnow strips a block a previous version wrote (uninstall already did). So the nextcodegraph install/codegraph uninstallcleans 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 nopostinstall); the leftover block is harmless (just redundant) until the user re-runs the installer.server-instructions.tsis 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 -ihint.INSTRUCTIONS_TEMPLATE/CLAUDE_MD_TEMPLATE,claude-md-template.ts,writeClaudeMd/hasClaudeMdSection, and the Cursor-onlywireProjectSurfacesbootstrap (its only job was writing the rules file).instructions-template.tskeeps just the markers needed to find/strip legacy blocks. The install log learned aRemovedverb.server-instructions.tsand nowhere else.Tests
.mdc/ Kiro steering). 140/140 installer tests pass.npm-shimdownload tests, which fail identically onmain(local-HTTPS/environment, unrelated).tsc --noEmitclean,npm run buildclean.🤖 Generated with Claude Code