This is a reference guide for Claude's hook system, which lets you intercept and modify agent behavior at specific points like before tool execution, after prompts, or during session starts. You write hooks as shell scripts that call TypeScript handlers via tsx, reading JSON input from stdin and outputting whether to continue or block. It's most useful when you need guardrails on what tools Claude can use, want to inject context at session boundaries, or need to log agent actions. The pattern is clean but requires understanding the event lifecycle. If you're building a Claude workflow that needs programmatic control over agent decisions rather than just prompt engineering, this is how you do it.
- skills.sh installs
- 509
- GitHub stars
- 3.9K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add parcadei/continuous-claude-v3 --skill hooks --agent claude-codeInstalls into .claude/skills of the current project.
Files
Hook Development Rules
When working with files in .claude/hooks/:
Pattern
Shell wrapper (.sh) → TypeScript (.ts) via npx tsx
Shell Wrapper Template
#!/bin/bash
set -e
cd "$CLAUDE_PROJECT_DIR/.claude/hooks"
cat | npx tsx <handler>.ts
TypeScript Handler Pattern
interface HookInput {
// Event-specific fields
}
async function main() {
const input: HookInput = JSON.parse(await readStdin());
// Process input
const output = {
result: 'continue', // or 'block'
message: 'Optional system reminder'
};
console.log(JSON.stringify(output));
}
Hook Events
- PreToolUse - Before tool execution (can block)
- PostToolUse - After tool execution
- UserPromptSubmit - Before processing user prompt
- PreCompact - Before context compaction
- SessionStart - On session start/resume/compact
- Stop - When agent finishes
Testing
Test hooks manually:
echo '{"type": "resume"}' | .claude/hooks/session-start-continuity.sh
Sponsors
Details
- Repository
- github.com/parcadei/continuous-claude-v3
- Category
- Frontend Development
- First seen
- Jun 3, 2026
More from parcadei/continuous-claude-v3
All 108- Prove508
- Compound Learnings507
- Hook Developer506
- Tldr Code506
- Commit503
- Research External503
- Test503
- Background Agent Pings502
- Debug Hooks501
- Describe Pr501
- Braintrust Tracing498
- Opc Architecture497
- Shapely Compute497
- Workflow Router497
- Math Router495
- Recall495
- Mcp Scripts494
- Help493
- Firecrawl Scrape492
- Morph Search492
- Cli Reference491
- Completion Check491
- Idempotent Redundancy491
- Search Tools491
