hooks
This Claude Code skill provides a framework for creating lifecycle hooks that intercept and control Claude's execution at key points including tool use, prompt submission, context compaction, and session management. Use this when building event-driven automation that requires validation, logging, or conditional blocking of operations within a continuous Claude workflow.
git clone --depth 1 https://github.com/parcadei/Continuous-Claude-v3 /tmp/hooks && cp -r /tmp/hooks/.claude/skills/hooks ~/.claude/skills/hooksSKILL.md
# Hook Development Rules
When working with files in `.claude/hooks/`:
## Pattern
Shell wrapper (.sh) → TypeScript (.ts) via `npx tsx`
## Shell Wrapper Template
```bash
#!/bin/bash
set -e
cd "$CLAUDE_PROJECT_DIR/.claude/hooks"
cat | npx tsx <handler>.ts
```
## TypeScript Handler Pattern
```typescript
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:
```bash
echo '{"type": "resume"}' | .claude/hooks/session-start-continuity.sh
```
## Registration
Add hooks to `.claude/settings.json`:
```json
{
"hooks": {
"EventName": [{
"matcher": ["pattern"], // Optional
"hooks": [{
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/hook.sh"
}]
}]
}
}
```Security vulnerability analysis and testing
Build Python agents using Agentica SDK - spawn agents, implement agentic functions, multi-agent orchestration
Unit and integration test execution and validation
Feature planning, design documentation, AND integration planning
End-to-end and acceptance test execution
Analyze Claude Code sessions using Braintrust logs
Session analysis, precedent lookup, and learning extraction
Query the artifact index for precedent and guidance