/hatch3r:hatch3r-hooksfrom hatch3r
Define, edit, and manage event-driven hooks that activate agents on project events. Tool-agnostic with adapters for tool-native configs.
Ships in hatch3r. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Task Progress:
- [ ] Step 0: Detect ambiguity (P8 B1)
- [ ] Step 1: Discover current state
- [ ] Step 2: Define a hook (add) — select event, agent, conditions, write definition file
- [ ] Step 3: Edit an existing hook
- [ ] Step 4: Remove a hook
- [ ] Step 5: Sync hooks to tools
Before any action, scan the user's request and provided context for unresolved questions in scope, acceptance criteria, irreversibility, or constraint conflicts (contradictory inputs, missing target, unknown convention). If any are found, ask the user via the platform-native question tool per agents/shared/user-question-protocol.md — do not proceed under silent assumption. This is the default path, not an exception. Acceptable to proceed without asking ONLY when scope is single-target, single-concern, and the brief alone is testable. Any residual ambiguity discovered mid-workflow invokes the same protocol.
If .hatch3r/learnings/ exists, scan for learnings related to hook configurations, event trigger patterns, or prior hook issues before starting.
hooks/ for existing hook definition files (.md files with frontmatter)..hatch3r/hatch.json for configured tools and features.Present the current state:
Current Hooks: {list with id, event, agent — or "none"}
Configured Tools: {tools from hatch.json}
Hooks Feature: {enabled/disabled}
ASK: "Current hooks: {list or 'none'}. Tools: {list}. What would you like to do? (a) Add a new hook, (b) Edit existing hook, (c) Remove a hook, (d) List all hooks, (e) Sync hooks to tools"
For adding a new hook:
Present available events with descriptions:
| Event | Description | Use Cases |
|---|---|---|
pre-commit | Triggered before a commit is created | Lint checks, secret scanning, test running |
post-merge | Triggered after a branch merge | Dependency updates, migration checks, notification |
ci-failure | Triggered when CI/CD pipeline fails | Auto-diagnosis, fix suggestions |
file-save | Triggered when a file is saved | Auto-formatting, auto-testing, live validation |
session-start | Triggered when a new coding session starts | Context loading, status checks |
pre-push | Triggered before pushing to remote | Full test suite, build verification |
pre-implementation | Triggered before implementing a sub-issue | Context loading, spec review, learning consultation |
post-implementation | Triggered after implementing a sub-issue | Learning capture, code quality check, doc updates |
pre-review | Triggered before code review starts | Checklist generation, context preparation |
post-review | Triggered after code review completes | Fix tracking, learning capture, approval notifications |
pre-release | Triggered before a release workflow | Changelog verification, version validation, dependency audit |
post-release | Triggered after a release completes | Monitoring setup, notification, deploy verification |
pre-test | Triggered before test execution | Test environment setup, fixture preparation |
post-test | Triggered after test execution completes | Coverage reporting, flaky test detection, result analysis |
on-error | Triggered when any workflow step fails | Error diagnosis, auto-retry, escalation, incident logging |
on-context-switch | Triggered when agent context is refreshed or delegated | State persistence, handoff documentation |
on-dependency-change | Triggered when dependencies are added/updated/removed | Security audit, compatibility check, license validation |
on-security-finding | Triggered when a security issue is discovered | Alert escalation, auto-fix suggestions, incident creation |
[!IMPORTANT] Claude Code only maps
session-start→SessionStartsemantically. Every other event above (pre-commit, post-merge, ci-failure, file-save, pre-push, etc.) is a git/project lifecycle event with NO native Claude Code mapping — the adapter emits a no-op or alternative strategy, NOT a PreToolUse/PostToolUse binding. If the user picks one of these and targets Claude Code, say so before writing the definition. Full detail: the "Claude Code event mapping" note in Step 2d below.
ASK: "Select an event for this hook."
First run ls agents/ to read the current agent roster. The list below is the canonical set at authoring time, but agents may be added or renamed — verify each id against the live roster before presenting, and drop any that no longer resolve to agents/<id>.md. Present available hatch3r agents (every id below carries the hatch3r- prefix and must exist as agents/<id>.md):
hatch3r-lint-fixer — Automatic lint error resolutionhatch3r-testability — Test generation for new or changed codehatch3r-reviewer — Code review and quality checkshatch3r-security — Security vulnerability scanninghatch3r-ci-watcher — CI/CD pipeline monitoring and diagnosishatch3r-ui — Accessibility and UI-quality checkshatch3r-performance — Performance analysis and optimizationhatch3r-dependency-drafter — Dependency security and update checkshatch3r-docs-writer — Documentation generation and updatesIf the user names an agent not shown, confirm it against the ls agents/ roster: accept a real id, and warn that any name absent from agents/ must be created there before the hook can fire. The agent: value is emitted verbatim into the hook definition — no id normalization resolves a short or misspelled name, so a value that is not an exact agents/<id>.md id activates nothing.
ASK: "Select an agent to activate when this event fires."
src/**/*.ts, *.css)main, release/*)ASK: "Add conditions? (glob patterns, branch patterns, or skip for 'always activate')"
Generate the hook definition file at hooks/{event}-{agent-short-name}.md:
---
id: {event}-{agent-short-name}
type: hook
event: {selected-event}
agent: {selected-agent}
description: {user-provided or auto-generated description}
globs: {comma-separated glob patterns, if any}
branches: {comma-separated branch patterns, if any}
---
# Hook: {event} → {agent}
{Description of what this hook does and when it activates.}
## Activation
- **Event:** {event}
- **Agent:** {agent}
- **Conditions:** {glob patterns, branch patterns, or "always"}
## Tool-Specific Behavior
- **Claude Code:** For session-start → SessionStart. For pre-commit, post-merge, ci-failure, file-save, pre-push: no native mapping — adapter may use no-op or alternative strategy (see mapping note below).
- **Cursor:** Maps to glob-based rule activation in `.cursor/rules/`
- **Others:** Hook definition stored; sync when adapter support is added
Claude Code event mapping: Claude Code's native hook events (PreToolUse, PostToolUse, SubagentStart, SessionStart) are tool-lifecycle events and do NOT map to git/project events. PreToolUse fires before every tool call; PostToolUse fires after every tool completes; SubagentStart fires when a subagent spawns. Only session-start → SessionStart is semantically correct. For pre-commit, post-merge, ci-failure, file-save, and pre-push, the Claude Code adapter may use a no-op or alternative strategy (e.g., Cursor rules) — do not map these to PreToolUse/PostToolUse/SubagentStart, as that would cause hooks to fire on every tool invocation instead of the intended event.
ASK: "Hook definition: {summary}. Create? (yes / adjust / cancel)"
For editing an existing hook:
hooks/.ASK: "Updated hook: {summary}. Save? (yes / revert / cancel)"
ASK: "Remove hook '{id}'? This will delete hooks/{filename}. (yes / cancel)"
.cursor/rules/hatch3r-hook-*.mdc) will be cleaned up on the next npx hatch3r sync.hooks/.hatch.json, describe what will be generated:
CLAUDE.md.mdc rule files in .cursor/rules/hatch3r-hook-*.mdc[!IMPORTANT] For Claude Code, only
session-startbecomes an executable native hook. Git/project-event hooks (pre-commit, post-merge, ci-failure, file-save, pre-push, etc.) are written toCLAUDE.mdas documentation, NOT registered as native Claude Code hooks — they do not fire on the named event. State this explicitly when listing the generated Claude Code output (see the "Claude Code event mapping" note in Step 2d).
ASK: "Hooks will generate these files: {list}. Run npx hatch3r sync to apply. (understood / sync now)"
If user chooses "sync now", instruct them to run npx hatch3r sync in the terminal.
A hook is a single canonical artifact: one event fires one agent, optionally narrowed by conditions. The fields below are the complete config that adapters honor today (src/hooks/types.ts HookDefinition + HookCondition):
| Field | Required | Meaning |
|---|---|---|
id | yes | Unique hook identifier (sanitized for shell safety). |
event | yes | Lifecycle event from the events table in Step 2a. |
agent | yes | Agent ID dispatched when the event fires. |
description | yes | Human-readable purpose. |
globs | no | File glob patterns — hook fires only when matching files are affected. |
branches | no | Branch name patterns — hook fires only on matching branches. |
labels | no | Issue/PR labels — hook fires only when matching labels are present. |
There is no chaining, custom-event, priority, timeout, or parallel-by-priority config: each hook is independent, the adapter emits one tool-native entry per hook, and ordering across multiple hooks on the same event is the tool's own (Claude Code stacks matcher entries; Cursor stacks .cursor/hooks.json entries). Do not author hooks.chains, hooks.customEvents, emit-hook, priority:, or timeout: — no code consumes them.
hooks/ doesn't exist: create it automatically.agents/: warn but allow (agent may be added later).npx hatch3r sync.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
hooks, event-driven, agent-activation, orchestration, devops, tool-agnostic
Claude Code refuses to install this plugin
.claude-plugin/plugin.json: commands: Invalid input, agents: Invalid string: must start with "./", agents: Invalid string: must end with ".md", skills: Invalid string: must start with "./", mcpServers: Invalid string: must start with "./"
.claude-plugin/plugin.json: commands: Invalid input, agents: Invalid string: must start with "./", agents: Invalid string: must end with ".md", skills: Invalid string: must start with "./", mcpServers: Invalid string: must start with "./"
Checked against Claude Code 2.1.332's install rules. The listing below is what the repository ships; Claude Code cannot install it as published.
55 skills in this plugin
/hatch3r-a11y-auditRuns a WCAG AA accessibility audit with findings and fixes across 7 scan categories (keyboard, contrast, ARIA, reduced motion, screen reader, high contrast, automated axe). Use when auditing and remediating accessibility./hatch3r-adhoc-orchestrateScaffolds the ad-hoc Tier >= 2 orchestration protocol -- Per-Turn Pipeline-State Header, implementer delegation plan, End-of-Turn Delegation Attestation. Use for a multi-phase task with no registered command to avoid inline-implementation bypass mode./hatch3r-ai-featureEval-driven development workflow for shipping AI features — write eval before prompt, measure, iterate, ship with caching + cost telemetry + model fallback + hallucination SLIOther plugins' skills for the same job