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>
36 lines
927 B
Go
36 lines
927 B
Go
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)
|
|
}
|