Skip to main content

Hooks

Automated triggers that run before or after actions.


What is a Hook?

A hook is a script that runs automatically:

  • PreToolUse - Before an action (e.g., validate before write)
  • PostToolUse - After an action (e.g., prompt after write)

You don't call hooks. They run automatically when triggered.


Available Hooks

HookTypeTrigger
validate-prdPreToolUseBefore writing PRD
capture-feedbackPostToolUseAfter writing artifact
post-commit-roadmapPostToolUseAfter git commit
bootstrapPreToolUseBefore skill execution

How They Work

PreToolUse hooks can:

  • Allow the action (exit 0)
  • Warn but allow (exit 1)
  • Block the action (exit 2)

PostToolUse hooks can:

  • Display messages
  • Prompt for input
  • Never block

Hook Location

scripts/{hook-name}.sh

Configuration

Hooks are registered in hooks/hooks.json (plugin-level) or SKILL.md frontmatter (skill-scoped):

Plugin-level (hooks/hooks.json):

{
"PreToolUse": [
{
"matcher": "Write",
"hooks": ["scripts/validate-prd.sh"]
}
]
}

Skill-scoped (SKILL.md frontmatter):

---
hooks:
PreToolUse:
- matcher: Write
hooks: ["scripts/validate-prd.sh"]
---

Creating Hooks

See Create a Hook for step-by-step guide.