This repository contains Claude Code hooks and configuration files designed to enhance the development experience when using Claude Code. The repository serves as a collection of utilities and validation tools rather than a traditional application codebase.
The repository implements Claude Code's hook system for validating and enhancing tool usage:
-
bash_command_validator.py: A PreToolUse hook for the Bash tool that validates commands and suggests better alternatives:
- Recommends
rg(ripgrep) overgrep - Suggests
rg --filespatterns overfind -name - Recommends
ast-grepfor source code searching in Swift, Python, TypeScript, and Rust files
- Recommends
-
file_protection.py: A file protection hook that prevents modification of sensitive files:
- Blocks editing of
.env, lock files (package-lock.json,Package.resolved,bun.lock,Cargo.lock), and.git/directory contents
- Blocks editing of
- ast-grep-rule.md: Comprehensive documentation for ast-grep pattern syntax, including meta variables, pattern matching, and advanced usage examples
This repository includes a .claude/settings.json template that uses ${HOME} substitution variables for portability. To set up the configuration on your machine:
# Run the setup script to replace ${HOME} with your actual home directory
uv run scripts/update_settings_paths.pyThis script will:
- Create a backup of the original settings file (
.claude/settings.json.backup) - Replace all
${HOME}variables with your actual home directory path - Update the settings file with machine-specific paths
The configuration includes:
- Hook integrations for bash command validation and file protection
- Local marketplace and plugin setup (including the explanatory-output-style plugin)
- Environment variables and custom status line configuration
This repository includes a local plugin marketplace for Claude Code customizations. The structure follows Claude Code's plugin system:
.claude-plugin/
marketplace.json # Marketplace definition
plugins/
explanatory-output-style/ # Plugin directory
.claude-plugin/
plugin.json # Plugin metadata
hooks/
hooks.json # Hook definitions
hooks-handlers/
session-start.sh # SessionStart hook implementation
README.md # Plugin documentation
All plugins are defined and maintained locally in this repository, making it easy to customize and extend functionality without depending on external repositories.
The settings file configures these hooks for your Claude Code setup:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "uv run ${HOME}/Develop/claude-code/hooks/bash_command_validator.py"
}
]
},
{
"matcher": "Edit|MultiEdit|Write",
"hooks": [
{
"type": "command",
"command": "uv run ${HOME}/Develop/claude-code/hooks/file_protection.py"
}
]
}
]
}
}This repository doesn't contain traditional build/test commands as it's primarily a configuration repository. The Python hooks can be executed directly:
# Test bash command validator
echo '{"tool_name": "Bash", "tool_input": {"command": "grep pattern file.txt"}}' | uv run hooks/bash_command_validator.py
# Test file protection
echo '{"tool_input": {"file_path": ".env"}}' | uv run hooks/file_protection.pyThe hooks enforce these tool preferences:
- Use
rg(ripgrep) instead ofgrepfor text searching - Use
ast-greporsgfor structural code searching and refactoring - Use
rg --filespatterns instead offind -namefor file discovery - Leverage ast-grep for language-aware code analysis in Swift, Python, TypeScript, and Rust
The hooks use specific exit codes for different behaviors:
0: Allow tool execution1: Show error to user but not to Claude2: Block tool execution and show error to Claude