# 08 Hook Generate

> Generate a hook, a handler that runs at a lifecycle event, across the host AI tools. Use when the user wants to create, scaffold, or refactor a hook, or automate an action at a lifecycle point. Not for other artifacts like skills or rules.

- Skill: `ai-driven-dev/08-hook-generate` (Agent Skill, multi-file: 8 files)
- Install (CLI): `npx skillmds@latest add ai-driven-dev/08-hook-generate`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ai-driven-dev/08-hook-generate/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: ai-driven-dev (https://skillmd.com/u/ai-driven-dev)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/ai-driven-dev/08-hook-generate

---


# Hook Generate

Builds one hook: an entry merged into the chosen scope for each supported tool, plus the backing script.

## Actions

| #   | Action         | Role                                              | Input             |
| --- | -------------- | ------------------------------------------------- | ----------------- |
| 01  | `capture-hook` | Clarify the moment, action, matcher, scope, tools | user request      |
| 02  | `write-hook`   | Merge the entry per tool, write the script         | the captured spec |
| 03  | `validate`     | Check the file, the merge, and the moment fit      | files written     |

Run the actions in order, `01 → 03`, and run each action's `## Test` before the next.
Before running an action, read its file in `actions/`, not only the table or assets.

## References

- `references/hook-authoring.md`: the contract (R1-R7), the lifecycle moments, and the handler, matcher, and exit-code model.
- `references/tool-paths.md`: per-tool support, moment-to-event names, file formats, scopes, and write targets.

## Assets

- `assets/hook-template.json`: the entry scaffold.
- `assets/hook-script-template.sh`: the backing-script scaffold.

