HaiAI123

Curated Global AI Tools Directory

Industry update
Flat

Claude Code hooks guide: making rules actually run

10/08/2026 — 10/08, 20:21·1 sources (all)·2 reports (all)

Key takeaways

  • A practical guide to Claude Code hooks explains how they run at fixed points in a session, such as before a tool call, after a file edit, wh…

Background & analysis

On October 8, 2026, DEV Community published two tutorials on Claude Code hooks. The first, posted around midday, walks through three complete hooks: one that blocks dangerous commands such as git push --force at the PreToolUse stage, one that scans writes for AWS, Anthropic, and GitHub keys and asks the developer to switch to environment variables, and one that runs the project's Prettier or Biome automatically after PostToolUse. According to the post, hooks are configured in .claude/settings.json and matched by event and tool; a hook receives the event as JSON over stdin, and exiting with code 2 blocks the action, so the behavior does not depend on the model remembering a rule.

The second post, published that evening, explains the mechanism in more detail. Hooks are commands that run at fixed points in a session: before a tool runs, after a file is edited, when a prompt is submitted, and when Claude stops. Unlike a line in CLAUDE.md, a hook is not advice — it always runs, and a PreToolUse hook can block an action outright by exiting with code 2. The article says its content was checked against the hooks guide and reference on 2026-10-05, corresponding to Claude Code 2.1.289, and that the event list has grown to 33. It also notes three recent changes: sessions now start in auto mode by default, mods can override hooks, and Cursor can run Claude Code hooks as well. Neither report specifies when those changes took effect or provides further detail on them.

AI-generated from 2 reports · updated 10 hours ago

Latest turnA practical guide explains how Claude Code hooks work: they run at fixed points in a session — before a tool runs, after a file edit, on prompt submission, and when Claude stops. Unlike advice in CLAUDE.md they always execute, and a PreToolUse hook can block an action by exiting with code 2. It also covers three recent changes: sessions starting in auto mode, mods that can overrule a hook, and Cursor running Claude Code's hooks.

Related AI tools

24-hour heatHeat index 74 · peak 100 · 17h ago
24 hours agonow

Reports on this story headlines open the original

Yesterday
  1. A practical guide explains how Claude Code hooks work: they run at fixed points in a session — before a tool runs, after a file edit, on prompt submission, and when Claude stops. Unlike advice in CLAUDE.md they always execute, and a PreToolUse hook can block an action by exiting with code 2. It also covers three recent changes: sessions starting in auto mode, mods that can overrule a hook, and Cursor running Claude Code's hooks.

    DEV Community · AIAI score 67
  2. A tutorial walks through three Claude Code hooks with full code: one blocks dangerous commands like git push --force at the PreToolUse stage, one scans Write/Edit for AWS, Anthropic and GitHub keys, and one runs Prettier or Biome after PostToolUse. Hooks live in .claude/settings.json, match on event and tool, and exit code 2 blocks the action without relying on the model to remember rules.

    DEV Community · AIAI score 60

Other stories people are talking about

How is heat calculated?About the method

Heat counts how many independent sources covered a story in the last 48 hours: one source counts once no matter how many posts it published, decaying with a 24-hour half-life. What ranks first is what many people are talking about.

This page aggregates public feeds. Headlines and summaries are machine-organized and remain the property of the original authors; verify important facts at the source. If you believe a headline or summary infringes your rights, email the contact address in the footer with the page URL and basis of your claim, and we will remove or replace it after review.

Surge
Discussion rising fast
New
First report within 6 hours
Rising
Still gathering discussion

Back to AI industry updates →