Agent skill
kit-hooks
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/kit-hooks
SKILL.md
Hook Development for epost_agent_kit
Overview
Hooks are event-driven automation scripts that execute in response to Claude Code events. Use hooks to validate operations, enforce policies, add context, and integrate external tools.
Hook Types
Command Hooks (Deterministic)
Execute bash/node scripts for fast, deterministic checks:
{
"type": "command",
"command": "node .claude/hooks/my-hook.cjs",
"timeout": 60
}
Prompt Hooks (LLM-Driven)
Use Claude for context-aware validation:
{
"type": "prompt",
"prompt": "Validate this tool use is appropriate: $TOOL_INPUT",
"timeout": 30
}
Supported events: Stop, SubagentStop, UserPromptSubmit, PreToolUse
Hook Events
| Event | When | Use For |
|---|---|---|
PreToolUse |
Before tool runs | Validation, blocking, modification |
PostToolUse |
After tool completes | Feedback, logging, lint/build |
UserPromptSubmit |
User sends prompt | Context injection, rules reminder |
Stop |
Agent stopping | Completeness check, notification |
SubagentStop |
Subagent done | Task validation |
SessionStart |
Session begins | Project detection, env setup |
SessionEnd |
Session ends | Cleanup, logging |
PreCompact |
Before compaction | Preserve critical context |
Notification |
User notified | Reactions |
Hook Configuration in settings.json
Hooks are configured in packages/core/settings.json under the hooks key:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash|Glob|Grep|Read|Edit|Write",
"hooks": [
{
"type": "command",
"command": "node .claude/hooks/scout-block.cjs",
"timeout": 10
}
]
}
]
}
}
Matchers
- Exact:
"matcher": "Write" - Multiple:
"matcher": "Read|Write|Edit" - Wildcard:
"matcher": "*" - Regex:
"matcher": "mcp__.*__delete.*"
Input/Output Contract
Input (JSON via stdin)
{
"session_id": "abc123",
"cwd": "/project/dir",
"hook_event_name": "PreToolUse",
"tool_name": "Write",
"tool_input": { "file_path": "/path" }
}
Output (JSON via stdout)
PreToolUse decisions:
{
"hookSpecificOutput": {
"permissionDecision": "allow|deny|ask"
},
"systemMessage": "Explanation for Claude"
}
Exit codes: 0 = success, 2 = blocking error (stderr → Claude)
epost_agent_kit Hook Architecture
Hooks live in packages/core/hooks/ and are generated to .claude/hooks/:
packages/core/hooks/
├── session-init.cjs # SessionStart: project detection, env vars, plan resolution
├── subagent-init.cjs # SubagentStart: compact context injection to Task agents
├── context-reminder.cjs # UserPromptSubmit: session context + rules (deduplicated)
├── scout-block.cjs # PreToolUse: block node_modules/dist/.git per .epost-ignore
├── privacy-block.cjs # PreToolUse: block .env/secrets unless APPROVED: prefix
├── subagent-stop-reminder.cjs # SubagentStop: post-agent reminders (planner → /cook)
├── session-metrics.cjs # Stop: record session duration/git stats → .epost-data/
├── lesson-capture.cjs # Stop: evaluate significance, prompt knowledge capture
└── notifications/
└── notify.cjs # Stop: Discord/Telegram notification
packages/kit/hooks/
├── kit-session-check.cjs # SessionStart: check skill-index.json staleness
├── kit-write-guard.cjs # PreToolUse: block writes to .claude/ in kit-repo context
└── kit-post-edit-reminder.cjs # PostToolUse: skill index + re-init + stale ref scan
Configuration files:
.epost-kit.json— Hook config (plan naming, project type, hook toggles, validation rules).epost-ignore— Scout-block patterns (gitignore-spec format)
Creating a New Hook
- Create hook script in
packages/{package}/hooks/{hook-name}.cjs - Wire into
packages/core/settings.jsonunder appropriate event - Add to
packages/{package}/package.yamlfiles mapping if needed - Run
epost-kit init --freshto regenerate
Additional Resources
For detailed patterns, security practices, and advanced techniques:
references/hook-patterns.md— Common patterns, testing, debugging
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?