Validate custom agent file format and structure. Use after creating or editing an agent, before committing agent changes, or when an agent fails to load.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Generate hook script from template. Use when adding a new hook, wiring a PreToolUse/PostToolUse/Stop/Notification hook, or scaffolding hook config for settings.json.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
설치 방법 보기설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.
Generate a hook script and configuration based on requirements.
Usage: /hook-template [hook-event] [purpose]
Claude Code defines 30 hook events. The common ones, grouped:
| Group | Events |
|---|---|
| Lifecycle | SessionStart, SessionEnd, Setup |
| Prompt | UserPromptSubmit, UserPromptExpansion |
| Tool | PreToolUse, PostToolUse, PostToolUseFailure, PostToolBatch |
| Permission | PermissionRequest, PermissionDenied |
| Subagent | SubagentStart, SubagentStop |
| Stop | Stop, StopFailure |
| Task | TaskCreated, TaskCompleted |
| Compaction | PreCompact, PostCompact |
| Notification | Notification, MessageDisplay |
| MCP elicitation | Elicitation, ElicitationResult |
| Environment | ConfigChange, CwdChanged, FileChanged, InstructionsLoaded, WorktreeCreate, WorktreeRemove, TeammateIdle |
That is all 30 events. See the official Claude Code hooks docs for the full list and each event's payload. The templates below cover the practical 90%.
| Field | Type | Required | Default | Notes |
|---|---|---|---|---|
type | String | No | command | command, prompt, http, mcp_tool, or agent |
command | String | If type=command | - | Shell command to execute |
prompt | String | If type=prompt | - | Natural language prompt evaluated by an LLM |
matcher | String | No | - | For tool events: tool name, regex, or * |
timeout | Integer | No | 60 | Seconds, per hook |
once | Boolean | No | false | Run hook only once per session |
if | String | No | - | Conditional guard for the hook |
statusMessage | String | No | - | Message shown while the hook runs |
type: command (default) and type: prompt (LLM-evaluated) cover most needs.
The http, mcp_tool, and agent entry types also exist for calling an
endpoint, invoking an MCP tool, or dispatching a subagent.
All hooks receive JSON on stdin. The event name is in hook_event_name:
{
"session_id": "abc123",
"transcript_path": "/path/to/transcript.txt",
"cwd": "/current/working/dir",
"permission_mode": "ask",
"hook_event_name": "PreToolUse",
"tool_name": "Write",
"tool_input": { "file_path": "/path/to/file" }
}
hookSpecificOutput.permissionDecision of allow,
deny, or ask. Exit code 2 with a stderr message is the shorthand for
deny. The legacy top-level {"decision": "approve" | "block"} is still accepted.{"decision": "block", "reason": "<next prompt>"} — the key is reason.0 with no output.Gather Requirements
*)Generate Script at .claude/hooks/[name].sh
Update settings.json with hook config
Make Executable: chmod +x
Validate with /hooks-check
#!/bin/bash
INPUT=$(cat)
TOOL=$(echo "$INPUT" | jq -r '.tool_name')
FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
# Block edits to specific files
if [[ "$FILE" == *"package-lock.json"* ]]; then
echo "BLOCKED: Do not edit lockfiles directly" >&2
exit 2 # exit 2 = deny for PreToolUse
fi
exit 0 # Allow (no output needed)
#!/bin/bash
INPUT=$(cat)
FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
if [[ "$FILE" == *"package-lock.json"* ]]; then
jq -n '{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "deny",
"permissionDecisionReason": "Do not edit lockfiles directly"
}
}'
exit 0
fi
# permissionDecision may be "allow", "deny", or "ask"
exit 0
#!/bin/bash
cat > /dev/null # Consume stdin
INFO="This file requires careful review"
jq -n --arg ctx "$INFO" '{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"additionalContext": $ctx
}
}'
exit 0
#!/bin/bash
INPUT=$(cat)
# Process and log... (no stdout needed)
exit 0
#!/bin/bash
CHECKPOINT=".auto-loop/checkpoint.json"
if [[ ! -f "$CHECKPOINT" ]]; then
exit 0 # Allow stop
fi
# Block stop to continue loop — key is "reason", used as the next prompt
jq -n --arg reason "Continuing iteration" \
'{"decision": "block", "reason": $reason}'
exit 0
#!/bin/bash
cat > /dev/null
echo "Loading project context..." >&2
exit 0
Instead of a bash script, use type: "prompt" in settings.json:
{
"hooks": {
"Stop": [
{
"matcher": "*",
"hooks": [
{
"type": "prompt",
"prompt": "Review the work done. Return 'approve' if complete, or 'block' with reason.",
"timeout": 30
}
]
}
]
}
}
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/validate.sh",
"timeout": 60
}
]
}
],
"SessionStart": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/load-context.sh",
"once": true
}
]
}
]
}
}
/hook-template PreToolUse "block edits to package-lock.json"
Creates:
- .claude/hooks/protect-lockfile.sh
- Updates .claude/settings.json
아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.
로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.
아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.
Validate custom agent file format and structure. Use after creating or editing an agent, before committing agent changes, or when an agent fails to load.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Generate custom agent from template. Use when creating a new subagent from scratch, or scaffolding an agent file with correct frontmatter.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
List all available agents (core, expert, self-evolving). Use when the user asks what agents are available or runs /agents.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
TDD-based autonomous development loop with checkpoint recovery and observability changelog
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
View and manage the runtime changelog for observability
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Track development session events in a daily markdown changelog, including file changes, test results, and key decisions.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.