feat(setup claude): add --stealth flag

Add a `--stealth` flag to `bd setup claude` that installs
Claude Code hooks using `bd prime --stealth` instead of
`bd prime`. This extends the stealth workflow introduced for
`bd prime` to the setup command, enabling workflows where git
operations should be deferred or handled separately from bd
database flushing.

When `--stealth` is specified, the installed hooks call
`bd prime --stealth`, which outputs only `bd sync --flush-only`
in the close protocol, omitting all git operations.

Update `RemoveClaude()` to remove both command variants
(`bd prime` and `bd prime --stealth`) for backwards
compatibility with existing installations. Update
`hasBeadsHooks()` to detect either variant as a valid
installation.

Add comprehensive test coverage for stealth mode: hook
installation with stealth command, removal of both variants,
detection of both variants, and idempotency with stealth mode.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Abhinav Gupta
2025-12-03 18:05:08 -08:00
parent c9eeecf0c3
commit 4a7d7b0b41
3 changed files with 153 additions and 11 deletions
+3 -1
View File
@@ -9,6 +9,7 @@ var (
setupProject bool
setupCheck bool
setupRemove bool
setupStealth bool
)
var setupCmd = &cobra.Command{
@@ -86,7 +87,7 @@ agents from forgetting bd workflow after context compaction.`,
return
}
setup.InstallClaude(setupProject)
setup.InstallClaude(setupProject, setupStealth)
},
}
@@ -94,6 +95,7 @@ func init() {
setupClaudeCmd.Flags().BoolVar(&setupProject, "project", false, "Install for this project only (not globally)")
setupClaudeCmd.Flags().BoolVar(&setupCheck, "check", false, "Check if Claude integration is installed")
setupClaudeCmd.Flags().BoolVar(&setupRemove, "remove", false, "Remove bd hooks from Claude settings")
setupClaudeCmd.Flags().BoolVar(&setupStealth, "stealth", false, "Use 'bd prime --stealth' (flush only, no git operations)")
setupCursorCmd.Flags().BoolVar(&setupCheck, "check", false, "Check if Cursor integration is installed")
setupCursorCmd.Flags().BoolVar(&setupRemove, "remove", false, "Remove bd rules from Cursor")