| name | create-hook |
| description | Use when asked to create, scaffold, or write a new vibe-lab hook or hook policy. Defines one canonical POLICY.md and optional runtime scripts, with Claude Code hook and OpenCode plugin compatibility. |
Create Hook
When to Use
Use this skill when the user asks to:
- "Create a hook for X"
- "Scaffold a new hook"
- "Block or warn when Y happens"
- "Add an OpenCode plugin equivalent for a hook"
Do not use when a markdown rule is enough and no runtime warning/blocking is needed.
Rule
A canonical hook starts as .agents/hooks/<name>/POLICY.md; runtime scripts are optional and adapters are generated by bin/inject.
Template
Use canonical/hook-template.md.
Workflow
- Confirm whether the policy must block, warn, or only document behavior.
- Choose a kebab-case hook name.
- Write
packages/cli/library/hooks/<name>.md with purpose, events, decision rules, runtime, and fail-closed behavior.
- Map Claude Code lifecycle events to OpenCode plugin events where possible.
- Add scripts only for runtime behavior; keep them non-interactive and fail-closed for safety hooks.
- Run
lazyai-cli compile to generate Claude hook scripts/settings and OpenCode plugins.
- Run
lazyai-cli doctor to verify output consistency.
Event Mapping
- Claude
PreToolUse ↔ OpenCode tool.execute.before.
- Claude
PostToolUse ↔ OpenCode tool.execute.after.
- Claude
SessionStart ↔ OpenCode session.created.
- Claude
PreCompact / PostCompact ↔ OpenCode experimental.session.compacting or session.compacted.
- Claude
UserPromptSubmit ↔ OpenCode tui.prompt.append when prompt mutation is needed.
- If no equivalent exists, document the unsupported adapter and make
lazyai-cli doctor warn.
Constraints
- Hooks must never silently drop data.
- Safety hooks deny when parsing or required runtime fails.
- OpenCode plugins are TypeScript/JavaScript, not shell hook JSON.
- OMP/Pi runtime hook support is not assumed.
Verification Checklist