Claude Code hooks vs skills: what each does and when to use it
Use a hook when something must happen every time, like formatting each edited file or blocking edits to .env: Claude Code runs it whether or not the model remembers. Use a skill when the agent needs to know how to do a job: it is guidance the model loads when a task matches. Many good setups pair the two.
| Hook | Skill | |
|---|---|---|
| What it is | A shell command run at a fixed event | A folder with SKILL.md instructions |
| Who decides it runs | Claude Code, every time the event fires | The model, when the task matches the description (or you, with /skill-name) |
| Can it block an action | Yes: exit code 2 on PreToolUse blocks the tool call | No; it can only advise |
| Where it lives | .claude/settings.json, ~/.claude/settings.json, a plugin's hooks/hooks.json, or skill frontmatter | .claude/skills/ or ~/.claude/skills/ |
| Context cost | None unless it prints feedback | Name and description always; full text when used |
| Works in other agents | Claude Code's own format | Open standard: Cursor, Codex and others read SKILL.md |
Choose a hook when
- A rule must never be broken: protected files, a formatter, a lint step.
- You want a check before Claude stops: a Stop hook that exits with code 2 keeps Claude working and sends your message back.
- You want a side effect: a desktop notification when Claude needs input.
Choose a skill when
- The task needs judgement and steps: a code review checklist, a release process, a migration recipe.
- The same know-how should work in Cursor and Codex too.
- It is long, and you do not want it in context for every task.
Use both
A skill can declare hooks in its frontmatter; they register when the skill is invoked and keep running for the rest of the session. Plugins can ship skills and a hooks/hooks.json together, so one install sets up the teaching and the enforcement.
When a skill or vault helps, and when it does not
Helps
- A skill teaches a procedure the agent does not know; a bundled hook makes sure the critical step happens.
- A packaged pair saves writing the scripts yourself.
Does not help
- If you only need enforcement, a hook alone is simpler than any skill.
- Review hooks before enabling them: they run commands with your permissions.