Ship fast. Break nothing.Claude Code hooks — plus Codex & Copilot — in one command
Security, quality and workflow guardrails your agent can’t skip.
- 105 hooks
- Open-source · MIT
- Hooks unit-tested
- Security scanned
Up and running in 60 seconds
$ npx hookstack-cli@latest install Will writes the hooks into .claude/hooks and patches settings.json — nothing else.
What hooks actually do
Watch your hooks ship a feature
Hooks fire on the agent's lifecycle — guardrails before risky actions, automation after. Scroll through one feature shipping under their watch.
A feature lands on your plate
“Add Stripe checkout.” The agent starts on main — exactly where it shouldn’t.
session-start-load-git-context
"Add Stripe checkout"
Browse the Claude Code hooks catalogue
Security
15Secret detection before Bash execution
Catch a leaked API key before it ever runs
Destructive command blocking
Stops a disk-wiping shell command before it runs
Sensitive file write protection
Your .env and keys stay untouched by the agent
Lock file write protection
Lock files stay intact - package manager only
git push to main guardrail
No accidental push straight to main
Auto-approve read-only permissions
Stop clicking approve on harmless reads
Redact secrets from displayed output
Secrets never show on screen during a share
Block file writes on main branch
Blocks edits on main until you branch
Write-time secret detection
No API key ever lands in a file
Env file read guard
Your .env secrets never enter the model context
PII redactor for display
Prevents credit card numbers, IBANs, SSNs and emails from ever appearing on screen
Block remote script piped to shell
No "curl | sh" runs unaudited code on your machine
Force-push guard (any branch)
Force-with-lease only — never clobber a teammate
Sudo usage warning
Flags privilege escalation before it hangs your loop
Env file gitignore guard
A new .env can never sneak into a commit unignored
Context
17Project conventions injection
The agent follows your conventions, unprompted
Load Git context at startup
Starts every session knowing your repo state
Current date and time injection
No more answers stuck on last year's date
Automatic session naming
Each session gets a name, not a hash
Structured tool failure log
Every tool failure logged for the post-mortem
Re-inject context after compaction
Conventions survive a context compaction
Inject context on skill invocation
Auto-attach a checklist to any slash command
Auto-pull on main at session start
Always start from a fresh, up-to-date main
Stale stash warning at session start
Warns you about that WIP stash you forgot
WebSearch temporal context injector
Prevents stale search results by silently adding the current year
AGENTS.md context loader
Auto-loads your AGENTS.md so every session starts with full agent context
Binary file to Markdown converter
Read any PDF, DOCX or PPTX as clean Markdown — slash token usage on binary files
Binary file read blocker
Stop Claude from wasting tokens trying to read .exe, .pyc, .pkl or .zip files
Large JSON/CSV compactor
Get a schema + row count instead of dumping 10 000 lines of JSON into context
WebFetch HTML-to-Markdown converter
Fetch any web page as clean Markdown — strip boilerplate HTML before it enters context
GitHub context loader
Open PRs and CI status loaded before you ask
Inject installed dependency versions
The agent codes against your real versions, not guesses
Validation
33Automatic formatting after write
Every file lands already Prettier-clean
Biome lint after write
TSLint errors fixed in the same loop, not in CI
TypeScript type checking
TSType errors caught the moment a file is saved
Run tests at end of response
Won't hand back until the test suite is green
Enforce package managers
TSForces uv and pnpm, kills pip/npm drift
Automatic quality check (Stop)
Types and lint must pass before Claude hands back control
Missing test detection (Stop)
No source file ships without a test
Per-modified-file coverage (Stop)
TSCatches the file that quietly dropped coverage
Per-modified-file lint (Stop)
TSBlocks the session on a lint error you introduced
Full i18n validation (Stop)
Ship no untranslated string, no orphan key
Typecheck after parallel file edits
TSOne tsc pass after a batch, not one per file
Auto-run tests when source files change
Tests rerun the moment a source file changes
Test suite gate before task completion
No task closes on a red build
Ruff format after write
PyPython lands PEP 8-clean on every save
Ruff lint after write
PyUnused imports caught before they pile up
Pyright type checking
PyPython type errors caught right after an edit
Enforce uv for Python dependencies
PyForces uv, ends pip/poetry drift
Run pytest at end of response
PyWon't hand back until pytest is green
Next.js App Router quality checker
TSCatches missing 'use client' and legacy Pages Router patterns before they silently break
Registry schema validation on change
Schema errors surface in-session, not in CI
Registry drift check at stop
Catalogue drift caught before CI rejects the PR
Motion rules guard
TSAnimation rule violations flagged as you write them
Conflict marker detector
Leftover merge conflict markers caught instantly
Code duplication guard
Warns on code duplication above threshold at session end
SEO page metadata guard
TSEvery page ships indexable — title + description set
Next.js image guard
TSStop a raw <img> from wrecking your LCP score
Single H1 heading guard
TSOne <h1> per page — the clean outline crawlers trust
JSX accessibility guard
TSWCAG violations caught on every JSX save, no plugin needed
SEO structure gate
TSYour SEO can't regress — gated like your test suite
Validate OKF bundle on edit
Catch a malformed knowledge entry the instant you save it
Block edits to generated folders
Never waste an edit on a file the build overwrites
Block oversized file writes
Stops a 500 KB dump from bloating your repo
Leftover debug statement guard
No stray console.log or print() slips into a commit
Notification
10Slack notification on agent event
Pings your Slack when the agent needs you
End-of-session audit log
Every session leaves an audit trail
Tool usage tracking
See exactly how hard each session works
TTS voice notification
Hear it out loud when the agent needs you
Voice task-completion announcement
Get told out loud the moment work is done
System sound notification
A chime to catch your attention, no voice needed
System sound on task completion
A satisfying chime the moment Claude finishes
Subagent start voice announcement
Hear each subagent spin up
Subagent end voice summary
Hear each subagent finish, no audio clash
Desktop notification on rate limit
Get pinged when a rate limit pauses Claude
Workflow
22Worktree guardrail (Edit/Write)
Edits never leak back into your main repo
Worktree env initialization
New worktrees boot with their own env and ports
Worktree dependency update
TSEvery worktree starts with fresh dependencies
Auto-disable Stop hook after N failures
A flaky Stop hook can't trap your session
Transcript backup before compaction
Your full transcript survives every compaction
Dependency check and install at startup
TSPyOpen a session, environment's already ready
Temporary file cleanup at session end
Sessions end with a clean logs directory
Configuration change audit log
Every settings.json change is on the record
Reload direnv on directory change
Bash always runs in the right env per folder
Automatic ExitPlanMode approval
Plans proceed without the extra approval click
Reload .env on file change
Edit .env and Bash picks it up instantly
Clean up artifacts on worktree removal
Removing a worktree reclaims its disk and containers
Log API errors to file
Every API error logged for the post-mortem
Enforce task naming conventions
Every task ties back to a [TICKET-123]
Log auto-mode permission denials
See what auto-mode silently blocked
Install project dependencies on init
TSFresh clone opens with node_modules ready
Audit log for CLAUDE.md file loads
Know exactly which CLAUDE.md governed a session
Auto-create worktree when starting on main
Start on main and you're moved to a worktree
Registry auto-sync
hooks sync automatically whenever the catalogue changes
Block push on closed PR
prevents accidentally pushing to a merged or closed PR branch
Front-end visual check reminder
Never ship UI you only saw in the diff
Node version mismatch check
Catch a wrong Node version before it bites at build time
Documentation
8Session summary generation
An automatic changelog of what the agent shipped
Save compaction summary to log
Keep a readable trail of every compaction
Docs consistency reminder
No more READMEs telling two different stories
Force implementation doc at stop
No code change ships without a doc/implementation/ trace
OKF bundle staleness reminder on session start
Never let your project knowledge base go stale and lie to you
OKF bundle staleness reminder at stop
End no session without refreshing a stale knowledge base
Dead link checker
No broken links in Markdown docs you ship — checked automatically at session end
Dead image checker
No broken images in your Markdown docs — checked automatically at session end
settings.json configuration.Hooks vs slash-commands vs prompt instructions
Three ways to steer Claude Code — only one is guaranteed to run on every action.
| Agentic hooks | Slash-commands | Prompt instructions | |
|---|---|---|---|
| How it runs | Node.js script, outside the model | You type it; the model interprets | Text the model may follow |
| Deterministic? | Yes — fires unconditionally | No — the model decides | No — probabilistic |
| Can it be skipped? | No | Yes | Yes |
| Token cost | Zero (separate process) | Consumes context | Consumes context |
| Best for | Guardrails, gates, automation | On-demand interactive tasks | Soft guidance & style |
New to hooks? Read the guides or learn who builds HookStack.
Learn more about Claude Code hooks
- What Are Claude Code Hooks? A Practical GuideClaude Code hooks are commands that run automatically at lifecycle events. See the lifecyc…
- PreToolUse vs PostToolUse: Which Claude Code Hook to UsePreToolUse runs before a tool and can block it; PostToolUse runs after and reacts. See two…
- Claude Code Hooks vs Slash Commands vs Prompt InstructionsHooks, slash commands, and prompt instructions steer Claude Code at different levels. See …
- Claude Code Hooks Not Working? A Troubleshooting GuideClaude Code hook not firing, output ignored, or breaking your session? Diagnose the common…
- Write Your First Claude Code Hook in 5 MinutesA step-by-step tutorial: create the hooks folder, write a Bash command logger, register it…
- Claude Code settings.json: The Complete ReferenceA complete reference for Claude Code settings.json: where it lives, hooks and permissions …
- 10 Claude Code Hooks Worth Installing (With Examples)A curated list of useful Claude Code hooks examples: block secrets and destructive command…
- How to Secure Claude Code with HooksSecure Claude Code with deterministic hooks: block destructive commands, prevent secrets l…
- Automate Code Quality in Claude Code with HooksAutomate code quality in Claude Code with hooks: run formatters, lint on write, typecheck …
- Inject Context into Claude Code with HooksUse UserPromptSubmit and SessionStart hooks to inject context into Claude Code — conventio…
- SEO & Accessibility Guardrails for Next.js with HooksGuarantee SEO metadata, heading hierarchy, next/image, and accessible JSX in your Next.js …
- Isolate Agent Work with Git Worktrees and HooksIsolate Claude Code agent work with git worktree hooks: auto-redirect from main, provision…
- Claude Code Hooks for Python (ruff, pytest, pyright)Claude Code hooks for Python: run ruff, pyright, and pytest via uv — no virtualenv activat…
- OpenAI Codex Hooks: Setup, Config, and ExamplesOpenAI Codex hooks run commands at lifecycle events, just like Claude Code. See the .codex…
Frequently asked questions
- What is an agentic hook?
- An agentic hook is a Node.js script triggered by Claude Code lifecycle events — PreToolUse, PostToolUse, SessionStart, Stop. Hooks enforce deterministic behavior in agentic workflows: block dangerous commands, run tests automatically, inject context, and notify your team — without relying on the LLM to remember.Read the full guide →
- How do agentic hooks improve vibe coding?
- Vibe coding lets an AI agent like Claude Code drive most of your implementation while you set direction. Hooks add CI-like guardrails that fire on every agent action — making your agentic workflow production-safe, auditable, and repeatable regardless of what the model decides to do.Read the full guide →
- Does HookStack work with GitHub Copilot?
- Yes. The hookstack-cli installs the same hooks for GitHub Copilot — the hook scripts (.mjs) are identical, only the config file paths are adapted. Run npx hookstack-cli@latest install --copilot in your project root. Because Copilot and Claude Code share the same lifecycle events (PreToolUse, PostToolUse, SessionStart, Stop), a HookStack hook is portable with no code changes.
- Does HookStack work with OpenAI Codex?
- Yes. The hookstack-cli installs the same hooks for OpenAI Codex into a .codex/hooks.json config file, with the hook scripts in .codex/hooks/. Use npx hookstack-cli@latest install --codex-project to commit the config with your repo, or --codex-profile to apply it to every project via ~/.codex/hooks.json. Codex and Claude Code share the same lifecycle event names (PreToolUse, PostToolUse, SessionStart, Stop), so the hook code (.mjs) is identical — only the config format differs.
- Why are Claude Code hooks better than prompt instructions?
- Prompts are probabilistic — the model may or may not follow them. Claude Code hooks are deterministic Node.js scripts that execute unconditionally on matching events. No drift, no hallucination, no forgotten rules. That guarantee is what makes agentic workflows trustworthy in production.Read the full guide →
- How do I install Claude Code hooks with HookStack?
- Browse the catalogue, select the hooks you want, then run the generated npx hookstack-cli@latest install command in your project root. HookStack writes the scripts to .claude/hooks/ and patches your settings.json — nothing else touched.Read the full guide →
- I already use Claude Code commands like /gen-test-unit or /create-worktree — aren't hooks the same thing?
- Commands are interactive: you type them, Claude reads and acts on them inside the conversation. Hooks are the opposite — Node.js scripts that fire unconditionally outside the model, triggered by lifecycle events (PreToolUse, PostToolUse, Stop…). The model never sees them, never decides whether to run them, and can't skip them. Commands steer the AI; hooks constrain it.Read the full guide →
- Do hooks consume tokens from my context window?
- No. Hooks run in a separate process, outside the model entirely. They can inject context back into the session via stdout, but the hook scripts themselves — and whatever they compute — are never sent to the model unless you explicitly return a message. Commands, on the other hand, are part of the conversation and consume context. Hooks are a zero-cost enforcement layer.Read the full guide →