1
0
Fork 0
mirror of https://github.com/imjasonh/cnotes synced 2026-07-16 12:21:48 +00:00

Initial implementation of Claude Code hooks in Go

- Easy-to-use hook registration system
- Built-in hooks for bash validation, file protection, and logging
- Automatic goimports formatting for modified Go files
- CLI with install/uninstall commands
- Comprehensive documentation and examples

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jason Hall 2025-07-21 10:12:28 -04:00
parent 2d0411b022
commit 2e7a2badba
Failed to extract signature
14 changed files with 767 additions and 0 deletions

31
cmd/run.go Normal file
View file

@ -0,0 +1,31 @@
package cmd
import (
"context"
"os"
"github.com/spf13/cobra"
"github.com/imjasonh/hooks/internal/hooks"
_ "github.com/imjasonh/hooks/internal/handlers"
)
var runCmd = &cobra.Command{
Use: "run",
Short: "Run hook handler (called by Claude Code)",
Long: `Run the hook handler by reading JSON from stdin and processing it.
This command is typically called automatically by Claude Code when hooks are triggered.
You can also use it for testing by piping JSON input.`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
code := hooks.RunExitCode(ctx)
if code != 0 {
os.Exit(code)
}
return nil
},
}
func init() {
rootCmd.AddCommand(runCmd)
}