From cc-toolkit
Create, configure, debug, and optimize Claude Code hooks (PreToolUse, PostToolUse, SessionStart, Stop, Notification). Use when the user wants to add automation, enforce rules, block commands, or run scripts on Claude Code events. Triggers on: 'create hook', 'block command', 'auto-run on save', 'PreToolUse', 'PostToolUse', 'hook not working', 'hook debug', 'automation'. Use proactively when discussing automation or guardrails.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cc-toolkit:cc-hooksThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Create, debug, and optimize Claude Code hooks for automation and guardrails.
Create, debug, and optimize Claude Code hooks for automation and guardrails.
| Event | When it fires | Common uses |
|---|---|---|
| PreToolUse | Before a tool executes | Block, validate, transform inputs |
| PostToolUse | After a tool executes | Auto-format, log, notify |
| SessionStart | When a session begins | Load context, set environment |
| Stop | When Claude stops responding | Summary, cleanup, commit |
| Notification | On notifications | Custom alerts, integrations |
Understand the requirement — Ask:
Check existing hooks — Read settings.json (project and global) for existing hooks that might conflict
Write the hook script:
$TOOL_NAME, $tool_input (JSON via stdin)Register the hook — Add to settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [{"type": "command", "command": "path/to/script.sh"}]
}
]
}
}
Test the hook:
Document — Add comment in script explaining purpose and trigger
The hook script file + updated settings.json entry. Explanation of what was created and how to test.
If hook fails to register, verify settings.json syntax is valid JSON. If hook doesn't fire, check matcher pattern matches the exact tool name.
npx claudepluginhub fernandoxavier02/fx-studio-ai --plugin cc-toolkitProvides CDSS development patterns for drug interaction checking, dose validation, clinical scoring (NEWS2, qSOFA), and alert classification integrated into EMR workflows.