/hook-architect:hook-architectfrom hook-architect
Guides creating and maintaining Claude Code hooks with discovery, self-healing, and auto-updates. Covers PreToolUse, PostToolUse, and other hook event types with API specifications.
Ships in hook-architect. 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.
Design perfect Claude Code hooks for any codebase through guided discovery, intelligent recommendations, and self-healing.
Last Updated: January 2026 (Claude Code 2.1.x API)
| Command | What It Does |
|---|---|
/hook-architect | Full guided workflow |
/hook-architect --review | Audit & grade existing hooks (A-F) |
/hook-architect --update | Check Anthropic docs for API updates |
/hook-architect --heal | Auto-fix common issues |
/hook-architect --recipes | Browse hook templates |
| Type | When | Use For |
|---|---|---|
PreToolUse | Before tool runs | Permission gates, file protection, input modification |
PermissionRequest | Permission dialog shown | Auto-allow/deny permissions |
PostToolUse | After tool completes | Logging, auto-format, notifications, feedback to Claude |
UserPromptSubmit | User sends message | Context injection, routing, validation |
SubagentStart | Agent spawns | Enrichment, duplicate detection |
SubagentStop | Agent completes | Output compression, scoring, evaluation |
Stop | Main agent finishes | Control if Claude continues working |
SessionStart | Session starts/resumes | Load context, setup environment |
SessionEnd | Session ends | Cleanup, logging, save state |
PreCompact | Before compaction | Intercept context compression |
Notification | Background alerts | React to permission, idle, auth notifications |
{
"tool_name": "Edit",
"tool_input": {"file_path": "/path/to/file.ts", "old_string": "...", "new_string": "..."},
"tool_use_id": "toolu_01ABC123...",
"session_id": "...",
"cwd": "/project/path"
}
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "allow|deny|ask",
"permissionDecisionReason": "Why this decision was made",
"updatedInput": {"command": "modified command"}
}
}
Permission Decisions:
allow - Bypass permission system, proceed immediatelydeny - Block the tool call entirelyask - Show user permission dialog (NEW!)DEPRECATED (still works but update your hooks):
{"decision": "approve|block", "reason": "..."}
{
"hookSpecificOutput": {
"hookEventName": "PostToolUse",
"additionalContext": "Feedback for Claude about what happened"
}
}
{
"decision": "block",
"reason": "Why blocked"
}
Or add context (printed to stdout or via JSON):
{
"hookSpecificOutput": {
"hookEventName": "UserPromptSubmit",
"additionalContext": "Injected context for this prompt"
}
}
{
"hookSpecificOutput": {
"hookEventName": "SessionStart",
"additionalContext": "Loaded project context..."
}
}
Special: Use $CLAUDE_ENV_FILE to persist environment variables.
Define hooks directly in Skills, Subagents, and Slash Commands via frontmatter:
---
name: secure-coder
description: Code with security checks
hooks:
PreToolUse:
- matcher: "Bash"
hooks:
- type: command
command: "./scripts/security-check.sh"
PostToolUse:
- matcher: "Edit|Write"
hooks:
- type: command
command: "./scripts/run-linter.sh"
once: true # Run only once per session
---
Supported events: PreToolUse, PostToolUse, Stop
Use LLM evaluation instead of shell scripts:
{
"hooks": {
"Stop": [{
"hooks": [{
"type": "prompt",
"prompt": "Evaluate if all tasks are complete. $ARGUMENTS",
"timeout": 30
}]
}]
}
}
LLM responds with:
{"ok": true|false, "reason": "explanation if false"}
| Variable | Description |
|---|---|
$CLAUDE_PROJECT_DIR | Absolute path to project root |
$CLAUDE_PLUGIN_ROOT | Plugin directory (for plugin hooks) |
$CLAUDE_CODE_REMOTE | "true" for web, unset for CLI |
$CLAUDE_ENV_FILE | File to persist env vars (SessionStart only) |
# From plugin templates directory:
./scripts/install-hooks.sh --safety # Essential hooks
./scripts/install-hooks.sh --all # All hooks
./scripts/install-hooks.sh file-guardian # Specific hook
{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": ".claude/hooks/file-guardian.sh",
"timeout": 10
}
]
}
],
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": ".claude/hooks/auto-formatter.sh"
}
]
}
],
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": ".claude/hooks/load-context.sh"
}
]
}
]
}
}
--review grades hooks A-F on security, performance, reliability--update checks Anthropic docs for API changes--heal auto-fixes: deprecated fields, missing hookEventName, old decision values| Issue | Auto-Fix |
|---|---|
decision: "approve" | → permissionDecision: "allow" |
decision: "block" | → permissionDecision: "deny" |
Missing hookEventName | → Add based on hook type |
Missing set -e | → Add to shell scripts |
| Unquoted variables | → Add quotes |
Match MCP tools with pattern: mcp__<server>__<tool>
{
"matcher": "mcp__memory__.*",
"hooks": [{"type": "command", "command": "..."}]
}
claude --debug # Shows hook matching and execution details
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub lego4005/foxit-marketplace --plugin hook-architect