refactor(hooks): rename to gt tap guard pr-workflow

Reorganizes Claude Code hook handlers under `gt tap` namespace:
- gt tap - parent command for all hook handlers
- gt tap guard - subcommand for blocking operations
- gt tap guard pr-workflow - blocks PR creation and feature branches

This structure allows future expansion:
- gt tap audit <x>   - logging/metrics (PostToolUse)
- gt tap inject <x>  - input modification (PreToolUse)
- gt tap check <x>   - validation (PostToolUse)

Replaces the flat gt block-pr-workflow command.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
beads/crew/emma
2026-01-19 11:21:54 -08:00
committed by Steve Yegge
parent 37f465bde5
commit dcf7b81011
3 changed files with 151 additions and 106 deletions

35
internal/cmd/tap.go Normal file
View File

@@ -0,0 +1,35 @@
package cmd
import (
"github.com/spf13/cobra"
)
var tapCmd = &cobra.Command{
Use: "tap",
Short: "Claude Code hook handlers",
Long: `Hook handlers for Claude Code PreToolUse and PostToolUse events.
These commands are called by Claude Code hooks to implement policies,
auditing, and input transformation. They tap into the tool execution
flow to guard, audit, inject, or check.
Subcommands:
guard - Block forbidden operations (PreToolUse, exit 2)
audit - Log/record tool executions (PostToolUse) [planned]
inject - Modify tool inputs (PreToolUse, updatedInput) [planned]
check - Validate after execution (PostToolUse) [planned]
Hook configuration in .claude/settings.json:
{
"PreToolUse": [{
"matcher": "Bash(gh pr create*)",
"hooks": [{"command": "gt tap guard pr-workflow"}]
}]
}
See ~/gt/docs/HOOKS.md for full documentation.`,
}
func init() {
rootCmd.AddCommand(tapCmd)
}