hook-developer
Skill3.9k starsChanged 11 months agoMITView on GitHub
Complete Claude Code hooks reference - input/output schemas, registration, testing patterns
- Reads credentials
Trending
Quiet since October.thin dataabout the whole repository
Who's talking about parcadei/Continuous-Claude-v3
- @tom-doerr.bsky.social“https://github.com/parcadei/Continuous-Claude-v3”Bluesky · Apr 21, 2026 · 1 likes
- sudosubin/agents.nix“claude-code-plugins.github.parcadei.continuous-claude-v3: init at 0-unstable-2026-01-26”GitHub · Oct 4, 2026
- sudosubin/agents.nix“agent-skills.github.parcadei.continuous-claude-v3: init at 0-unstable-2026-01-26”GitHub · Oct 1, 2026
- jimy-r/awesome-agent-workspaces“Add Reef to Skills and instruction management”GitHub · Sep 27, 2026
- jimy-r/awesome-agent-workspaces“Maintained-bar check: entries to review”GitHub · Sep 14, 2026
The biggest 5 of 12 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 12
Talked about on GitHub and Bluesky (12 times).
On GitHub · 11
- Oct 4, 2026claude-code-plugins.github.parcadei.continuous-claude-v3: init at 0-unstable-2026-01-26 — sudosubin/agents.nix0 reactions
- Oct 1, 2026agent-skills.github.parcadei.continuous-claude-v3: init at 0-unstable-2026-01-26 — sudosubin/agents.nix0 reactions
- Sep 27, 2026Add Reef to Skills and instruction management — jimy-r/awesome-agent-workspaces0 reactions · 1 comment
- Sep 14, 2026Maintained-bar check: entries to review — jimy-r/awesome-agent-workspaces0 reactions
- Sep 13, 2026ci: SHA-pin third-party actions and split the 90-day flag from the 365-day breach — jimy-r/awesome-agent-workspaces0 reactions
6 more on GitHub
- Aug 31, 2026Maintained-bar check: entries to review — jimy-r/awesome-agent-workspaces0 reactions · 2 comments
- Apr 25, 2026Audit candidate: parcadei/Continuous-Claude-v3 — xiaolai/nlpm0 reactions · 2 comments
- Apr 1, 2026Profile: continuous-claude-v3 — nota-america/forgecat-agent-profiles0 reactions
- Feb 10, 2026feat(hooks): TLDR-lite file summaries — AST-based token reduction for large file reads — yonatangross/orchestkit0 reactions · 2 comments
- Jan 11, 2026manylinux 2_28 can't build working postgres binaries — pypa/manylinux0 reactions · 2 comments
- Dec 12, 2025dec 2025 jan 2026 — kimtth/azure-openai-llm-notes0 reactions
On Bluesky · 1
- Apr 21, 2026https://github.com/parcadei/Continuous-Claude-v3 — @tom-doerr.bsky.social1 likes and repost
In this repository107 other files it gives its agents.
- agent-context-isolationSkill
- agentica-claude-proxySkill
- agentica-infrastructureSkill
- agentica-promptsSkill
- agentica-sdkSkill
- agentica-serverSkill
- agentica-spawnSkill
- agentic-workflowSkill
- agent-orchestrationSkill
- ast-grep-findSkill
- async-repl-protocolSkill
- background-agent-pingsSkill
- braintrust-analyzeSkill
- braintrust-tracingSkill
- buildSkill
- cli-referenceSkill
- commitSkill
- complete-skillSkill
- completion-checkSkill
- compound-learningsSkill
- continuity-ledgerSkill
- create-handoffSkill
- dead-codeSkill
- debug-hooksSkill
- debugSkill
- describe-prSkill
- discovery-interviewSkill
- environment-triageSkill
- explicit-identitySkill
- exploreSkill
- firecrawl-scrapeSkill
- fixSkill
- git-commitsSkill
- github-searchSkill
- graceful-degradationSkill
- helpSkill
- hooksSkill
- idempotent-redundancySkill
- implement_plan_microSkill
- implement_planSkill
- implement_taskSkill
- index-at-creationSkill
- llm-tuning-patternsSkill
- loogle-searchSkill
- math-helpSkill
- math-routerSkill
- mathSkill
- mcp-chainingSkill
- mcp-scriptsSkill
- migrateSkill
- modular-codeSkill
- morph-applySkill
- morph-searchSkill
- motSkill
- nia-docsSkill
- no-polling-agentsSkill
- no-task-outputSkill
- observe-before-editingSkill
- onboardSkill
- opc-architectureSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 272
CRITICAL: Check stop_hook_active: true to prevent infinite loops!
- Distinctive: line 288
Purpose: Run when a subagent (Task tool) is spawned.
- Distinctive: line 449
Default type. Executes bash commands or scripts.
- Distinctive: line 724
Detached spawn hides errors: - add logging to debug
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Hook Developer
Complete reference for developing Claude Code hooks. Use this to write hooks with correct input/output schemas.
When to Use
- Creating a new hook
- Debugging hook input/output format
- Understanding what fields are available
- Setting up hook registration in settings.json
- Learning what hooks can block vs inject context
Quick Reference
| Hook | Fires When | Can Block? | Primary Use |
| PreToolUse | Before tool executes | YES | Block/modify tool calls |
| PostToolUse | After tool completes | Partial | React to tool results |
| UserPromptSubmit | User sends prompt | YES | Validate/inject context |
| PermissionRequest | Permission dialog shows | YES | Auto-approve/deny |
| SessionStart | Session begins | NO | Load context, set env vars |
| SessionEnd | Session ends | NO | Cleanup/save state |
| Stop | Agent finishes | YES | Force continuation |
| SubagentStart | Subagent spawns | NO | Pattern coordination |
| SubagentStop | Subagent finishes | YES | Force continuation |
| PreCompact | Before compaction | NO | Save state |
| Notification | Notification sent | NO | Custom alerts |
Hook type options: type: "command" (bash) or type: "prompt" (LLM evaluation)
Hook Input/Output Schemas
PreToolUse
Purpose: Block or modify tool execution before it happens.
Input:
{
"session_id": "string",
"transcript_path": "string",
"cwd": "string",
"permission_mode": "default|plan|acceptEdits|bypassPermissions",
"hook_event_name": "PreToolUse",
"tool_name": "string",
"tool_input": {
"file_path": "string",
"command": "string"
},
"tool_use_id": "string"
}Output (JSON):
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "allow|deny|ask",
"permissionDecisionReason": "string",
"updatedInput": {}
},
"continue": true,
"stopReason": "string",
"systemMessage": "string",
"suppressOutput": true
}Exit code 2: Blocks tool, stderr shown to Claude.
Common matchers: Bash, Edit|Write, Read, Task, mcp__.*
PostToolUse
Purpose: React to tool execution results, provide feedback to Claude.
Input:
{
"session_id": "string",
"transcript_path": "string",
"cwd": "string",
"permission_mode": "string",
"hook_event_name": "PostToolUse",
"tool_name": "string",
"tool_input": {},
"tool_response": {
"filePath": "string",
"success": true,
"output": "string",
"exitCode": 0
},
"tool_use_id": "string"
}CRITICAL: The response field is tool_response, NOT tool_result.
Output (JSON):
{
"decision": "block",
"reason": "string",
"hookSpecificOutput": {
"hookEventName": "PostToolUse",
"additionalContext": "string"
},
"continue": true,
"stopReason": "string",
"suppressOutput": true
}Blocking: "decision": "block" with "reason" prompts Claude to address the issue.
Common matchers: Edit|Write, Bash
UserPromptSubmit
Purpose: Validate user prompts, inject context before Claude processes.
Input:
{
"session_id": "string",
"transcript_path": "string",
"cwd": "string",
"permission_mode": "string",
"hook_event_name": "UserPromptSubmit",
"prompt": "string"
}Output (Plain text):
Any stdout text is added to context for Claude.Output (JSON):
{
"decision": "block",
"reason": "string",
"hookSpecificOutput": {
"hookEventName": "UserPromptSubmit",
"additionalContext": "string"
}
}Blocking: "decision": "block" erases prompt, shows "reason" to user only (not Claude).
Exit code 2: Blocks prompt, shows stderr to user only.
PermissionRequest
Purpose: Automate permission dialog decisions.
Input:
{
"session_id": "string",
"transcript_path": "string",
"cwd": "string",
"permission_mode": "string",
"hook_event_name": "PermissionRequest",
"tool_name": "string",
"tool_input": {}
}Output:
{
"hookSpecificOutput": {
"hookEventName": "PermissionRequest",
"decision": {
"behavior": "allow|deny",
"updatedInput": {},
"message": "string",
"interrupt": false
}
}
}SessionStart
Purpose: Initialize session, load context, set environment variables.
Input:
{
"session_id": "string",
"transcript_path": "string",
"cwd": "string",
"permission_mode": "string",
"hook_event_name": "SessionStart",
"source": "startup|resume|clear|compact"
}Environment variable: CLAUDE_ENV_FILE - write export VAR=value to persist env vars.
Output (Plain text or JSON):
{
"hookSpecificOutput": {
"hookEventName": "SessionStart",
"additionalContext": "string"
},
"suppressOutput": true
}Plain text stdout is added as context.
SessionEnd
Purpose: Cleanup, save state, log session.
Input:
{
"session_id": "string",
"transcript_path": "string",
"cwd": "string",
"permission_mode": "string",
"hook_event_name": "SessionEnd",
"reason": "clear|logout|prompt_input_exit|other"
}Output: Cannot affect session (already ending). Use for cleanup only.
Stop
Purpose: Control when Claude stops, force continuation.
Input:
{
"session_id": "string",
"transcript_path": "string",
"cwd": "string",
"permission_mode": "string",
"hook_event_name": "Stop",
"stop_hook_active": false
}CRITICAL: Check stop_hook_active: true to prevent infinite loops!
Output:
{
"decision": "block",
"reason": "string"
}Blocking: "decision": "block" forces Claude to continue with "reason" as prompt.
SubagentStart
Purpose: Run when a subagent (Task tool) is spawned.
Input:
{
"session_id": "string",
"transcript_path": "string",
"cwd": "string",
"permission_mode": "string",
"hook_event_name": "SubagentStart",
"agent_id": "string"
}Output: Context injection only (cannot block).
SubagentStop
Purpose: Control when subagents (Task tool) stop.
Input:
{
"session_id": "string",
"transcript_path": "string",
"cwd": "string",
"permission_mode": "string",
"hook_event_name": "SubagentStop",
"stop_hook_active": false
}Output: Same as Stop.
PreCompact
Purpose: Save state before context compaction.
Input:
{
"session_id": "string",
"transcript_path": "string",
"cwd": "string",
"permission_mode": "string",
"hook_event_name": "PreCompact",
"trigger": "manual|auto",
"custom_instructions": "string"
}Matchers: manual, auto
Output:
{
"continue": true,
"systemMessage": "string"
}Notification
Purpose: Custom notification handling.
Input:
{
"session_id": "string",
"transcript_path": "string",
"cwd": "string",
"permission_mode": "string",
"hook_event_name": "Notification",
"message": "string",
"notification_type": "permission_prompt|idle_prompt|auth_success|elicitation_dialog"
}Matchers: permission_prompt, idle_prompt, auth_success, elicitation_dialog, *
Output:
{
"continue": true,
"suppressOutput": true,
"systemMessage": "string"
}Registration in settings.json
Standard Structure
{
"hooks": {
"EventName": [
{
"matcher": "ToolPattern",
"hooks": [
{
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/my-hook.sh",
"timeout": 60
}
]
}
]
}
}Matcher Patterns
| Pattern | Matches |
Bash | Exactly Bash tool |
Edit|Write | Edit OR Write |
Read.* | Regex: Read* |
mcp__.*__write.* | MCP write tools |
* | All tools |
Case-sensitive: Bash ≠ bash
Events Requiring Matchers
- PreToolUse - YES (required)
- PostToolUse - YES (required)
- PermissionRequest - YES (required)
- Notification - YES (optional)
- SessionStart - YES (
startup|resume|clear|compact) - PreCompact - YES (
manual|auto)
Events Without Matchers
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [{ "type": "command", "command": "/path/to/hook.sh" }]
}
]
}
}Hook Types
Command Hooks (type: "command")
Default type. Executes bash commands or scripts.
{
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/my-hook.sh",
"timeout": 60
}Prompt-Based Hooks (type: "prompt")
Uses LLM (Haiku) for context-aware decisions. Best for Stop/SubagentStop.
{
"type": "prompt",
"prompt": "Evaluate if Claude should stop. Context: $ARGUMENTS. Check if all tasks are complete.",
"timeout": 30
}Response schema:
{
"decision": "approve" | "block",
"reason": "Explanation",
"continue": false,
"stopReason": "Message to user",
"systemMessage": "Warning"
}MCP Tool Naming
MCP tools use pattern mcp__<server>__<tool>:
| Pattern | Matches |
mcp__memory__.* | All memory server tools |
mcp__.*__write.* | All MCP write tools |
mcp__github__.* | All GitHub tools |
Environment Variables
Available to All Hooks
| Variable | Description |
CLAUDE_PROJECT_DIR | Absolute path to project root |
CLAUDE_CODE_REMOTE | "true" if remote/web, empty if local CLI |
SessionStart Only
| Variable | Description |
CLAUDE_ENV_FILE | Path to write export VAR=value lines |
Plugin Hooks Only
| Variable | Description |
CLAUDE_PLUGIN_ROOT | Absolute path to plugin directory |
Exit Codes
| Exit Code | Behavior | stdout | stderr |
| 0 | Success | JSON processed | Ignored |
| 2 | Blocking error | IGNORED | Error message |
| Other | Non-blocking error | Ignored | Verbose mode |
Exit Code 2 by Hook
| Hook | Effect |
| PreToolUse | Blocks tool, stderr to Claude |
| PostToolUse | stderr to Claude (tool already ran) |
| UserPromptSubmit | Blocks prompt, stderr to user only |
| Stop | Blocks stop, stderr to Claude |
Shell Wrapper Pattern
#!/bin/bash
set -e
cd "$CLAUDE_PROJECT_DIR/.claude/hooks"
cat | npx tsx src/my-hook.tsOr for bundled:
#!/bin/bash
set -e
cd "$HOME/.claude/hooks"
cat | node dist/my-hook.mjsTypeScript Handler Pattern
import { readFileSync } from 'fs';
interface HookInput {
session_id: string;
hook_event_name: string;
tool_name?: string;
tool_input?: Record<string, unknown>;
tool_response?: Record<string, unknown>;
// ... other fields per hook type
}
function readStdin(): string {
return readFileSync(0, 'utf-8');
}
async function main() {
const input: HookInput = JSON.parse(readStdin());
// Process input
const output = {
decision: 'block', // or undefined to allow
reason: 'Why blocking'
};
console.log(JSON.stringify(output));
}
main().catch(console.error);Testing Hooks
Manual Test Commands
# PostToolUse (Write)
echo '{"tool_name":"Write","tool_input":{"file_path":"test.md"},"tool_response":{"success":true},"session_id":"test"}' | \
.claude/hooks/my-hook.sh
# PreToolUse (Bash)
echo '{"tool_name":"Bash","tool_input":{"command":"ls"},"session_id":"test"}' | \
.claude/hooks/my-hook.sh
# SessionStart
echo '{"hook_event_name":"SessionStart","source":"startup","session_id":"test"}' | \
.claude/hooks/session-start.sh
# SessionEnd
echo '{"hook_event_name":"SessionEnd","reason":"clear","session_id":"test"}' | \
.claude/hooks/session-end.sh
# UserPromptSubmit
echo '{"prompt":"test prompt","session_id":"test"}' | \
.claude/hooks/prompt-submit.shRebuild After TypeScript Edits
cd .claude/hooks
npx esbuild src/my-hook.ts \
--bundle --platform=node --format=esm \
--outfile=dist/my-hook.mjsCommon Patterns
Block Dangerous Files (PreToolUse)
#!/usr/bin/env python3
import json, sys
data = json.load(sys.stdin)
path = data.get('tool_input', {}).get('file_path', '')
BLOCKED = ['.env', 'secrets.json', '.git/']
if any(b in path for b in BLOCKED):
print(json.dumps({
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "deny",
"permissionDecisionReason": f"Blocked: {path} is protected"
}
}))
else:
print('{}')Auto-Format Files (PostToolUse)
#!/bin/bash
INPUT=$(cat)
FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
if [[ "$FILE" == *.ts ]] || [[ "$FILE" == *.tsx ]]; then
npx prettier --write "$FILE" 2>/dev/null
fi
echo '{}'Inject Git Context (UserPromptSubmit)
#!/bin/bash
echo "Git status:"
git status --short 2>/dev/null || echo "(not a git repo)"
echo ""
echo "Recent commits:"
git log --oneline -5 2>/dev/null || echo "(no commits)"Force Test Verification (Stop)
#!/usr/bin/env python3
import json, sys, subprocess
data = json.load(sys.stdin)
# Prevent infinite loops
if data.get('stop_hook_active'):
print('{}')
sys.exit(0)
# Check if tests pass
result = subprocess.run(['npm', 'test'], capture_output=True)
if result.returncode != 0:
print(json.dumps({
"decision": "block",
"reason": "Tests are failing. Please fix before stopping."
}))
else:
print('{}')Debugging Checklist
- Hook registered in settings.json?
- Shell script has
+xpermission? - Bundle rebuilt after TS changes?
- Using
tool_responsenottool_result? - Output is valid JSON (or plain text)?
- Checking
stop_hook_activein Stop hooks? - Using
$CLAUDE_PROJECT_DIRfor paths?
Key Learnings from Past Sessions
- Field names matter -
tool_responsenottool_result - Output format -
decision: "block"+reasonfor blocking - Exit code 2 - stderr goes to Claude/user, stdout IGNORED
- Rebuild bundles - TypeScript source edits don't auto-apply
- Test manually -
echo '{}' | ./hook.shbefore relying on it - Check outputs first -
ls .claude/cache/before editing code - Detached spawn hides errors - add logging to debug
See Also
/debug-hooks- Systematic debugging workflow.claude/rules/hooks.md- Hook development rules
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

