Templates are pre-configured hook collections that solve common automation needs. Like a ship's armory stocked with proven weapons, Eyelet's template library provides battle-tested configurations ready for deployment.
- Overview
- Available Templates
- Using Templates
- Template Structure
- Creating Custom Templates
- Sharing Templates
- Example Templates
- Best Practices
Eyelet templates are curated collections of hooks designed to work together for specific use cases. They provide:
- Quick deployment - Install complete hook configurations with a single command
- Parameterization - Customize templates with variables during installation
- Version control - Track template versions and updates
- Community sharing - Export and share templates with other users
Templates are deployed into action to configure your hooks.
Protect your development environment from dangerous operations.
- safety-check - Prevents dangerous commands from executing
- Blocks
rm -rf /, fork bombs, and pipe-to-shell attacks - Validates file paths and operations
- Customizable dangerous pattern matching
- Blocks
Track and analyze Claude Code's behavior.
- logger - Universal logging for all tool usage
- Tracks command history and performance
- Structured JSON logging with daily rotation
- Configurable output locations
Enhance your development processes.
-
enhancer - Output enhancement and formatting
- Formats command outputs for readability
- Filters sensitive information
- Adds metadata and annotations
-
workflow - Multi-step workflow coordination
- Sequential task execution
- Conditional logic based on results
- State persistence between steps
# View all templates in your armory
eyelet template list
# Filter by category
eyelet template list --category security# Inspect the ordinance
eyelet template show loggerOutput shows:
- Template metadata (name, author, version)
- Hook configurations
- Required variables
- Example use cases
# Load the cannons! (Install to project)
eyelet template install safety-check
# Install to user configuration
eyelet template install logger --scope user
# Install with custom variables
eyelet template install logger --var log_location=/var/log/claude-hooksDuring installation, Eyelet will:
- Prompt for any required variables not provided
- Apply variable substitution to hook configurations
- Add hooks to your configuration
- Report successful deployment
# Share the wealth
eyelet template export my-custom-template ./my-template.json# Bring aboard new ordinance
eyelet template import ./downloaded-template.jsonTemplates are JSON files with the following structure:
{
"id": "safety-check",
"name": "Safety Check Hook",
"description": "Prevents dangerous commands from executing",
"category": "security",
"version": "1.0.0",
"author": "Eyelet Team",
"tags": ["safety", "bash", "security"],
"variables": {
"dangerous_patterns": [
"rm -rf /",
":(){ :|:& };:"
],
"block_message": "Command blocked for safety"
},
"hooks": [
{
"id": "block-dangerous-commands",
"type": "PreToolUse",
"enabled": true,
"description": "Block dangerous bash commands",
"matcher": {
"type": "tool",
"pattern": "Bash"
},
"handler": {
"type": "script",
"path": "~/.eyelet/handlers/safety-check.py"
}
}
]
}- id: Unique identifier (lowercase, no spaces)
- name: Human-readable name
- description: What the template does
- category: Template category (security, monitoring, development, testing, custom)
- version: Semantic version number
- author: Template creator (optional)
- tags: Searchable tags (optional)
- variables: Configurable parameters with defaults
- hooks: Array of hook configurations
# Forge new weapons
eyelet template createThe interactive wizard will guide you through:
- Basic template information
- Variable definitions
- Hook configurations
- Testing and validation
Create a JSON file following the template structure:
{
"id": "git-workflow",
"name": "Git Workflow Automation",
"description": "Automate git operations with safety checks",
"category": "development",
"version": "1.0.0",
"variables": {
"auto_commit": true,
"commit_prefix": "[AUTO]"
},
"hooks": [
{
"id": "pre-commit-check",
"type": "PreToolUse",
"enabled": true,
"matcher": {
"type": "tool",
"pattern": "Bash"
},
"handler": {
"type": "inline",
"code": "# Check for git operations\nif [[ $TOOL_INPUT == *\"git commit\"* ]]; then\n echo \"Validating commit...\"\nfi"
}
}
]
}Variables allow customization during installation:
"variables": {
"log_dir": "~/.eyelet/logs", // String with default
"max_file_size": 1048576, // Number (1MB)
"enable_filtering": true, // Boolean
"allowed_commands": ["ls", "cat"] // Array
}Variables are replaced in:
- Hook handler paths
- Inline script code
- Configuration values
- Matcher patterns
Share your templates with the Eyelet community:
-
Export your template:
eyelet template export my-awesome-template ./my-template.json -
Test thoroughly:
- Install in a clean environment
- Verify all hooks work correctly
- Document any prerequisites
-
Share via:
- GitHub repositories
- Gist snippets
- Community forums
- Pull requests to official templates
For sharing multiple templates:
my-eyelet-templates/
├── README.md
├── templates/
│ ├── security/
│ │ ├── enhanced-safety.json
│ │ └── audit-logger.json
│ ├── development/
│ │ ├── pr-automation.json
│ │ └── test-runner.json
│ └── monitoring/
│ └── performance-tracker.json
└── handlers/
├── enhanced-safety.py
└── pr-automation.sh
Complete template for comprehensive logging:
{
"id": "universal-logger",
"name": "Universal Logging System",
"description": "Log all Claude Code interactions with structured output",
"category": "monitoring",
"version": "2.0.0",
"author": "Eyelet Team",
"tags": ["logging", "monitoring", "analytics"],
"variables": {
"log_directory": "~/.eyelet/logs",
"log_format": "jsonl",
"include_context": true,
"rotation_days": 7
},
"hooks": [
{
"id": "pre-tool-logger",
"type": "PreToolUse",
"enabled": true,
"description": "Log tool invocations",
"handler": {
"type": "script",
"path": "~/.eyelet/handlers/universal-logger.py",
"args": ["--pre", "--dir", "{{log_directory}}"]
}
},
{
"id": "post-tool-logger",
"type": "PostToolUse",
"enabled": true,
"description": "Log tool results",
"handler": {
"type": "script",
"path": "~/.eyelet/handlers/universal-logger.py",
"args": ["--post", "--dir", "{{log_directory}}"]
}
}
]
}Handler script (universal-logger.py):
#!/usr/bin/env python3
"""Universal logging handler for Eyelet"""
import json
import sys
import argparse
from datetime import datetime, timezone
from pathlib import Path
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--pre', action='store_true')
parser.add_argument('--post', action='store_true')
parser.add_argument('--dir', default='~/.eyelet/logs')
args = parser.parse_args()
# Read hook input
input_data = json.load(sys.stdin)
# Create log entry
log_entry = {
'timestamp': datetime.now(timezone.utc).isoformat(),
'hook_type': 'PreToolUse' if args.pre else 'PostToolUse',
'tool_name': input_data.get('tool_name'),
'tool_input': input_data.get('tool_input'),
'context': input_data.get('context', {})
}
# Write to log file
log_dir = Path(args.dir).expanduser()
log_dir.mkdir(parents=True, exist_ok=True)
log_file = log_dir / f"{datetime.now():%Y-%m-%d}.jsonl"
with open(log_file, 'a') as f:
f.write(json.dumps(log_entry) + '\n')
# Allow execution
sys.exit(0)
if __name__ == '__main__':
main()Integrate with git pre-commit hooks:
{
"id": "git-integration",
"name": "Git Hooks Integration",
"description": "Validate and enhance git operations",
"category": "development",
"version": "1.0.0",
"variables": {
"check_branch": true,
"protected_branches": ["main", "master", "production"],
"require_issue_number": true
},
"hooks": [
{
"id": "git-commit-validator",
"type": "PreToolUse",
"enabled": true,
"matcher": {
"type": "tool",
"pattern": "Bash"
},
"handler": {
"type": "inline",
"code": "#!/bin/bash\n# Validate git commits\nif [[ \"$TOOL_INPUT\" =~ git\\ commit ]]; then\n BRANCH=$(git branch --show-current)\n if [[ \" {{protected_branches}} \" =~ \" $BRANCH \" ]]; then\n echo \"Error: Cannot commit directly to $BRANCH\" >&2\n exit 2\n fi\nfi\nexit 0"
}
}
]
}Automated security checks:
{
"id": "security-scanner",
"name": "Security Scanner",
"description": "Scan for security issues in code operations",
"category": "security",
"version": "1.2.0",
"tags": ["security", "scanning", "secrets"],
"variables": {
"scan_patterns": [
"password\\s*=",
"api[_-]?key\\s*=",
"secret\\s*=",
"token\\s*="
],
"scan_extensions": [".py", ".js", ".env", ".config"]
},
"hooks": [
{
"id": "secret-scanner",
"type": "PreToolUse",
"enabled": true,
"matcher": {
"type": "tool",
"pattern": "Write|Edit"
},
"handler": {
"type": "script",
"path": "~/.eyelet/handlers/secret-scanner.py"
}
}
]
}Enforce code quality standards:
{
"id": "code-quality",
"name": "Code Quality Enforcer",
"description": "Run linters and formatters automatically",
"category": "development",
"version": "1.0.0",
"variables": {
"python_formatter": "black",
"js_linter": "eslint",
"auto_fix": true
},
"hooks": [
{
"id": "python-formatter",
"type": "PostToolUse",
"enabled": true,
"matcher": {
"type": "and",
"conditions": [
{"type": "tool", "pattern": "Write|Edit"},
{"type": "path", "pattern": ".*\\.py$"}
]
},
"handler": {
"type": "command",
"command": "{{python_formatter}} {{file_path}}"
}
}
]
}- Single Responsibility: Each template should solve one specific problem well
- Sensible Defaults: Provide good default values for variables
- Clear Documentation: Include detailed descriptions and examples
- Version Control: Use semantic versioning for template updates
- Error Handling: Templates should fail gracefully with helpful messages
- Use descriptive names:
log_directorynotdir - Follow naming conventions:
snake_casefor variables - Group related variables with prefixes:
git_check_branch,git_protected_branches
- Order hooks by execution phase (Pre before Post)
- Group related hooks together
- Use consistent naming patterns for hook IDs
- Include clear descriptions for each hook
Before sharing:
- Test in isolation with minimal configuration
- Test with various variable combinations
- Verify error handling for edge cases
- Document any system requirements
- Include example usage in documentation
- Never include sensitive data in templates
- Use variables for paths and credentials
- Validate all user inputs in handlers
- Prefer fail-open for safety-critical hooks
- Document security implications clearly
- Keep handlers lightweight and fast
- Use appropriate matchers to minimize overhead
- Cache expensive operations when possible
- Log asynchronously for high-volume hooks
- Monitor resource usage of installed templates
- Identify the need: What problem does this template solve?
- Design the solution: Which hooks and handlers are needed?
- Create minimal version: Start with basic functionality
- Test thoroughly: Install and verify behavior
- Add variables: Make it customizable
- Document usage: Include examples and edge cases
- Share with community: Export and publish
Remember: Good templates are like well-maintained weapons in a ship's armory - reliable, tested, and ready for action when needed!