By karanb192
Production-ready Claude Code hooks, each installable on its own as a plugin.
Trending marketplaces
7-day visitors to each marketplace page
npx claudepluginhub karanb192/claude-code-hooksA per-file context-cost leaderboard for Claude Code. A PostToolUse hook (async, zero added latency) attributes every tool result's tokens to the file(s) it pulled into context; at SessionEnd (or on demand via /context-hogs:leaderboard) it renders your repo's most token-expensive files with estimated cost, so you know which files to trim.
The comeback price of a cold prompt cache, shown before you pay it. A UserPromptSubmit guard warns (or refuses once) when your next message will re-write a lapsed 1-hour cache at up to 80x the read rate, a SessionStart hook prices a stale resume, and the same script is a one-line status line segment with the minutes left and the cold-comeback cost.
A personal flight recorder for Claude Code quality. Background hooks (async, zero added latency) record your own per-session signals keyed by model id and Claude Code version: tool-failure rate, same-file edit churn, turn-end counts, and tokens-per-completed-task. At your next SessionStart (or on demand via /nerf-receipts:receipts) it renders a trend card with sparklines and flags meaningful shifts that coincide with a model change, so the next time someone says "they nerfed it" you have data instead of vibes.
A CLAUDE.md compliance flight-recorder for Claude Code. At SessionStart it parses CLAUDE.md into numbered atomic rules; on every Edit/MultiEdit/Write a PostToolUse hook (async, zero added latency) passively tallies how often each rule was relevant and whether it was followed or violated; at SessionEnd (or on demand via /dead-rules-audit:scorecard) it renders a worst-first compliance scorecard with a promote-to-hook hint for chronically-ignored rules. Zero deps, zero network, fully deterministic.
Embeds a reviewer-facing provenance receipt into your PR body when Claude runs `gh pr create` (or `glab mr create`). A PostToolUse hook (async, zero added latency) records a per-session ledger: tool calls, agent-authored lines, and every test/typecheck command with its real exit code; a PreToolUse (Bash) hook then rewrites the --body on `gh pr create` with the real prompt count, estimated spend, test tally, and a truthful agent-vs-human authored-line split. Preview it anytime via /pr-provenance-stamp:provenance.
Turns what your agents ACTUALLY did into a standup: captured from session transcripts (not commits/tickets, which miss uncommitted work, real test exit codes, and unresolved errors) and rolled up cross-repo. Stop/SessionEnd snapshot each session's outcome (task, branch + diffstat, tests + exit codes, PRs, blockers) to a local per-day ledger; SessionStart re-injects yesterday's unresolved blockers via additionalContext and prints a standup-ready card. Render today's card any time via /standup-autopilot:standup.
Approach-level negative-knowledge memory for Claude Code. Mines your transcripts (Stop/PreCompact, both async and zero added latency) for approaches you TRIED and then REVERTED (with the reason, date, and estimated token cost of the detour) into a per-repo registry. On UserPromptSubmit it injects a 'you already tried this' warning card when a new prompt matches a recorded dead end; on PreToolUse (Edit|Write) it asks before an edit reintroduces a previously-reverted hunk. Review the registry any time with /dead-end-registry:dead-ends.
Turns your repo's tech debt into an aging bounty economy. A SessionStart hook scans tracked files and prices each TODO/FIXME/HACK/skip as a wanted-poster bounty whose XP grows with its git-blame age, injects the top 3 as opportunistic side quests, and, via a PostToolUse hook, verifies and pays out bounties that genuinely disappear. SessionEnd renders a payout card, and /bounty-board:board shows the current board on demand.
A PreToolUse guard for Bash that blocks dangerous shell commands before they execute: rm targeting home/root/system dirs, dd to disk devices, mkfs, fork bombs, curl|sh, force push to main, git reset --hard, chmod 777, docker volume rm, and more. Three safety levels (critical/high/strict, picked via HOOK_SAFETY_LEVEL) control how much is blocked, and per-level ask mode (HOOK_ASK_*) turns a hard deny into a prompt you approve or reject. Every block is logged with the pattern id and reason.
A secrets firewall for Claude Code. A PreToolUse hook screens every Read, Edit, Write, Bash, and Grep call against tiered patterns (critical/high/strict): sensitive files like .env, SSH keys, AWS/kube/gcloud/docker credentials, and keystores, plus shell commands that expose or exfiltrate them (cat .env, printenv, echo $SECRET_KEY, curl/scp/rsync uploads) and delegation sinks that feed a secrets file or a secret env var to an external model CLI (gemini, codex, llm, sgpt, aichat, openai, mods, fabric) or a model API host; the opt-in strict level also flags any file contents sent that way. Matches are denied, or turned into a prompt via per-level ask mode, with the exact pattern id and reason; .env.example-style templates stay allowed. Safety level is tunable via HOOK_SAFETY_LEVEL, no file edits needed.
Branch-aware git guardrails for Claude Code. A PreToolUse hook on Bash that denies destructive git and gh CLI operations before they run: pushing to main/master, deleting protected branches, commit/merge/rebase/reset/push while on a protected branch, and gh pr merge/close, issue close, release delete, repo delete. Three safety levels (critical/high/strict) selectable via HOOK_SAFETY_LEVEL; every block is logged.
Stops the "fake green" failure mode for Claude Code. A PreToolUse guard on Bash|Edit|MultiEdit|Write that denies making a suite pass by deleting test files or directories (rm / git rm), renaming a test to a disabled name (.bak, .disabled, ...), or adding a skip/xfail/ignore marker to an existing test (by Edit, a whole-file Write, or a sed -i / perl -pi / redirect from the shell), across pytest, unittest, jest/mocha/vitest, Go, JUnit/TestNG, NUnit/MSTest, RSpec, and Rust. Never blocks writing new, real tests or editing test bodies. Three safety levels (critical/high/strict), tunable via HOOK_SAFETY_LEVEL.
Stops `rm -rf content` silently destroying `Content` on case-insensitive filesystems (APFS default, exFAT, NTFS). A PreToolUse hook on Bash that resolves the real target of destructive commands (rm, rmdir, mv, mkdir, touch, find -delete) through cd/pushd chains, quotes, subshells, and heredocs, and denies the ones that would hit a differently-cased entry of what was typed. Three safety levels (HOOK_SAFETY_LEVEL), per-level ask mode instead of hard deny.
Who guards the guards: a PreToolUse hook that blocks the agent from tampering with its own guardrail configuration. Deny-by-default protection for settings.json, hook scripts and hooks.json manifests, installed plugins under ~/.claude/plugins, .mcp.json and ~/.claude.json, plugin manifests, and (at strict level) CLAUDE.md and rules/agents/commands, across Bash, Edit, MultiEdit, and Write, including `claude config/mcp/plugin` CLI writes. Reads always pass; symlinked paths are resolved; creating a protected file counts as mutation (the CVE-2026-25725 vector). Escape hatch via CONFIG_GUARD_ALLOW=true, per-level ask mode via HOOK_ASK_*.
A total-spawns-per-session budget for subagents: a PreToolUse guard on the Agent tool that counts every spawn in a session (nested spawns from inside subagents included), asks for approval at SPAWN_CAP_ASK (default 20) and every SPAWN_CAP_ASK_STEP spawns after it (default 10), and denies at SPAWN_CAP_DENY (default 60): prompts at 20, 30, 40, 50, hard stop at 60. Closes the gap left when Claude Code 2.1.224 removed its native per-session spawn cap; the native concurrency and depth caps bound the rate, not the total. Append-only per-session ledger, so parallel spawns in one turn are all counted. SPAWN_CAP_ALLOW=true lets spawns through while set, still counted.
Tripwire for out-of-band config changes in Claude Code. A ConfigChange hook fires whenever settings (user, project, local, policy) or skills change mid-session, from an installer script, an npm postinstall payload, or any other process rewriting settings while a session runs, and makes the change loudly visible via systemMessage. Opt into CONFIG_WATCH_BLOCK=true to stop the change from taking effect (exit 2); policy_settings cannot be blocked by hooks, so those still warn. Pairs with config-guard, which blocks the agent's own writes.
Automatic git staging for Claude Code. A PostToolUse hook on Edit|Write runs `git add` on every file Claude modifies, so `git status` always shows exactly what Claude touched and pre-commit review needs no manual staging. Files outside a git repo are skipped, .gitignore is respected (ignored files fail to stage and the failure is logged, never forced), and the git call is shell-free so hostile filenames cannot inject commands.
Auto-formats files the moment Claude writes them. A PostToolUse hook on Write|Edit runs ruff (check --fix + format, via uv) on Python and prettier (via npx) on JS/TS/JSON/MD/YAML/HTML, resolving relative paths against the session cwd and passing file paths as argv so shell metacharacters in filenames can never inject commands. Unsupported types and missing files are skipped silently, formatter failures never block the session, and every outcome logs to ~/.claude/hooks-logs/.
A durable, greppable markdown log of every Claude Code session. SessionStart seeds a note (timestamps, cwd, git repo/branch), an async PostToolUse hook appends every Edit/Write/Read/Bash with zero added latency (bash commands truncated and secret-redacted, concurrent writes serialized via a file lock), and SessionEnd finalizes it with an ended timestamp and final git status. Point CC_SESSION_LOG_DIR at an Obsidian vault for cross-device sync.
A prompt-injection tripwire for instruction files. Audits CLAUDE.md / .claude/rules/*.md content and flags hidden or hostile directives: invisible Unicode smuggling (zero width characters, tag characters, variation-selector runs; the TrapDoor supply-chain signature), bidi overrides, directives to read or exfiltrate secrets, curl|sh, decode-and-execute, and hook/settings tampering. Files that load during a session are audited by an InstructionsLoaded hook. The files read at session start load before plugin hooks register, so the first UserPromptSubmit or PreToolUse of each session audits them as they are on disk (with their @ imports) before the model acts. A finding locks the session and every prompt and tool call is denied until a human fixes the file or clears the named lock. Tune via HOOK_AUDIT_LEVEL (critical/high/strict) and HOOK_AUDIT_WARN_ONLY, no file edits needed.
Slack alerts when Claude Code needs you. A Notification hook on permission_prompt|idle_prompt|elicitation_dialog classifies each notification (from notification_type when present, else from keywords in the message) and posts a Slack Block Kit card to your CCH_SLA_WEBHOOK: a tool-specific title (Bash/Write/Edit/Read permission, waiting, or a choice to make), project name, short session id, the message truncated to 200 chars, the full cwd, and a timestamp. No webhook set means a logged no-op; the hook always exits 0 and never blocks your session.
All seven guard hooks in one Node process: subagent-spawn-cap, config-guard, block-dangerous-commands, protect-secrets, protect-tests, git-safety, and case-insensitive-guard, evaluated in that order with the first blocking verdict winning in that guard's own output format. Installing the guards individually costs seven Node startups per matching tool call (about 35 ms each); the pack pays one. Env vars pass straight through (HOOK_SAFETY_LEVEL for the six pattern guards uniformly, HOOK_ASK_*, CONFIG_GUARD_ALLOW, SPAWN_CAP_ASK / SPAWN_CAP_ASK_STEP / SPAWN_CAP_DENY / SPAWN_CAP_ALLOW). Do not install alongside the individual guard plugins: duplicated guards run twice. Also runs natively in Codex CLI: shell commands and apply_patch edits are checked, and an ask verdict is sent as a block because Codex hooks cannot ask.
🪝 Guardrails for Claude Code and Codex CLI. Browse the 22-plugin marketplace and check host compatibility.
Before an agent runs a shell command or edits a file, these hooks check the action against rules outside the model. The guard pack blocks matched secret reads, dangerous commands, test disabling and destructive Git operations. A blocked call returns a reason to the agent. The coverage limits matter: hooks only see the events their host sends, and pattern checks are not a sandbox. The rewrite record lists the command spellings the shell guards must refuse, the mentions they must allow, and the ones they still miss. The catalog also includes Claude Code automation, notifications and observability, with an OWASP mapping.
Start with guard-pack. Choose your agent:
Claude Code, inside a session:
/plugin marketplace add karanb192/claude-code-hooks
/plugin install guard-pack@claude-code-hooks
Restart Claude Code after installing.
Codex CLI, from a shell:
codex plugin marketplace add karanb192/claude-code-hooks
codex plugin add guard-pack@claude-code-hooks
Open /hooks in Codex and approve the pack. Approve it again after updates; Codex skips unapproved or changed hooks. Do not install the pack alongside its individual guards. See the Codex compatibility table before choosing other plugins.
| Protecting Secrets | Blocking Dangerous Commands |
|---|---|
![]() | ![]() |
A growing collection of tested, documented hooks. Every one installs as a one-command Claude Code plugin: run /plugin marketplace add karanb192/claude-code-hooks, then /plugin install <name>@claude-code-hooks; see Install as a plugin for the 22-plugin catalog. Prefer to own the file? Every plugin's script also works standalone: copy plugins/<name>/<name>.js and wire it into settings.json yourself (Quick Start).
Every hook below is an installable plugin; each link goes to the plugin's directory, which holds the script, its tests, and a README. They're grouped by the event that fires them, because the event model is the thing worth learning.
Runs at session boundaries: inject context at SessionStart and capture outcomes at Stop / SessionEnd.
7-day visitors to each marketplace page
RuFlo Marketplace: Claude Code native agents, swarms, workers, and MCP tools for continuous software engineering
Claude Code marketplace entries for the plugin-safe Agentic Awesome Skills library and its compatible editorial bundles.
Directory of popular Claude Code extensions including development tools, productivity plugins, and MCP integrations