fix(installer): stop writing duplicate instructions block to CLAUDE.m…#532
Open
Bin-hy wants to merge 1 commit into
Open
fix(installer): stop writing duplicate instructions block to CLAUDE.m…#532Bin-hy wants to merge 1 commit into
Bin-hy wants to merge 1 commit into
Conversation
…d for Claude Code Claude Code already receives SERVER_INSTRUCTIONS via the MCP initialize response every session (~1700 tokens as a system reminder). The installer was also writing an INSTRUCTIONS_TEMPLATE block to CLAUDE.md (~1500 tokens, ~90% identical content), so agents paid the cost twice on every turn with no benefit. On install(), strip any existing block with removeMarkedSection() instead of writing a new one — upgrading users have the legacy block removed automatically. uninstall() is unchanged (already calls removeMarkedSection). writeInstructionsEntry() stays exported for the deprecated config-writer.ts shim. Other targets (Cursor, Codex, opencode, Gemini, Kiro) are unchanged. Closes colbymchenry#529 Co-Authored-By: Claude Sonnet 4.6 <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
EN: Claude Code already receives
SERVER_INSTRUCTIONSvia the MCPinitializeresponse on every session (~1700 tokens, surfaced as a system reminder). The installer was also writing anINSTRUCTIONS_TEMPLATEblock toCLAUDE.md(~1500 tokens, ~90% identical content), so agents read the same guidance twice on every turn with no benefit — pure token waste.CN: Claude Code 每次会话已通过 MCP
initialize响应收到SERVER_INSTRUCTIONS(~1700 tokens,以系统提醒形式展示)。安装器同时还会向CLAUDE.md写入一份INSTRUCTIONS_TEMPLATEblock(~1500 tokens,内容约 90% 重合),导致 agent 每轮都重复读取相同内容,纯粹的 token 浪费。Changes / 改动
src/installer/targets/claude.ts: Ininstall(), replace thewriteInstructionsEntry()call withremoveMarkedSection()— strips the existing block if a legacy install left one (automatic migration for upgrading users). Only reportsaction: 'removed'when content was actually stripped.uninstall()is unchanged (already callsremoveMarkedSection).writeInstructionsEntry()stays exported for the deprecatedconfig-writer.tsshim.SERVER_INSTRUCTIONSand still need their own instructions files.CHANGELOG.md: entry added under## [Unreleased] / ### Changed.src/installer/targets/claude.ts:在install()中将writeInstructionsEntry()改为调用removeMarkedSection()——如果旧版安装留下了 block,自动将其清除(升级用户无需手动操作)。仅在实际移除内容时才向files添加action: 'removed'。uninstall()保持不变。writeInstructionsEntry()保留导出供已废弃的config-writer.tsshim 使用。SERVER_INSTRUCTIONS,仍需各自的指令文件。CHANGELOG.md:在## [Unreleased] / ### Changed下新增条目。Test plan / 测试
__tests__/installer-targets.test.tspasses (134 tests) — all parametrized contract tests for Claude still pass (files.length > 0, idempotency,alreadyConfiguredround-trip)claude: install does not write CLAUDE.md instructions blockclaude: install strips existing CLAUDE.md codegraph block (migration path)— verifies user content outside markers is preserved and removal is surfaced inresult.files🤖 Generated with Claude Code