Skills Explorer Add Skills

claude-code-hooks

An agent skill by daymade, from daymade/claude-code-skills. Tags: automation, debugging, devops, setup, workflow.

What it does

How to write, test, register, and debug Claude Code hooks — PreToolUse / PostToolUse / SessionStart / Stop Bash guards that enforce a rule the model would otherwise talk itself past. Use whenever the user wants to create a hook, block/intercept a tool call, turn a repeatedly-violated rule into a hard gate, add a guard rail, debug a hook that misfires or "poisons the session", register a hook across profiles, or mentions hooks / PreToolUse / Stop hook / 拦截 / 守卫 / 钩子 / 拦下. Bakes in the hard-won pitfalls: UserPromptSubmit only ever sees user input, never Claude's own text — a rule about Claude's own output belongs on Stop instead; token-level shlex matching (never awk splitting); bash -n + real-JSON end-to-end testing BEFORE registering (a corrupted PreToolUse hook poisons every Bash call); SSOT + symlink so a ~/.claude reinstall can't lose it; multi-profile convergence; and human-confirmation release gates. Reach for this even for "make it stop doing X" — a durable stop is a hook, not a reminder.

Install

With the skills CLI, which installs into Claude Code, Codex, Cursor and other agents:

npx skills add daymade/claude-code-skills --skill claude-code-hooks

Or copy the skill folder into Claude Code's skills directory by hand (~/.claude/skills for every project, or .claude/skills inside one):

git clone --depth 1 https://github.com/daymade/claude-code-skills
cp -r claude-code-skills/daymade-claude-code/claude-code-hooks ~/.claude/skills/claude-code-hooks

Safety box score

Grade D, elevated risk: 56 of 100 risk points, rated 2026-10-20. The grade rates what the skill and its scripts can reach on the machine of whoever installs it, across eight categories from shell execution to secrets access. How the score works.

This skill ships a fairly heavy hook-building toolkit: Bash/Python test harnesses, hook patterns, profile registration logic, and GUI/TTY confirmation flows that can read and rewrite Claude config under the user’s home directory. The main risks are local config tampering, broad shell execution, and gating or steering irreversible actions like commits/pushes; one referenced file could not be inspected.

Category levels, from 0 (none) to 3 (high)
CategoryLevelWhy
Code & shell execution3 (high)It bundles runnable shell/Python hook code and a test harness that literally executes the hook (`printf '%s' "$2" | "$HOOK"`), plus embedded commands like `python3 - <<'PY'` and `osascript`.
Network access1 (low)There is no shipped downloader/uploader, but the review instructions explicitly tell the reader to `curl` raw source and compare exact strings, so network fetches are part of the skill’s workflow.
Filesystem reach2 (moderate)It reads/writes home-directory config and hook paths such as `~/.claude/settings.json`, `~/.claude/hooks/<name>.sh`, and transcript files under `~/.claude/projects/...`.
Secrets & credentials1 (low)The skill can read session transcripts and profile settings from the user’s home directory, which may contain sensitive prompts or other confidential data, but it does not target keychains or credential stores.
Privilege & persistence2 (moderate)It mutates persistent Claude profile/settings state and uses `osascript`-based confirmation gates; that changes app behavior across sessions, even though it does not require sudo.
Instruction hijack surface1 (low)It uses model-facing injected context (`hookSpecificOutput` / `additionalContext`) and Stop-hook feedback text to steer future model behavior, which is an intentional context-injection channel.
Irreversible actions2 (moderate)The skill is expressly about gating tool calls, and its examples cover irreversible actions like `git commit`, `git push`, `gh pr create`, and `SendMessage`, so it can control whether those actions happen.
Transparency2 (moderate)`references/hook_pitfalls.md` could not be read, yet SKILL.md relies on it for critical failure modes and loop logic, so part of the claimed behavior remains unreviewed.

Before installing

Rated 2026-10-20 by an automated review of 4 files from the skill's repository.

Source

Repository
daymade/claude-code-skills (all skills from this repository)
Path
daymade-claude-code/claude-code-hooks/SKILL.md
Branch
main
Updated
2026-09-20