Freeive

claude-code·Published 2026.06.01·Views 1

Does AI Sometimes Ignore Your CLAUDE.md? Force "Must-Do" Tasks with /hooks

/hooks shows the hooks that run automatically at specific moments. Unlike CLAUDE.md's "guidance," a hook is "enforcement." Learn how to lock in rules that

Have you ever written "always run the check before committing" in CLAUDE.md (Claude Code's rules file), only to have the AI sometimes skip right past it? CLAUDE.md is, after all, a "request," so there is no guarantee it will be followed 100%. For a rule you really must not miss, you need not guidance but enforcement. /hooks is the command for that. It sets up a rule that runs automatically, no matter what, at a defined moment. It is an advanced feature, so if you are just getting started, it is enough to know that "there is something like this for rules you must keep."

Definition

/hooks is a command that shows the "hook" settings you have set up to run automatically in specific situations.

A "hook" is an automatic rule that runs no matter what once a defined moment arrives. Just like the word "hook" suggests, it latches on at a specific instant (for example, right before committing) and automatically pulls in and runs the defined command.

Compared to CLAUDE.md, the difference is clear.

  • CLAUDE.md = guidance: A request to "do it this way." The AI looks at the situation and follows it, but can sometimes skip it.
  • Hook = enforcement: A rule that "at this moment, this runs no matter what." It always runs regardless of the AI's judgment.

In other words, "things that absolutely must be kept" are only certain if you set them up as hooks.

How to Use (by difficulty)

Basics — Viewing Hook Settings

Type into the chat box.

/hooks

Once you enter it, a list of the hook settings currently in place appears on screen. It lets you check "which command is set to run automatically at which moment." It will be empty at first, and you use it here to inspect which hooks are in place.

Advanced — Deciding Which Rules to Hook

Setting up a new hook can be requested through conversation. For example, like this.

커밋하기 전에 항상 lint 검사를 자동으로 돌리도록 훅으로 걸어줘

This binds the command "run a lint check" to the moment "right before commit." (Lint is a check that inspects the format and errors in code.) After that, whether the AI forgets or not, the check runs first no matter what every time you commit. You can verify with /hooks that the setting took effect.

Common Pitfall — /hooks Is a "View" Command; Setting One Up Is Configuration

This is an easy point to confuse. Typing /hooks does not create a new hook. /hooks is a command that shows the hooks currently in place.

  • Viewing: /hooks → check current settings.
  • Setting up: Request "set this up as a hook" through conversation, or add it directly to the config file.

And one more thing. Because hooks have strong enforcement power, setting one up wrong can run an unintended command every single time. So it is best to set them up carefully only for things that truly "must always run." There is no need to make a hook for something you only do once in a while.

Real-World Example

Committing without running tests kept happening, so I wrote "run the check before committing" in CLAUDE.md. Even so, it sometimes got skipped. Because it was "guidance," it was not followed 100%. So I went ahead and set it up as a hook.

커밋 전에 자동으로 검사를 실행하는 훅 걸어줘

After that, the check was never once skipped. By fixing it as "enforcement" instead of leaving it to the AI's judgment, the "oh, I missed it this time" moments disappeared. I felt firsthand that rules you must keep should be enforcement, not guidance.

Using It Further

  • Auto-run rules: Force a command to run at a specific moment.
  • Pre-commit checks: Lock in things like "lint and test before commit" so they cannot be broken.
  • Dividing roles with CLAUDE.md: Light recommendations in CLAUDE.md (guidance), things that must never be skipped as hooks (enforcement).
  • Only for must-do tasks: Save it for core rules you do not want to leave to the AI's judgment.

Tip: You do not need to make every rule a hook. Most are fine as CLAUDE.md guidance. Setting just one or two "if this is missed, there is an accident" items as hooks is easier to manage and prevents unintended execution.

Summary

The core fits in one sentence. Things that must be kept should be enforced with hooks, not guidance. CLAUDE.md is a request, so it can sometimes be ignored, but a hook runs no matter what at the defined moment. When you do not want to leave a "must-do task" to the AI's judgment, a hook is the most reliable safeguard.

Based on: Claude Code v2.1.154 (2026.05)

#ClaudeCode#hooks#hook#automation#forced-execution#developer

Comments

Comments 0

Checking sign-in status…

Loading comments…

Recent

More notes.