Skip to content
Back to skills

Create Hook

ASecurity

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`).

  • 7 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 2, 2026
ai-agentspythonbashtestinggitci/cd

Security analysis

A100/100

Pro scans all 20 files and shows the line behind each finding

Scanned October 3, 2026

npx -y skills add richfrem/agent-plugins-skills --skill create-hook --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Create Hook?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Create Hook
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/richfrem-create-hook-agent-plugins-skills/badge)](https://www.skillsdirectory.com/skills/richfrem-create-hook-agent-plugins-skills)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.md2.5 KB
  • acceptance-criteria.md395 B
  • evals/evals.json876 B
  • evals/results.tsv417 B
  • fallback-tree.md1.4 KB
  • references/acceptance-criteria.md42 B
  • references/advanced.md31 B
  • references/fallback-tree.md36 B
  • references/hitl-interaction-design.md46 B
  • references/migration.md32 B
  • references/pattern-decision-matrix.md46 B
  • references/patterns.md31 B
  • references/patterns/action-forcing-output-with-deadline-attribution.md82 B
  • references/patterns/adversarial-objectivity-constraint.md69 B
  • references/patterns/anti-pattern-vaccination.md59 B
  • references/patterns/anti-symptom-triage.md54 B
  • references/patterns/artifact-embedded-execution-audit-trail.md74 B
  • references/patterns/artifact-generation-xss-compliance-gate.md74 B
  • references/patterns/artifact-lifecycle.md53 B
  • references/patterns/artifact-state-interrogative-routing.md71 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…