- Published on
Claude Code Hooks Level Up β Measure Time, Read Effort, Automate CI Reviews
Hooks are Claude Code's quietest β and most powerful β feature.
A hook is a shell command that runs automatically before or after Claude uses any tool. In May 2026, three meaningful upgrades landed in the hook system, plus the new claude ultrareview subcommand.
What Are Hooks? A 30-Second Primer
| Hook Type | When It Fires |
|---|---|
| PreToolUse | Immediately before a tool runs |
| PostToolUse | Immediately after a tool succeeds |
| PostToolUseFailure | Immediately after a tool fails |
| Stop | After Claude finishes a response |
PostToolUse Output Replacement β Now for Every Tool
Previously limited to MCP tools only. As of May 2026, it works with every tool.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "python3 sanitize_output.py",
"hookSpecificOutput": {
"updatedToolOutput": true
}
}
]
}
]
}
}
API keys, passwords, personal data β scrubbed before they enter Claude's context.
effort.level β Hooks Can Read the Effort Setting
Now readable via effort.level in hook input JSON or $CLAUDE_EFFORT as an env var.
#!/bin/bash
if [ "$CLAUDE_EFFORT" = "high" ] || [ "$CLAUDE_EFFORT" = "xhigh" ]; then
npm run test:full
else
npm run test:smoke
fi
duration_ms β How Long Did That Tool Actually Take?
A duration_ms field is now included in PostToolUse and PostToolUseFailure hook inputs, recording pure tool runtime in milliseconds.
#!/bin/bash
DURATION=$1
if [ "$DURATION" -gt 5000 ]; then
echo "[SLOW] $(date): ${DURATION}ms - $TOOL_NAME" >> slow-tools.log
fi
claude ultrareview β CI-Ready Code Review
claude ultrareview src/
claude ultrareview src/ --json
claude ultrareview --diff origin/main...HEAD
Exit codes: 0 (completed) / 1 (failed)
Tips for Getting Started
- Start with
duration_msto find bottlenecks - Use
effort.levelto gate expensive hooks - Use PostToolUse output replacement as a security layer
- Make
claude ultrareviewpart of your PR checklist
Sources
- Anthropic, "Claude Code Changelog β May 2026": https://code.claude.com/docs/en/changelog
- Releasebot, "Claude Code Updates by Anthropic β May 2026": https://releasebot.io/updates/anthropic/claude-code
- Simon Willison, "Live blog: Code w/ Claude 2026": https://simonwillison.net/2026/May/6/code-w-claude-2026/