Back to skills
SKILL.md
Create Hook
ASecurityScaffolds a new event-driven hook in a plugin. NOT for creating skills (use `create-skill`) and NOT for GitHub Actions agentic workflows (use `create-agentic-workflow`).
- 7 stars
- 0 votes
- 0 copies
- 2 views
- Added September 2, 2026
Security analysis
100/100Pro scans all 20 files and shows the line behind each finding
npx -y skills add richfrem/agent-plugins-skills --skill create-hook --agent claude-codeAre you the author of Create Hook?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/richfrem-create-hook-agent-plugins-skills)---
name: create-hook
plugin: agent-scaffolders
description: >
Scaffolds a new event-driven hook in a plugin. NOT for creating skills (use `create-skill`) and NOT for GitHub Actions agentic workflows (use `create-agentic-workflow`).
argument-hint: "[event-type or use case]"
allowed-tools: Bash, Read, Write
---
# Create Hook (create-hook)
Scaffolds event-driven lifecycle hooks (e.g. `PreToolUse`, `PostToolUse`, `Stop`, `PermissionRequest`) in plugin configuration or skill frontmatter.
## Contents
- [Critical Constraints](#critical-constraints)
- [Quick start](#quick-start)
- [Workflow](#workflow)
- [Verification](#verification)
- [References](#references)
## Critical Constraints
- **Event Scope**: Only for lifecycle hooks. For standalone skills, use `create-skill`. For CI/CD or agentic workflows, use `create-github-action` or `create-agentic-workflow`.
- **Cross-Platform Commands**: Hook commands must support macOS/Linux and Windows via `python3 ... || python ...` syntax with `${CLAUDE_PLUGIN_ROOT}` path anchors.
- **Project Context Guards**: Hook scripts must verify repository context on entry (e.g. check `.agent/` or `context/`) and exit silently (return code 0) if uninitialized.
- **Minimal Latency**: Keep synchronous hook handlers lean to prevent blocking the agent execution loop.
## Quick start
```bash
python3 plugins/agent-scaffolders/scripts/scaffold.py \
--type hook \
--name check-command \
--path plugins/<plugin>/hooks \
--event PreToolUse \
--action command
```
## Workflow
1. **Phase 1: Event & Scope Selection**: Determine lifecycle trigger event (`PreToolUse`, `PostToolUse`, `Stop`), placement scope (global `hooks.json` vs skill frontmatter), and action type (`command`, `prompt`, `agent`).
2. **Phase 2: Hook Configuration**: Draft configuration entry with event identifier, target tool matcher pattern, and action parameters.
3. **Phase 3: Script Implementation**: For command hooks, author script with cross-platform fallback, silent project guards, and deterministic exit codes.
4. **Phase 4: Linting & Testing**: Execute `hook_linter.py` on created handler scripts and verify schema validity.
## Verification
```bash
# Lint the hook handler script
python3 plugins/agent-scaffolders/scripts/hook_linter.py plugins/<plugin>/hooks/<script>.py
# Audit skill compliance
python3 plugins/agent-scaffolders/scripts/audit_skill.py plugins/agent-scaffolders/skills/create-hook --mode source
```
## References
- [fallback-tree.md](references/fallback-tree.md) - Fallback tree for scaffolding failures.
- [references/patterns.md](references/patterns.md) - Common event-driven hook patterns.
- [references/advanced.md](references/advanced.md) - Advanced handler types and lifecycle nuances.
- [acceptance-criteria.md](references/acceptance-criteria.md) - Hook validation and acceptance criteria.
Files in this skill
- SKILL.md
- acceptance-criteria.md
- evals/evals.json
- evals/results.tsv
- fallback-tree.md
- references/acceptance-criteria.md
- references/advanced.md
- references/fallback-tree.md
- references/hitl-interaction-design.md
- references/migration.md
- references/pattern-decision-matrix.md
- references/patterns.md
- references/patterns/action-forcing-output-with-deadline-attribution.md
- references/patterns/adversarial-objectivity-constraint.md
- references/patterns/anti-pattern-vaccination.md
- references/patterns/anti-symptom-triage.md
- references/patterns/artifact-embedded-execution-audit-trail.md
- references/patterns/artifact-generation-xss-compliance-gate.md
- references/patterns/artifact-lifecycle.md
- references/patterns/artifact-state-interrogative-routing.md
Attribution
Comments
Loading comments…