Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Claude Code hook system for pre/post tool execution. Triggers on: hooks, PreToolUse, PostToolUse, hook script, tool validation, audit logging.
.claude/skills/aiskillstore-claude-code-hooks/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✗→✓ | ▲ Improved | -6% | 0% |
| case-01 | ✗→✓ | ▲ Improved | -18% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 7% | 0% |
| case-09 | ✗→✓ | ▲ Improved | -45% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 78% | 0% |
Execute custom scripts before/after Claude Code tool invocations.
| Event | When | Has Matcher | |-------|------|-------------| | PreToolUse | Before tool execution | Yes | | PostToolUse | After tool completes | Yes | | PermissionRequest | Permission dialog shown | Yes | | Notification | Notifications sent | Yes | | UserPromptSubmit | User submits prompt | No | | Stop | Agent finishes | No | | SubagentStop | Subagent finishes | No | | PreCompact | Before context compaction | No | | SessionStart | Session begins/resumes | No | | SessionEnd | Session ends | No |
Add to ~/.claude/settings.json or .claude/settings.local.json:
json{ "hooks": { "PreToolUse": [{ "matcher": "Bash", "hooks": [{ "type": "command", "command": "$CLAUDE_PROJECT_DIR/hooks/validate.sh", "timeout": 5000 }] }] } }
| Pattern | Matches | |---------|---------| | "Write" | Only Write tool | | "*" or "" | All tools | | "mcp__*" | All MCP tools | | "Bash" | Bash commands |
bash#!/bin/bash # Receives JSON via stdin: { "tool_name": "...", "tool_input": {...} } INPUT=$(cat) TOOL=$(echo "$INPUT" | jq -r '.tool_name') # Exit codes: # 0 = Success (continue) # 2 = Block with error (stderr shown to Claude) # Other = Non-blocking error
| Use Case | Event | Example | |----------|-------|---------| | Validate inputs | PreToolUse | Block dangerous commands | | Audit logging | PostToolUse | Log all tool usage | | Custom approval | PermissionRequest | Slack notification | | Session init | SessionStart | Load project context |
"$VAR" not $VAR.. traversal)$CLAUDE_PROJECT_DIR for pathsbash# Debug hook loading claude --debug # List registered hooks /hooks # Test script manually echo '{"tool_name":"Bash"}' | ./hooks/validate.sh
./references/hook-events.md - All events with input/output schemas./references/configuration.md - Advanced config patterns./references/security-patterns.md - Production securitySee Also: claude-code-debug for troubleshooting, claude-code-headless for CLI automation
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-03 | fail→pass | 11,523 | 6,048 | -48% | 1 | 1 | 0% | 1,958 | 1,850 | -6% | 0 | 0 | — |
case-04 | pass→pass | 12,646 | 18,346 | +45% | 1 | 1 | 0% | 1,976 | 2,655 | +34% | 0 | 0 | — |
case-01 | fail→pass | 12,551 | 4,823 | -62% | 1 | 1 | 0% | 2,004 | 1,653 | -18% | 0 | 0 | — |
case-02 | pass→pass | 15,733 | 9,641 | -39% | 1 | 1 | 0% | 2,940 | 2,404 | -18% | 0 | 0 | — |
case-05 | pass→pass | 10,362 | 7,944 | -23% | 1 | 1 | 0% | 1,933 | 2,185 | +13% | 0 | 0 | — |
case-06 | pass→pass | 10,749 | 8,933 | -17% | 1 | 1 | 0% | 1,885 | 2,349 | +25% | 0 | 0 | — |
case-07 | pass→pass | 8,842 | 2,322 | -74% | 1 | 1 | 0% | 1,413 | 1,116 | -21% | 0 | 0 | — |
case-08 | fail→pass | 6,763 | 2,879 | -57% | 1 | 1 | 0% | 1,099 | 1,177 | +7% | 0 | 0 | — |
case-09 | fail→pass | 11,069 | 2,190 | -80% | 1 | 1 | 0% | 1,953 | 1,078 | -45% | 0 | 0 | — |
case-10 | pass→pass | 7,786 | 4,197 | -46% | 1 | 1 | 0% | 1,422 | 1,410 | -1% | 0 | 0 | — |
case-11 | pass→pass | 6,980 | 2,659 | -62% | 1 | 1 | 0% | 1,127 | 1,145 | +2% | 0 | 0 | — |
case-12 | pass→pass | 10,331 | 3,195 | -69% | 1 | 1 | 0% | 1,846 | 1,246 | -33% | 0 | 0 | — |
case-13 | pass→pass | 6,821 | 2,345 | -66% | 1 | 1 | 0% | 882 | 1,116 | +27% | 0 | 0 | — |
case-14 | pass→pass | 10,004 | 2,997 | -70% | 1 | 1 | 0% | 1,719 | 1,181 | -31% | 0 | 0 | — |
case-15 | pass→pass | 10,903 | 2,282 | -79% | 1 | 1 | 0% | 1,855 | 1,091 | -41% | 0 | 0 | — |
case-16 | pass→pass | 5,731 | 2,725 | -52% | 1 | 1 | 0% | 901 | 1,124 | +25% | 0 | 0 | — |
case-17 | pass→pass | 16,473 | 4,679 | -72% | 1 | 1 | 0% | 1,552 | 1,528 | -2% | 0 | 0 | — |
case-18 | fail→pass | 12,542 | 6,488 | -48% | 1 | 1 | 0% | 988 | 1,757 | +78% | 0 | 0 | — |
case-19 | pass→pass | 7,968 | 4,613 | -42% | 1 | 1 | 0% | 1,410 | 1,549 | +10% | 0 | 0 | — |
case-20 | pass→pass | 3,515 | 2,250 | -36% | 1 | 1 | 0% | 562 | 1,069 | +90% | 0 | 0 | — |
case-21 | pass→pass | 15,689 | 12,400 | -21% | 1 | 1 | 0% | 2,765 | 3,099 | +12% | 0 | 0 | — |
case-22 | fail→pass | 8,169 | 5,416 | -34% | 1 | 1 | 0% | 1,351 | 1,707 | +26% | 0 | 0 | — |
case-23 | fail→pass | 9,151 | 5,129 | -44% | 1 | 1 | 0% | 1,572 | 1,689 | +7% | 0 | 0 | — |
case-24 | pass→pass | 7,374 | 3,374 | -54% | 1 | 1 | 0% | 1,284 | 1,372 | +7% | 0 | 0 | — |
case-25 | pass→pass | 9,721 | 3,241 | -67% | 1 | 1 | 0% | 1,549 | 1,222 | -21% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 25 cases were attempted. The headline lift of +28 percentage points is the difference between those two pass rates over the 25 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.