Skip to content

fix(init): honor --no-mcp and --no-hooks for Claude Code - #124

Closed
michaelxer wants to merge 1 commit into
trailhq:mainfrom
michaelxer:michaelxer/fix-claude-init-no-mcp-118-20260816
Closed

michaelxer wants to merge 1 commit into
trailhq:mainfrom
michaelxer:michaelxer/fix-claude-init-no-mcp-118-20260816

Conversation

@michaelxer

Copy link
Copy Markdown

Fixes #118.

Problem

graft init --no-mcp (and --no-hooks) only reached other-agent wiring. Claude Code still wrote .mcp.json and the hook shim/settings, even though the README says --no-mcp skips Claude Code MCP registration.

That's the path that burns extra LLM cache when Claude Code is pointed at a DeepSeek endpoint.

Fix

  • runInit honors mcp / hooks the same way runHostsInit already did
  • --dry-run / the picker drop those Claude paths
  • a later wiring refresh replays the stamp so an upgrade does not put them back
  • default graft init is unchanged

How I tested

node --import tsx --test test/claude-init.test.ts test/claude-settings-merge.test.ts test/hosts-init.test.ts test/hosts-plan.test.ts test/upkeep.test.ts

80 passed.

Local repro after the change:

graft init <tmp> --no-build --agents claude --no-mcp --no-hooks

writes statusline + skill, no .mcp.json, no graft-hooks.cjs. Default --agents claude still writes both.

Did not run a live Claude Code session against DeepSeek.

@Christian-B-Koller

Copy link
Copy Markdown

Appreciate your work 👍

github-actions Bot added a commit that referenced this pull request Aug 25, 2026
@github-actions

github-actions Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🌱 graft blast radius

3 areas changed → 1 area can be affected. 3 dependent symbols, depth 2.
Tests: no test reaches CLI Wiring; 2 areas updated their tests.
Tag: @anirudhkumar-nanonets — 4 of 4 areas · @shhdwi — 3 of 4 areas

flowchart TB
  A0(("MCP Retraction<br/>3 symbols"))
  classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
  class A0 reached;
Loading
Can be affected Symbols Nearest hop Reached from
MCP Retraction 3 src/hosts/retract.ts:L348-L467 targets — calls, depth 1 Claude Initialization, Claude Global Setup
Who knows this code — 2 people across 4 areas
Area Who knows it
Claude Global Setup · changed @anirudhkumar-nanonets — 5 commits, last today · @shhdwi — 3 commits, last 19d ago
Claude Initialization · changed @anirudhkumar-nanonets — 13 commits, last today · @shhdwi — 3 commits, last 1mo ago
CLI Wiring · changed @anirudhkumar-nanonets — 35 commits, last today · @shhdwi — 23 commits, last 19d ago
MCP Retraction · affected @anirudhkumar-nanonets — 2 commits, last today

Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no @ has no GitHub handle in its commit email — tag them by hand, or add a .mailmap entry. A suggestion from history, not a CODEOWNERS rule.

All 3 dependent symbols, grouped by area

MCP Retraction — 3 symbols in 1 file

  • src/hosts/retract.ts:L348-L467 — targets (calls, depth 1)
    369: for (const t of claudeTargets(repo)) keptPaths.add(t.path);
  • src/hosts/retract.ts:L474-L476 — planRetract (calls, depth 2)
  • src/hosts/retract.ts:L483-L486 — runRetract (calls, depth 2)
Test signal per changed area — 2 ✓ · 1 ✗

Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.

  • ✓ Claude Global Setup — 3 of 3 reached · 2 test files changed here: test/hosts-claude-global.test.ts, test/hosts-plan.test.ts
  • ✓ Claude Initialization — 2 of 3 reached · 3 test files changed here: test/claude-init.test.ts, test/claude-settings-merge.test.ts, test/hosts-claude-global.test.ts
    • not reached: claudeTargets
  • ✗ CLI Wiring — 0 of 2 reached · no test file reaches it
    • not reached: wireTarget, rewriteWiring
2 test suites also reference this code

4 symbols, kept out of the diagram and the table so they cannot crowd out the areas a reviewer has to look at.

  • test/cli-picker.test.ts
  • test/hosts-retract.test.ts

⚠️ 1 changed file not in the graph (CHANGELOG.md) — no parser claims the extension, or the index predates the file.

graft blast · origin/main...HEAD · depth 2 · 12 changed files

Open the interactive graph → — click an area to see its dependent symbols at file:line.

github-actions Bot added a commit that referenced this pull request Aug 25, 2026
@michaelxer
michaelxer force-pushed the michaelxer/fix-claude-init-no-mcp-118-20260816 branch from 468c545 to 812077b Compare August 27, 2026 14:12
github-actions Bot added a commit that referenced this pull request Aug 27, 2026
@michaelxer
michaelxer force-pushed the michaelxer/fix-claude-init-no-mcp-118-20260816 branch from 812077b to 29f906b Compare August 31, 2026 13:26
github-actions Bot added a commit that referenced this pull request Aug 31, 2026
Those flags only reached other-agent wiring. Claude Code still wrote
.mcp.json and the hook shim. Skip the matching Claude writes, keep
dry-run/picker in sync, and replay the stamp on refresh.

Fixes trailhq#118
@shhdwi

shhdwi commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this, and for the clear write-up of #118! Main has moved underneath it: the Claude Code home wiring from #276 changed the MCP result types, and after resolving the conflicts this branch no longer compiles (src/hosts/claude-global.ts: 'McpWrite' is not assignable to 'ConfigWrite'). #333 is the one we are taking forward for the dry-run half. The real-init bug is still there on main (--no-mcp --no-hooks still writes .mcp.json and the hook shim for Claude Code), so a fresh, focused PR against current main for #118 would be very welcome. Closing this one.

@shhdwi shhdwi closed this Sep 29, 2026
github-actions Bot added a commit that referenced this pull request Sep 29, 2026
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.

graft init --no-mcp does not work for Claude Code

3 participants