A comprehensive collection of hooks and plugins for Claude Code and OpenCode, plus traditional git hooks for code quality and security. Enhance your development workflow with event-driven automation across multiple AI coding assistants.
This repository provides dual-support for both Claude Code hooks and OpenCode plugins, allowing you to use the same automation concepts with either AI coding assistant.
📦 What's included:
- Claude Code Hooks - Event-driven scripts for Claude Code (PreToolUse, PostToolUse, etc.)
- OpenCode Plugins - TypeScript plugins for OpenCode (migrated equivalents)
- Git Hooks - Traditional pre-commit hooks for code quality and security (work with any workflow)
- Multi-language support - Python, JavaScript, TypeScript, Go, Shell
- ✅ Python, Shell, or JavaScript hooks
- ✅ More lifecycle events (SubagentStop, PreCompact)
- ✅ Rich environment variables
- ✅ Mature ecosystem
- 📖 See:
claude-code/README.md
- ✅ TypeScript/JavaScript plugins
- ✅ Native async/await
- ✅ Built-in zx for shell commands
- ✅ Familiar to web developers
- 📖 See:
opencode/README.md
- 📊 Migration Analysis:
MIGRATION_ANALYSIS.md - 📖 Migration Guide:
docs/migration-guide.md - ⚖️ Comparison:
docs/comparison.md
git clone https://github.com/AutumnsGrove/Hooks.git ~/Projects/Hooks
cd ~/Projects/Hookscd claude-code/
./deploy.shThis automatically:
- Copies hooks from
claude-code/hooks/to~/.claude/hooks/ - Updates
~/.claude/settings.jsonto register them - Preserves your existing hooks and settings
📖 Full guide: claude-code/README.md
cd opencode/
npm install
# Configure in your project's opencode.json
{
"plugins": [
"path/to/Hooks/opencode/plugins/grep-to-rg.ts"
]
}📖 Full guide: opencode/README.md
./ClaudeUsage/pre_commit_hooks/install_hooks.shInstalls traditional git hooks for code quality and security.
Since this is a git repository, easily sync hooks across machines:
# On a new machine
cd ~/Projects/Hooks
git pull origin main
cd claude-code/ && ./deploy.sh # For Claude Code
# or
cd opencode/ && npm install # For OpenCodeHooks/
├── claude-code/ # Claude Code hooks
│ ├── hooks/ # Hook scripts (Python, Shell)
│ │ └── grep-to-rg.py # Convert grep → rg
│ ├── deploy_hooks.py # Deployment script
│ ├── deploy.sh # Quick deploy wrapper
│ └── README.md # Claude Code setup guide
│
├── opencode/ # OpenCode plugins
│ ├── plugins/ # Plugin implementations (TypeScript)
│ │ ├── grep-to-rg.ts # Convert grep → rg
│ │ └── ... (coming soon)
│ ├── package.json # Dependencies
│ ├── tsconfig.json # TypeScript config
│ └── README.md # OpenCode setup guide
│
├── docs/ # Migration & comparison docs
│ ├── migration-guide.md # How to migrate hooks to plugins
│ ├── comparison.md # Claude Code vs OpenCode
│ └── claude-code-hooks-research.md # Community research
│
├── ClaudeUsage/ # Guides & git hooks
│ ├── pre_commit_hooks/ # Traditional git hooks
│ │ ├── install_hooks.sh # Interactive installer
│ │ ├── pre-commit-secrets-scanner # Prevents API key leaks
│ │ ├── pre-commit-python # Black, Ruff, pytest
│ │ ├── pre-commit-javascript # Prettier, ESLint
│ │ └── ... (11 total hooks)
│ └── ... (18 workflow guides)
│
├── MIGRATION_ANALYSIS.md # Migration feasibility analysis
├── IDEAS.md # 20+ hook/plugin ideas
├── CLAUDE.md # Project instructions
└── README.md # This file
Pre-commit hooks:
pre-commit-secrets-scanner- Prevents committing API keys (15+ patterns: Anthropic, OpenAI, AWS, GitHub, etc.)pre-commit-python- Black formatter, Ruff linter, pytestpre-commit-javascript- Prettier, ESLintpre-commit-go- gofmt, golangci-lintpre-commit-multi-language- Auto-detects project type
Other git hooks:
pre-push- Runs test suite before pushingpost-checkout- Auto-updates dependencies on branch switchcommit-msg- Validates conventional commit formatprepare-commit-msg- Adds templates to commit messages
Currently available:
| Hook/Plugin | Claude Code | OpenCode | Purpose |
|---|---|---|---|
| grep-to-rg | ✅ | ✅ | Convert grep → rg for performance |
| uv-enforcer | ✅ | ✅ | Enforce UV package manager usage |
| auto-formatter | ✅ | ✅ | Auto-format code (Black, Prettier, gofmt, rustfmt) |
| conventional-commit-validator | ✅ | ✅ | Enforce commit message format |
| command-tracker | ✅ | ✅ | Log all tool calls to SQLite database |
| session-tracker | ✅ | ✅ | Capture session analytics (duration, tools, files) |
| subagent-tracker | ✅ | ❌ | Track subagent completions (Claude Code only) |
| todo-extractor | ✅ | ✅ | Extract TODOs with priority detection |
| rm-protection | ✅ | ✅ | Move files to trash instead of deleting |
| test-runner | ✅ | ✅ | Auto-run tests when test files change |
Total: 10 hooks implemented (9 available in both systems)
Still planned (see IDEAS.md for details):
- Live website screenshot optimizer
- NPM vulnerability checker
- Smart PR creator
- Session end TTS notifications
- And 10+ more...
See MIGRATION_ANALYSIS.md for full migration status.
This collection includes security best practices:
-
✅ Pre-commit secrets scanner - Detects 15+ secret patterns before commit:
- Anthropic, OpenAI, AWS, GitHub, Google API keys
- JWT tokens, bearer tokens, private keys
- Hardcoded passwords and database credentials
- Provides actionable fix instructions when secrets detected
-
✅ Comprehensive
.gitignorepatterns -
✅ Security audit guides
# Interactive installer (auto-detects your language)
cd ~/Projects/YourProject
~/Projects/Hooks/ClaudeUsage/pre_commit_hooks/install_hooks.sh
# This installs:
# - Code quality checks (formatters + linters)
# - Security scanner (prevents API key leaks)
# - Test runner (blocks push if tests fail)
# - Dependency auto-updater1. Create a new hook:
# Add your hook to claude-code/hooks/
cd ~/Projects/Hooks
# Create your hook file (Python, Shell, etc.)
# Example: src/hooks/my-custom-hook.py2. Deploy to Claude Code:
./deploy.sh
# Or use Python directly:
uv run python deploy_hooks.py3. Restart Claude Code to activate the hooks
Hook event type detection:
The deployment script detects hook types using two methods:
-
Metadata in file (recommended):
#!/usr/bin/env python3 # CLAUDE_HOOK_EVENT: PreToolUse
-
Filename conventions (fallback):
*pre-tool*or*pretool*→ PreToolUse*post-tool*or*posttool*→ PostToolUse*prompt*or*user-prompt*→ UserPromptSubmit*session-start*→ SessionStart*session-end*→ SessionEnd*subagent-stop*→ SubagentStop
The deployment script automatically:
- Auto-detects hook event types
- Copies hooks to
~/.claude/hooks/ - Updates
~/.claude/settings.json - Makes hooks executable
- Preserves existing hooks and settings
See Claude Code documentation for hook API details.
All guides in ClaudeUsage/ directory:
- git_guide.md - Git workflow and conventional commits
- pre_commit_hooks/setup_guide.md - Hook installation and customization
- pre_commit_hooks/TROUBLESHOOTING.md - Common issues and solutions
- secrets_management.md - API key security
- See ClaudeUsage/README.md for complete index
Found a useful hook? Want to share your automation?
- Fork this repository
- Add your hook to the appropriate directory
- Update documentation
- Submit a pull request
Follow conventional commit format:
feat: add pre-commit hook for Rust projects
fix: correct Python hook detection logic
docs: update installation instructionschmod +x ~/Projects/Hooks/ClaudeUsage/pre_commit_hooks/*
~/Projects/Hooks/ClaudeUsage/pre_commit_hooks/install_hooks.shMake sure you've pulled the latest changes:
cd ~/Projects/Hooks
git pull origin mainSee ClaudeUsage/pre_commit_hooks/TROUBLESHOOTING.md for comprehensive troubleshooting.
This collection is provided as-is for use with Claude Code. Customize freely for your projects.
Last updated: 2025-11-11 Compatible with: Claude Code CLI Hook types: Git hooks, Claude Code event hooks