customaize-agent:create-hook▌
neolabhq/context-engineering-kit · updated Apr 8, 2026
MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.
Analyze the project, suggest practical hooks, and create them with proper testing.
Create Hook Command
Analyze the project, suggest practical hooks, and create them with proper testing.
Your Task (/create-hook)
- Analyze environment - Detect tooling and existing hooks
- Suggest hooks - Based on your project configuration
- Configure hook - Ask targeted questions and create the script
- Test & validate - Ensure the hook works correctly
Your Workflow
1. Environment Analysis & Suggestions
Automatically detect the project tooling and suggest relevant hooks:
When TypeScript is detected (tsconfig.json):
- PostToolUse hook: "Type-check files after editing"
- PreToolUse hook: "Block edits with type errors"
When Prettier is detected (.prettierrc, prettier.config.js):
- PostToolUse hook: "Auto-format files after editing"
- PreToolUse hook: "Require formatted code"
When ESLint is detected (.eslintrc.*):
- PostToolUse hook: "Lint and auto-fix after editing"
- PreToolUse hook: "Block commits with linting errors"
When package.json has scripts:
testscript → "Run tests before commits"buildscript → "Validate build before commits"
When a git repository is detected:
- PreToolUse/Bash hook: "Prevent commits with secrets"
- PostToolUse hook: "Security scan on file changes"
Decision Tree:
Project has TypeScript? → Suggest type checking hooks
Project has formatter? → Suggest formatting hooks
Project has tests? → Suggest test validation hooks
Security sensitive? → Suggest security hooks
+ Scan for additional patterns and suggest custom hooks based on:
- Custom scripts in package.json
- Unique file patterns or extensions
- Development workflow indicators
- Project-specific tooling configurations
2. Hook Configuration
Start by asking: "What should this hook do?" and offer relevant suggestions from your analysis.
Then understand the context from the user's description and only ask about details you're unsure about:
-
Trigger timing: When should it run?
PreToolUse: Before file operations (can block)PostToolUse: After file operations (feedback/fixes)UserPromptSubmit: Before processing requests- Other event types as needed
-
Tool matcher: Which tools should trigger it? (
Write,Edit,Bash,*etc) -
Scope:
global,project, orproject-local -
Response approach:
- Exit codes only: Simple (exit 0 = success, exit 2 = block in PreToolUse)
- JSON response: Advanced control (blocking, context, decisions)
- Guide based on complexity: simple pass/fail → exit codes, rich feedback → JSON
-
Blocking behavior (if relevant): "Should this stop operations when issues are found?"
- PreToolUse: Can block operations (security, validation)
- PostToolUse: Usually provide feedback only
-
Claude integration (CRITICAL): "Should Claude Code automatically see and fix issues this hook detects?"
- If YES: Use
additionalContextfor error communication - If NO: Use
suppressOutput: truefor silent operation
- If YES: Use
-
Context pollution: "Should successful operations be silent to avoid noise?"
- Recommend YES for formatting, routine checks
- Recommend NO for security alerts, critical errors
-
File filtering: "What file types should this hook process?"
3. Hook Creation
You should:
- Create hooks directory:
~/.claude/hooks/or.claude/hooks/based on scope - Generate script: Create hook script with:
- Proper shebang and executable permissions
- Project-specific commands (use detected config paths)
- Comments explaining the hook's purpose
- Update settings: Add hook configuration to appropriate settings.json
- Use absolute paths: Avoid relative paths to scripts and executables. Use
$CLAUDE_PROJECT_DIRto reference project root - Offer validation: Ask if the user wants you to test the hook
Key Implementation Standards:
- Read JSON from stdin (never use argv)
- Use top-level
additionalContext/systemMessagefor Claude communication - Include
suppressOutput: truefor successful operations - Provide specific error counts and actionable feedback
- Focus on changed files rather than entire codebase
- Support common development workflows
⚠️ CRITICAL: Input/Output Format
This is where most hook implementations fail. Pay extra attention to:
- Input: Reading JSON from stdin correctly (not argv)
- Output: Using correct top-level JSON structure for Claude communication
- Documentation: Consulting official docs for exact schemas when in doubt
4. Testing & Validation
CRITICAL: Test both happy and sad paths:
Happy Path Testing:
- Test expected success scenario - Create conditions where hook should pass
- Examples: TypeScript (valid code), Linting (formatted code), Security (safe commands)
Sad Path Testing: 2. Test expected failure scenario - Create conditions where hook should fail/warn
- Examples: TypeScript (type errors), Linting (unformatted code), Security (dangerous operations)
Verification Steps: 3. Verify expected behavior: Check if it blocks/warns/provides context as intended
Example Testing Process:
- For a hook preventing file deletion: Create a test file, attempt the protected action, and verify the hook prevents it
If Issues Occur, you should:
- Check hook registration in settings
- Verify script permissions (
chmod +x) - Test with simplified version first
- Debug with detailed hook execution analysis
Hook Templates
Type Checking (PostToolUse)
#!/usr/bin/env node
// Read stdin JSON, check .ts/.tsx files only
// Run: npx tsc --noEmit --pretty
// Output: JSON with additionalContext for errors
Auto-formatting (PostToolUse)
#!/usr/bin/env node
// Read stdin JSON, check supported file types
// Run: npx prettier --write [file]
// Output: JSON with suppressOutput: true
Security Scanning (PreToolUse)
#!/bin/bash
# Read stdin JSON, check for secrets/keys
# Block if dangerous patterns found
# Exit 2 to block, 0 to continue
Complete templates available at: https://docs.claude.com/en/docs/claude-code/hooks#examples
Quick Reference
📖 Official Docs: https://docs.claude.com/en/docs/claude-code/hooks.md
Common Patterns:
- stdin input:
JSON.parse(process.stdin.read()) - File filtering: Check extensions before processing
- Success response:
{continue: true, suppressOutput: true} - Error response:
{continue: true, additionalContext: "error details"} - Block operation:
exit(2)in PreToolUse hooks
Hook Types by Use Case:
- Code Quality: PostToolUse for feedback and fixes
- Security: PreToolUse to block dangerous operations
- CI/CD: PreToolUse to validate before commits
- Development: PostToolUse for automated improvements
Hook Execution Best Practices:
- Hooks run in parallel according to official documentation
- Design for independence since execution order isn't guaranteed
- Plan hook interactions carefully when multiple hooks affect the same files
Success Criteria
✅ Hook created successfully when:
- Script has executable permissions
- Registered in correct settings.json
- Responds correctly to test scenarios
- Integrates properly with Claude for automated fixes
- Follows project conventions and detected tooling
Result: The user gets a working hook that enhances their development workflow with intelligent automation and quality checks.
Documentation Index
Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt Use this file to discover all available pages before exploring further.
Automate workflows with hooks
Run shell commands automatically when Claude Code edits files, finishes tasks, or needs input. Format code, send notifications, validate commands, and enforce project rules.
Hooks are user-defined shell commands that execute at specific points in Claude Code's lifecycle. They provide deterministic control over Claude Code's behavior, ensuring certain actions always happen rather than relying on the LLM to choose to run them. Use hooks to enforce project rules, automate repetitive tasks, and integrate Claude Code with your existing tools.
For decisions that require judgment rather than deterministic rules, you can also use prompt-based hooks or agent-based hooks that use a Claude model to evaluate conditions.
For other ways to extend Claude Code, see skills for giving Claude additional instructions and executable commands, subagents for running tasks in isolated contexts, and plugins for packaging extensions to share across projects.
Set up your first hook
The fastest way to create a hook is through the /hooks interactive menu in Claude Code. This walkthrough creates a desktop notification hook, so you get alerted whenever Claude is waiting for your input instead of watching the terminal.
<Tabs>
<Tab title="macOS">
Uses [`osascript`](https://ss64.com/mac/osascript.html) to trigger a native macOS notification through AppleScript:
```
osascript -e 'display notification "Claude Code needs your attention" with title "Claude Code"'
```
</Tab>
<Tab title="Linux">
Uses `notify-send`, which is pre-installed on most Linux desktops with a notification daemon:
```
notify-send 'Claude Code' 'Claude Code needs your attention'
```
</Tab>
<Tab title="Windows (PowerShell)">
Uses PowerShell to show a native message box through .NET's Windows Forms:
```
powershell.exe -Command "[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); [System.Windows.Forms.MessageBox]::Show('Claude Code needs your attention', 'Claude Code')"
```
</Tab>
</Tabs>
What you can automate
Hooks let you run code at key points in Claude Code's lifecycle: format files after edits, block commands before they execute, send notifications when Claude needs input, inject context at session start, and more. For the full list of hook events, see the Hooks reference.
Each example includes a ready-to-use configuration block that you add to a settings file. The most common patterns:
- Get notified when Claude needs input
- Auto-format code after edits
- Block edits to protected files
- Re-inject context after compaction
Get notified when Claude needs input
Get a desktop notification whenever Claude finishes working and needs your input, so you can switch to other tasks without checking the terminal.
This hook uses the Notification event, which fires when Claude is waiting for input or permission. Each tab below uses the platform's native notification command. Add this to ~/.claude/settings.json, or use the interactive walkthrough above to configure it with /hooks:
Auto-format code after edits
Automatically run Prettier on every file Claude edits, so formatting stays consistent without manual intervention.
This hook uses the PostToolUse event with an Edit|Write matcher, so it runs only after file-editing tools. The command extracts the edited file path with jq and passes it to Prettier. Add this to .claude/settings.json in your project root:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path' | xargs npx prettier --write"
}
]
}
]
}
}
Block edits to protected files
Prevent Claude from modifying sensitive files like .env, package-lock.json, or anything in .git/. Claude receives feedback explaining why the edit was blocked, so it can adjust its approach.
This example uses a separate script file that the hook calls. The script checks the target file path against a list of protected patterns and exits with code 2 to block the edit.
```bash theme={null}
#!/bin/bash
# protect-files.sh
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
PROTECTED_PATTERNS=(".env" "package-lock.json" ".git/")
for pattern in "${PROTECTED_PATTERNS[@]}"; do
if [[ "$FILE_PATH" == *"$pattern"* ]]; then
echo "Blocked: $FILE_PATH matches protected pattern '$pattern'" >&2
exit 2
fi
done
exit 0
```
```bash theme={null}
chmod +x .claude/hooks/protect-files.sh
```
```json theme={null}
{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/protect-files.sh"
}
]
}
]
}
}
```
Re-inject context after compaction
When Claude's context window fills up, compaction summarizes the conversation to free space. This can lose important details. Use a SessionStart hook with a compact matcher to re-inject critical context after every compaction.
Any text your command writes to stdout is added to Claude's context. This example reminds Claude of project conventions and recent work. Add this to .claude/settings.json in your project root:
{
"hooks": {
"SessionStart": [
{
"matcher": "compact",
"hooks": [
{
"type": "command",
"command": "echo 'Reminder: use Bun, not npm. Run bun test before committing. Current sprint: auth refactor.'"
}
]
}
]
How to use customaize-agent:create-hook on Cursor
AI-first code editor with Composer
Prerequisites
Before installing skills in Cursor, ensure your development environment meets these requirements:
- ›Cursor installed and configured on your development machine
- ›Node.js version 16.0+ with npm package manager (verify with
node --version) - ›Active project directory or workspace where you want to add customaize-agent:create-hook
Execute installation command
Execute the skills CLI command in your project's root directory to begin installation:
The skills CLI fetches customaize-agent:create-hook from GitHub repository neolabhq/context-engineering-kit and configures it for Cursor.
Select Cursor when prompted
The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:
Verify installation
Confirm successful installation by checking the skill directory location:
Reload or restart Cursor to activate customaize-agent:create-hook. Access the skill through slash commands (e.g., /customaize-agent:create-hook) or your agent's skill management interface.
Security & Verification Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.
List & Monetize Your Skill
Submit your Claude Code skill and start earning
Use Cases▌
Task Automation & Efficiency
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Knowledge Enhancement
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Quality Improvement
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
Implementation Guide▌
Prerequisites
- ›Claude Desktop or compatible AI client with skill support
- ›Clear understanding of task or problem to solve
- ›Willingness to iterate and refine outputs
Time Estimate
15-45 minutes depending on use case complexity
Installation Steps
- 1.Install skill using provided installation command
- 2.Test with simple use case relevant to your work
- 3.Evaluate output quality and relevance
- 4.Iterate on prompts to improve results
- 5.Integrate into regular workflow if valuable
Common Pitfalls
- ⚠Expecting perfect results without iteration
- ⚠Not providing enough context in prompts
- ⚠Using skill for tasks outside its intended scope
- ⚠Accepting outputs without review and validation
Best Practices▌
✓ Do
- +Start with clear, specific prompts
- +Provide relevant context and constraints
- +Review and refine all outputs before using
- +Iterate to improve output quality
- +Document successful prompt patterns
✗ Don't
- −Don't use without understanding skill limitations
- −Don't skip validation of outputs
- −Don't share sensitive information in prompts
- −Don't expect skill to replace human judgment
💡 Pro Tips
- ★Be specific about desired format and style
- ★Ask for multiple options to choose from
- ★Request explanations to understand reasoning
- ★Combine AI efficiency with human expertise
When to Use This▌
✓ Use When
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid When
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
Learning Path▌
- 1Familiarize yourself with skill capabilities and limitations
- 2Start with low-risk, non-critical tasks
- 3Progress to more complex and valuable use cases
- 4Build expertise through regular use and experimentation
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
Ratings
4.6★★★★★34 reviews- ★★★★★Shikha Mishra· Dec 24, 2024
Keeps context tight: customaize-agent:create-hook is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Charlotte Menon· Dec 24, 2024
customaize-agent:create-hook has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Isabella Abebe· Dec 16, 2024
Keeps context tight: customaize-agent:create-hook is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Sakshi Patil· Nov 23, 2024
We added customaize-agent:create-hook from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Meera Bansal· Nov 19, 2024
customaize-agent:create-hook fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Yash Thakker· Nov 15, 2024
Registry listing for customaize-agent:create-hook matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Charlotte Bansal· Nov 15, 2024
Useful defaults in customaize-agent:create-hook — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Isabella Taylor· Nov 7, 2024
Registry listing for customaize-agent:create-hook matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Li Agarwal· Oct 26, 2024
customaize-agent:create-hook reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Chaitanya Patil· Oct 14, 2024
customaize-agent:create-hook fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
showing 1-10 of 34