◉CLAUDE LABJP
●2.1.301 — Adds the vim % motion, LaTeX math rendering in the VS Code panel, and a retry-watchdog limit for usage-limit waits (10/15)●2.1.299 — Conversations over 200K tokens left idle about 54 minutes get compacted; MCP allow rules now match only the server they name●SONNET 4.5 — Retires on the Claude API on 11/30, 45 days left. Migrate to Sonnet 5.5●WINDOWS — Reports say hooks break silently only on Japanese-locale Windows; check the character encoding first●FAST MODE — Opus 5.5 fast mode is out of research preview and no longer needs the beta header (10/15)●NEW — I Put a Ten-Line Promise File at the To…●2.1.301 — Adds the vim % motion, LaTeX math rendering in the VS Code panel, and a retry-watchdog limit for usage-limit waits (10/15)●2.1.299 — Conversations over 200K tokens left idle about 54 minutes get compacted; MCP allow rules now match only the server they name●SONNET 4.5 — Retires on the Claude API on 11/30, 45 days left. Migrate to Sonnet 5.5●WINDOWS — Reports say hooks break silently only on Japanese-locale Windows; check the character encoding first●FAST MODE — Opus 5.5 fast mode is out of research preview and no longer needs the beta header (10/15)●NEW — I Put a Ten-Line Promise File at the To…
Articles/Claude Code
⟐ Claude Code/2026-03-24Advanced

Claude Code Hooks— Practical Techniques to Automate Your Dev Workflow

Learn how to automate your development workflow with Claude Code Hooks. From PreToolUse and PostToolUse configuration to automated code review, security checks, and deployment pipeline integration.

claude-code132hooks22automation109workflow41devops

✦ Premium Article

What Are Claude Code Hooks — The Automation Layer That Transforms Your Workflow

Claude Code Hooks let you automatically run custom scripts before and after Claude executes tools. This means you can fully automate code reviews, test runs, security checks, and more — tasks that used to require manual intervention.

In 2026, collaborating with AI assistants is the norm in software development. But shipping AI-generated code straight to production without guardrails is risky. Hooks give you a way to apply consistent quality controls to Claude's output automatically, balancing safety with efficiency.

Hook Structure and Configuration

Claude Code Hooks are defined in .claude/settings.json. There are four hook types available:

// .claude/settings.json
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Edit|Write",
        "hook": {
          "type": "command",
          "command": "bash .claude/hooks/pre-edit-check.sh \"$FILEPATH\""
        }
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hook": {
          "type": "command",
          "command": "bash .claude/hooks/post-edit-lint.sh \"$FILEPATH\""
        }
      }
    ],
    "Notification": [
      {
        "matcher": "",
        "hook": {
          "type": "command",
          "command": "bash .claude/hooks/notify-slack.sh \"$MESSAGE\""
        }
      }
    ],
    "Stop": [
      {
        "matcher": "",
        "hook": {
          "type": "command",
          "command": "bash .claude/hooks/on-stop.sh"
        }
      }
    ]
  }
}

Here's what each hook type does:

PreToolUse — The Gatekeeper Before Execution

Fires before Claude edits files or runs commands. Returning exit code 2 blocks the tool execution entirely, making it ideal for preventing dangerous operations.

PostToolUse — Quality Checks After Execution

Fires immediately after a file edit or command completes. Perfect for automated linting, type checking, and test execution.

Notification — Automated Alert Forwarding

Fires when Claude issues a notification. Useful for Slack alerts, email notifications, or logging.

Stop — Session Cleanup

Fires just before Claude finishes a task and returns its response. Great for logging, cleanup, and summary generation.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦CI/CD pipeline full automation techniques combining Git hooks with Claude Code
✦Automated pre-commit fixes, formatting, security scanning implementation and optimization
✦Automated review process and production deployment validation methodology
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⟐ Claude Code2026-09-02
Two hooks that record every model switch and stop the ones you never agreed to
Build a PostModelSwitch hook that logs every model change and a PreModelSwitch hook that blocks unapproved switches during unattended runs. Complete scripts, measured timings, and the reason the two jobs must stay separate.
⟐ Claude Code2026-08-28
Don't let your verification script's full output flow back through a hook
The check was working the whole time. The conversation was what ran out of room. Measured side by side: 58 bytes from one scan of 833 files, 42KB from another. Which paths actually reach the model, and how to enforce a budget on them.
⟐ Claude Code2026-05-02
Stop the 'old_string is not unique' Error in Claude Code's Edit Tool — A Practical Rewrite Strategy
When Claude Code's Edit tool throws 'old_string is not unique in the file', the root cause is usually that the prompt didn't guarantee a uniquely identifiable target. Here's how to design rewrites that actually stick.