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 | Level | Why |
|---|---|---|
| Code & shell execution | 3 (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 access | 1 (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 reach | 2 (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 & credentials | 1 (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 & persistence | 2 (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 surface | 1 (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 actions | 2 (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. |
| Transparency | 2 (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
- Read `scripts/test_hook.sh`; it expects real hook event shapes and will modify behavior that depends on `~/.claude/settings.json`.
- Inspect the unread `references/hook_pitfalls.md` or the upstream docs it cites before trusting the loop/Stop-hook rules.
- Run `bash -n` and the harness against a scratch hook path first, then register it in a non-production profile.
- If you plan to use the macOS dialog gate, test decline/timeout behavior in your environment before relying on it.
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
Related skills
- agents-deploy — Use when deploying your agent to AWS, or when a deploy has failed.
- principle-build-the-lever — Apply to any non-trivial work, not just bulk work: edits, migrations, analyses, checks.
- principle-make-operations-idempotent — Apply when designing commands, lifecycle steps, or processing loops that run amid crashes, restarts, and retries.
- setup — Set up the AWS DevOps Agent and AWS Security Agent connections. Use when the user says "set up", "configure", "connect", or when MCP tools are missing.
- setup-benny — Configure Benny and prepare its triage and repro automations.
- auto-repo-setup — Diagnose, repair, and standardize repository setup and safe Git workflows for Claude Code or Codex.