TheoSym

Claude Code

Claude Code hooks: prompts request, hooks rule

Claude Code hooks are commands that run automatically at set points in a session, such as before a tool runs or after a file is edited. A prompt asks Claude to follow a rule. A hook makes the rule happen every time.

Updated September 30, 2026 · By Dr. Sam Sammane

From the TheoSym channel

Claude Code: prompts request, hooks rule

Published September 21, 2026

A 54-second TheoSym short on the difference between asking Claude Code to follow a rule and making it follow the rule with a hook.

Watch on YouTube

Prompts ask, hooks decide

When you write "always run the formatter" in a prompt or a project instruction file, you are making a request. The model usually follows it, and sometimes it does not.

A hook is not a request. It is code that the tool runs at a fixed point, whether or not the model remembers. Use prompts for guidance and hooks for anything you cannot afford to have skipped.

When hooks run

You attach a hook to a moment in the session. Common ones are:

  • Before a tool runs (PreToolUse), where a hook can inspect the action and block it
  • After a tool runs (PostToolUse), for example after Claude edits a file
  • When you submit a prompt, to add context or check the request
  • When Claude finishes, to run checks before you look at the result

Events and settings are documented in the Claude Code hooks guide. Names and options change, so use the guide for current syntax.

What to use hooks for

  • Format or lint every file Claude edits
  • Block edits to protected files such as lock files, secrets and production configuration
  • Run the test suite when Claude says it is done
  • Log every command for an audit trail
  • Send yourself a notification when a long task finishes

How to set one up

  1. Decide which rule must never be skipped. Start with one.
  2. Choose the moment it should run, before or after a tool, or at the end of a task.
  3. Add the hook to your Claude Code settings, at project level if the team should share it.
  4. Trigger it on purpose and confirm it does what you expect, including the failure case.
  5. Keep it fast. A slow hook slows every step of the session.

Treat hooks like code

Hooks run commands on your machine with your permissions. Review them like any script, keep them in version control and be careful with hooks you copy from someone else. Used well, they are the strongest way to put your limits in writing. See our Claude Code best practices for how hooks fit with plan mode and skills.

Claude Code hooks: common questions

What are Claude Code hooks?

Commands that Claude Code runs automatically at set points in a session, such as before a tool call, after an edit or when a task finishes. They apply your rules every time.

What is the difference between a hook and a prompt?

A prompt is a request the model may or may not follow. A hook is code that always runs at its trigger point, so it enforces the rule.

Can a hook stop Claude from doing something?

Yes. A hook that runs before a tool call can inspect the action and block it, for example an edit to a protected file. The Claude Code hooks guide describes how a hook signals a block.

Where do I configure Claude Code hooks?

In the Claude Code settings. Project-level settings are shared with your team through version control, and user-level settings apply to you only.

Are hooks safe?

They run commands with your permissions, so review them like any script and only use hooks you understand.

Want an agent you can trust in production?

TheoSym ships production agents with the eval suite, MCP tools and harness included. Bring one real workflow to a 15-minute call with Sam and see what building it would involve.

Book 15 minutes with Sam