cc-hooks

Claude Code lifecycle hooks are shell commands that run at defined points, such as before a tool is used. They can enforce rules mechanically, including blocking an action with the documented exit status.

In plain words
What is it for?
Use it to install default enforcement hooks and optionally configure guard rules for Claude Code. Hooks can be disabled per computer.
Why use it?
They prevent important instructions from being ignored during an agent session. Poorly scoped hooks can interfere with tool calls, so successful hooks must stay silent and failures must follow the expected format.

Skill for Claude CodeCodex

Part of the agentops plugin — 51 skills, 4 agents, 1 hook shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/boshu2/agentops/cc-hooks
Any agent
npx skills add boshu2/agentops --skill cc-hooks
Clone the repo
git clone --depth 1 https://github.com/boshu2/agentops

Made for: Claude Code, Codex.

Or install agentops, the plugin that ships this one along with the rest of its 51 skills, 4 agents, 1 hook.

Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,929 The whole file, excluding the scripts and references it only reads on demand.
Security scan D 2 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00032 $0.03929
Opus 5 $0.00016 $0.01965
Sonnet 5 $0.00006 $0.00786
Haiku 4.5 $0.00003 $0.00393

Measured 3d ago against content hash 9f30e7151900, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade D, and why

cc-hooks scanned grade D with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

Add to `~/.claude/settings.json` (user) or `.claude/settings.json` (project):

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

- **DCG**: Blocks `git reset --hard`, `rm -rf`, `git push --force`
images/gemini/skills/cc-hooks/SKILL.md · 322 lines

How it starts

The opening of the file, as written. The whole thing — 322 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Claude Code Hooks

Shell commands that fire at specific points in Claude Code's lifecycle.

Hooks enforce mechanically what prose cannot: a model can reason its way past an instruction, but it cannot reason its way past an exit 2 — which is exactly why every hook must be narrow, silent, and reversible.

Named failure mode — chatty happy path: a hook that emits stdout on exit 0 corrupts the tool call it was guarding; silence on success is part of the contract, not a style preference.

Constraints

  • Enforcement hooks (the PreToolUse policy dispatcher) ship by DEFAULT: plugin installs auto-wire hooks/hooks.json; skill copies and checkouts wire with one command (scripts/install-hooks.sh). Operators can disable per host (/plugin disable, or remove the settings matchers).
  • Injection hooks (SessionStart/UserPromptSubmit context stuffing) stay dead — the #511 teardown proved delta=0 at 10.35M resident tokens. Never ship one; the hookless-cold-start gate still enforces this.
  • Keep the happy path silent and block only with the event's documented exit/JSON contract because stray stdout can corrupt a tool call.
  • Bound Stop hooks with stop_hook_active and scope matchers narrowly to prevent recursion and unrelated-command interception.

Quick Start

Add to ~/.claude/settings.json (user) or .claude/settings.json (project):

{"hooks":{"PreToolUse":[{"matcher":"Bash","hooks":[{"type":"command","command":"my-validator.sh"}]}]}}

Hook Events

Event When Blocks? Common Use
PreToolUse Before tool runs Yes Block/modify commands
PostToolUse After tool succeeds Feedback Auto-format, lint
PermissionRequest Permission dialog Yes Auto-approve/deny
UserPromptSubmit Prompt submitted Yes Add context, validate
Stop Claude finishes Yes Force continue
SessionStart Session begins No Load context, set env
Notification Notifications No Desktop alerts

Read the full file on GitHub · 322 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 322 lines · 32 tokens per session scan D 9f30e7151900

Subscribe to this mod's changes

cc-hooks is a skill published in the GitHub repository boshu2/agentops (431 stars, last pushed 5d ago), licensed Apache-2.0. It adds 32 tokens to every session and 3,929 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it D with 2 findings (reads agent configuration directories, recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

brainstorm

Explore vague or ambitious ideas into a right-sized requirements-only plan. Use when the user wants to brainstorm, think through scope, decide what to build, or needs collaborative product framing before planning, not for a decisive verdict on whether to adopt or switch to a specific external technology, library, or…

OutlineDriven/odin-claude-plugin · 85 tokens

doc-review

Use when the user asks to review or critique a prose planning document — a plan, spec, PRD, requirements doc, or design doc.

OutlineDriven/odin-claude-plugin · 32 tokens

audit-project

Run an iterative multi-agent code audit until critical and high findings are resolved. Use when the user says "audit my code", "find all the bugs", "deep code audit", "iterative review", or "review until clean".

OutlineDriven/odin-claude-plugin · 50 tokens

autolearn

Compound a solved problem into a durable in-repo learning doc. Use when a verified non-trivial fix lands, the user says "compound this", "document this fix", or "remember this". This is the automatic-capture entry point; for an explicitly requested one-off write-up, use compound.

OutlineDriven/odin-claude-plugin · 65 tokens

doubt-driven

Doubt-driven adversarial review. Use when correctness matters more than speed, the code is unfamiliar, stakes are high, a claim can't be checked by the type system or compiler, or verifying now is cheaper than debugging later.

OutlineDriven/odin-claude-plugin · 49 tokens

drift-detect

Use when the user says "plan drift", asks whether the roadmap, plans, or docs still match the code, or is deciding what to rebuild when restarting a stalled project. For doc-vs-code drift inside a specific diff, use sync-docs.

OutlineDriven/odin-claude-plugin · 56 tokens