A comprehensive set of hooks for Claude Code to enforce clean code practices, prevent outdated dependencies, and automate development workflows.
- 📦 Package Age Validation: Prevents installation of outdated npm/yarn packages
- ✨ Clean Code Quality System: Validates function length, complexity, and code smells
- 🔍 Code Similarity Detection: Prevents code duplication
- 📝 CLAUDE.md Context Updater: Automatically maintains project documentation
- 🔔 Task Completion Notifications: System notifications for completed tasks
- 🧪 Comprehensive Testing: Full test suite for all hooks
# Clone the repository
git clone https://github.com/decider/claude-hooks.git
cd claude-hooks
# Run the setup script
./scripts/install.sh
# Copy hooks to your Claude directory
cp -r hooks ~/.claude/hooks
cp config/settings.example.json ~/.claude/settings.json
chmod +x ~/.claude/hooks/*.sh
For team projects, see Integration Guide for:
- Vendoring approach (recommended)
- Git submodule setup
- Direct installation
Edit ~/.claude/settings.json to customize:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/code-quality-primer.sh"
}
]
}
]
}
}
export MAX_AGE_DAYS=180 # Package age limit
export ENABLE_NOTIFICATIONS=true # Desktop notifications
export STRICT_MODE=false # Strict quality checks
| check-package-age.sh | Validates npm/yarn package age | Before package installation |
| code-quality-primer.sh | Clean Code reminders | Before file write/edit |
| code-quality-validator.sh | Validates code quality | After file write/edit |
| code-similarity-check.sh | Detects duplicate code | Before file operations |
| task-completion-notify.sh | Desktop notifications | After task completion |
| pre-commit-check.sh | Runs tests/lints | Before git commit |
| claude-context-updater.sh | Updates CLAUDE.md files | Various triggers |
All hooks automatically log their execution for debugging and monitoring. Logging is enabled by default - no configuration needed!
- Location: ~/.claude/logs/hooks.log
- Level: INFO (shows general execution flow)
- Max Size: 10MB (auto-rotates when exceeded)
- Retention: 7 days (old logs are automatically cleaned up)
To customize logging or turn it off, add to your settings.json:
{
"logging": {
"enabled": false, // Set to false to disable logging
"level": "DEBUG", // Or "WARN", "ERROR"
"path": "~/custom/path/hooks.log",
"maxSize": 5242880, // 5MB in bytes
"retention": 30 // Keep logs for 30 days
}
}
- DEBUG: Detailed information including inputs/outputs
- INFO: General information about hook execution
- WARN: Warnings about potential issues
- ERROR: Error conditions
# View logs interactively
~/.claude/tools/view-logs.sh
# Clean old logs
~/.claude/tools/clean-logs.sh
[2025-01-07 10:23:45] [INFO] [check-package-age] Hook started
[2025-01-07 10:23:45] [WARN] [check-package-age] Package [email protected] is 2835 days old (limit: 180)
[2025-01-07 10:23:45] [INFO] [check-package-age] Hook completed with exit code 1
To get the latest hooks:
cd ~/claude-hooks
git pull
./scripts/update.sh
Run the test suite:
cd tests
./test-all-hooks.sh
- Fork the repository
- Create your feature branch (git checkout -b feature/amazing-hook)
- Add your hook to hooks/
- Update config/settings.example.json
- Add tests to tests/
- Submit a Pull Request
MIT License - see LICENSE file for details
- Report issues: GitHub Issues
- Documentation: Wiki
- Discussions: GitHub Discussions
Current version: 1.0.0
Made with ❤️ for the Claude Code community
.png)

