Back to blog
March 12, 2026Shadman Rahman

Hooks: Set It Up Once, Never Think About It Again

Hooks run automatically before or after Claude Code actions. Automate formatting, linting, and validation.

What if every file Claude Code creates was automatically formatted? What if every commit message was automatically validated? What if dangerous commands were automatically blocked?

That's hooks. And once you set them up, you never think about them again.

What Are Hooks?

Hooks are scripts that run automatically at specific points in Claude Code's execution:

  • PreToolUse — runs before Claude uses a tool (write file, run command)
  • PostToolUse — runs after a tool completes (auto-format, validate)
  • Stop — runs when a session ends (final checks, cleanup)

Three Hooks Everyone Should Have

1. Auto-format on write. Every time Claude writes a file, run your formatter (Prettier, Black, gofmt). No more "can you format that?" messages.

2. Lint on write. Every file gets linted automatically. Catch issues before you even review the output.

3. Dangerous command blocker. Prevent rm -rf, git push --force, and other commands you never want Claude to run unsupervised.

How to Set Them Up

Hooks go in your .claude/settings.json. Each hook specifies when it runs and what command to execute. The setup takes 5 minutes.

Once configured, hooks are invisible. They just work. You stop worrying about formatting, linting, and safety because the system handles it.

That's the philosophy: automate the repetitive, focus on the creative. Read the full hooks guide to get started.

Stay in the loop

New guides, templates, and tips. No spam. Unsubscribe anytime.