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 TypeWhen It Fires
PreToolUseImmediately before a tool runs
PostToolUseImmediately after a tool succeeds
PostToolUseFailureImmediately after a tool fails
StopAfter 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

  1. Start with duration_ms to find bottlenecks
  2. Use effort.level to gate expensive hooks
  3. Use PostToolUse output replacement as a security layer
  4. Make claude ultrareview part of your PR checklist

Sources

Claude Code Hooks Level Up β€” Measure Time, Read Effort, Automate CI Reviews | MINSSAM.COM