A hook system for Claude Code that automatically enhances user prompts with predefined templates.
This tool intercepts user messages sent to Claude Code and injects them into customizable templates. This allows you to:
- Apply consistent instructions to every task
- Include project-specific guidelines automatically
- Combine user input with structured frameworks
- Ensure quality standards are always followed
User Message --> Hook --> Template Injection --> Enhanced Prompt --> Claude
- User sends a message:
"Add user authentication" - Hook captures the message
- Template is loaded from
.claude/prompt-template.md [PROMPT]placeholder is replaced with user's message- Enhanced prompt is sent to Claude with full context
- Claude Code CLI
- bash
- Python 3.6+
- jq (JSON processor)
# macOS
brew install jq
# Ubuntu/Debian
sudo apt-get install jq
# Windows (WSL)
sudo apt-get install jq# Create hooks directory in your project
mkdir -p YOUR_PROJECT/.claude/hooks
# Copy the hook script
cp hooks/enhance-prompt.sh YOUR_PROJECT/.claude/hooks/
# Make it executable
chmod +x YOUR_PROJECT/.claude/hooks/enhance-prompt.shNote: The Python helper script is auto-generated by the shell script on first run.
# Copy an existing template
cp templates/basic-template.md YOUR_PROJECT/.claude/prompt-template.md
# Or create your own with [PROMPT] placeholderAdd to your .claude/settings.json:
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "bash ${CLAUDE_PROJECT_DIR}/.claude/hooks/enhance-prompt.sh"
}
]
}
]
}
}Templates use a simple placeholder system. The [PROMPT] placeholder is replaced with the user's message:
## Task
[PROMPT]
---
## Instructions
1. Follow these guidelines
2. Use these best practices
3. Apply these standards
---
## Success Criteria
- [ ] Requirement 1
- [ ] Requirement 2| Template | Description |
|---|---|
basic-template.md |
Simple task structure with basic guidelines |
advanced-template.md |
Multi-phase workflow with quality standards |
Template (.claude/prompt-template.md):
## Task
[PROMPT]
Please follow best practices and write tests.User Input:
Add user login
Result sent to Claude:
## Task
Add user login
Please follow best practices and write tests.Template:
## Task
[PROMPT]
## Workflow
1. Plan the implementation
2. Write clean code
3. Add tests
4. Document changes
## Success Criteria
- [ ] All tests passing
- [ ] Code reviewed
- [ ] Documentation updatedEdit enhance-prompt.sh to change the template path:
TEMPLATE_FILE="${CLAUDE_PROJECT_DIR}/.claude/prompt-template.md"Remove the hook configuration from .claude/settings.json or set an empty array:
{
"hooks": {
"UserPromptSubmit": []
}
}Modify enhance-prompt.sh to skip certain messages:
# Skip if message contains a flag
if echo "$USER_PROMPT" | grep -q "#skip"; then
echo '{"continue": true}'
exit 0
ficlaude-code-prompt-enhancer/
├── hooks/
│ └── enhance-prompt.sh # Main hook script
├── templates/
│ ├── basic-template.md # Simple template
│ └── advanced-template.md # Multi-phase template
├── examples/
│ └── settings.json # Example configuration
├── docs/
│ ├── INSTALLATION.md # Detailed installation guide
│ ├── USAGE.md # Usage examples
│ └── CONTRIBUTING.md # Contribution guidelines
├── LICENSE
└── README.md
-
Check file permissions:
chmod +x .claude/hooks/enhance-prompt.sh
-
Verify template exists:
ls -la .claude/prompt-template.md
-
Test hook manually:
echo '{"prompt": "test message"}' | bash .claude/hooks/enhance-prompt.sh
-
Check jq is installed:
which jq
- Ensure the template file path is correct
- Check file encoding (should be UTF-8)
- Verify
[PROMPT]placeholder exists in the template
- Verify Python 3 is installed:
python3 --version - Check the auto-generated Python script at
.claude/hooks/enhance-prompt.py
- Team Standardization: Ensure all team members follow the same workflow
- Quality Assurance: Automatically include testing and review requirements
- Project Guidelines: Embed project-specific rules and standards
- Onboarding: Guide new developers with structured task frameworks
Contributions are welcome. Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
See CONTRIBUTING.md for details.
MIT License - see LICENSE for details.