fix(setup): skip duplicate hooks when beads plugin is installed#3196
Open
sjsyrek wants to merge 1 commit intogastownhall:mainfrom
Open
fix(setup): skip duplicate hooks when beads plugin is installed#3196sjsyrek wants to merge 1 commit intogastownhall:mainfrom
sjsyrek wants to merge 1 commit intogastownhall:mainfrom
Conversation
…192) When both the beads Claude Code plugin and `bd setup claude` are active, bd prime fires twice per session — wasting ~1-2k tokens each time. The plugin already declares identical SessionStart/PreCompact hooks in its plugin.json, so project-level hooks are redundant. Now `bd setup claude` detects the plugin via enabledPlugins in settings files and skips writing hooks when the plugin is already providing them. The CLAUDE.md integration section is still installed since the plugin does not provide that. `bd setup claude --check` reports "plugin-managed" as a valid success state instead of "No hooks installed". Co-Authored-By: Claude Opus 4.6 (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
Fixes #3192. When both the beads Claude Code plugin and
bd setup claudeare active,bd primefires twice per session — wasting ~1-2k tokens each time. The plugin already declares identicalSessionStart/PreCompacthooks in itsplugin.json, so project-level hooks frombd setup claudeare redundant.Changes Made
hasBeadsPlugin()— checks project, global, and legacy settings files for an enabled beads entry inenabledPluginsinstallClaude()— skips writingSessionStart/PreCompacthooks when the plugin is detected; still installs the CLAUDE.md section (which the plugin does not provide)checkClaude()— reports"✓ Hooks provided by beads plugin (plugin-managed)"as a valid success state instead of"✗ No hooks installed"Backward Compatibility
✅ No breaking changes: Users without the plugin see identical behavior
✅ Users with plugin:
bd setup claudenow skips hooks instead of duplicating them✅
bd setup claude --remove: Still works unconditionally (removes any project-level hooks regardless of plugin state)✅ CLAUDE.md section: Still installed even with plugin present
Technical Details
enabledPluginsdetection pattern fromcmd/bd/doctor/claude.go, but adapted for theclaudeEnvabstraction to keep tests hermetic"beads@...": false) correctly do not trigger the skipenv.readFile(notos.ReadFile) so tests don't touch the real filesystemTest plan
go test ./cmd/bd/setup/— all 105 tests pass (98 existing + 7 new)go vet ./cmd/bd/setup/— cleango build ./cmd/bd/...— compiles successfullybd setup claudein a project with the plugin installed → should print "plugin-managed, skipping"bd setup claude --checkwith plugin but no project hooks → should report "plugin-managed"bd setup claudewithout plugin → should register hooks as beforeSize: Small ✓
Two-file change, straightforward conditional + detection function.
🤖 Generated with Claude Code