HookStack
All guides

Claude Code Hooks vs Slash Commands vs Prompt Instructions

5 min read · Reviewed 2026-06-12

There are three ways to shape how Claude Code behaves: prompt instructions, slash commands, and hooks. They look interchangeable but they sit at very different levels of control — and only one of them is guaranteed to run.

This guide compares all three so you know which tool to reach for, and how to combine them.

Hooks vs slash commands vs prompt instructions: what is the difference?

Prompt instructions are text the model reads and usually follows. Slash commands are reusable prompts you invoke on demand inside the conversation. Hooks are scripts that fire outside the model on lifecycle events. The first two steer the AI; the third constrains it.

What are prompt instructions (CLAUDE.md)?

Prompt instructions live in your prompt or in a CLAUDE.md file the model loads as context. They are perfect for soft guidance — coding style, tone, architectural preferences — but they are probabilistic. The model may follow them, may interpret them loosely, or may decide an exception applies.

What are slash commands?

Slash commands are interactive: you type something like /gen-test-unit and the model reads the command and acts on it inside the conversation. They are great for on-demand tasks you trigger yourself. But because the model interprets and executes them, they are still inside the probabilistic loop — and they consume context.

What makes hooks different?

Hooks are Node.js scripts that fire unconditionally on lifecycle events (PreToolUse, PostToolUse, Stop…). The model never sees them, never decides whether to run them, and cannot skip them. They cost zero tokens because they run in a separate process. That guarantee is what makes them the right tool for anything that must always happen.

When should you use each?

  • Prompt instructions / CLAUDE.md → soft guidance and preferences.
  • Slash commands → on-demand, interactive tasks you trigger.
  • Hooks → guarantees: guardrails, gates, and automation that must run every time.

Can you combine them?

Yes — and the best setups do. Use CLAUDE.md to set direction, slash commands for repeatable tasks, and hooks to enforce the non-negotiables (run tests, block secrets, protect main). They are layers, not alternatives.

Frequently asked questions

Are hooks better than slash commands?
They do different jobs. Slash commands are interactive tasks you trigger; hooks are guarantees that fire automatically and cannot be skipped. Use both.
Do hooks replace CLAUDE.md?
No. CLAUDE.md is great for soft guidance the model interprets. Hooks enforce the rules that must hold regardless of what the model decides.
Do slash commands consume tokens?
Yes — commands are part of the conversation and consume context. Hooks run outside the model and cost zero tokens.

Related hooks

Sources