Cursor hooks never fire (or fail open). Fix the path, exit code, and Hooks log
If a Cursor hook never runs or fails open, fix hooks.json and the script path, block with exit code 2 or failClosed, then read Output → Hooks. Short answer: 5 steps. 1) Confirm the hooks.json Cursor actually loads; 2) Fix relative paths and restart if the file never reloads; 3) Block with exit code 2 (or valid deny JSON), not a generic non-zero; 4) Turn on failClosed for security-critical hooks; 5) Separate Cursor hooks from Claude Code imports.
Last updated: · This page is the decision checklist; the tools list for “Fix Cursor hooks that never fire or fail open” is a separate URL.
How do I fix the path, exit code, and Hooks log when Cursor hooks never fire?
Confirm the hooks.json Cursor actually loads
Project hooks live at `/.cursor/hooks.json` and run from the project root (script paths like `.cursor/hooks/script.sh`). User hooks live at `~/.cursor/hooks.json` and run from `~/.cursor/` (paths like `./hooks/script.sh`). Enterprise/team hooks can also apply. Open Customize → Hooks and View → Output → Hooks to see configured hooks and load errors. Docs: https://cursor.com/docs/hooks
Fix relative paths and restart if the file never reloads
Cursor watches hooks.json and reloads on save, but a wrong relative path means the command never starts. For project hooks, do not use `./hooks/...` unless that folder exists at the repo root—prefer `.cursor/hooks/...`. Make scripts executable (`chmod +x`). If Hooks still shows nothing after a save, fully restart Cursor.
Block with exit code 2 (or valid deny JSON), not a generic non-zero
For permission hooks (`beforeShellExecution`, `beforeMCPExecution`, and related), exit `0` and return schema-valid JSON to allow/ask/deny. Exit `2` blocks (same as `permission: "deny"`). Any other non-zero exit fails open by default—the action proceeds while Cursor logs the failure. Invalid JSON on those permission hooks blocks even when failClosed is false.
Turn on failClosed for security-critical hooks
Set `"failClosed": true` on the hook definition when a crash, timeout, missing binary, or non-zero exit (other than the intentional allow path) must block the action. Cursor’s docs call this out especially for security-critical `beforeMCPExecution` hooks. Without it, a broken guardrail silently lets the tool run.
Separate Cursor hooks from Claude Code imports
Claude Code hooks in `.claude/settings.json` only load when third-party imports are enabled (Cursor Settings → Agents → Include Third-Party Plugins, Skills, and Other Configs). They still use exit code `2` to block. If only Claude hooks fail, validate that JSON and the import toggle; if Cursor hooks fail, stay on `.cursor/hooks.json`. Third-party reference: https://cursor.com/docs/reference/third-party-hooks
Which tools are best to fix Cursor hooks that never fire or fail open?
Cursor Hooks
hooks.json locations, exit codes, failClosed, and the Hooks output channel.
Third Party Hooks
How Claude Code hooks import into Cursor and share exit code 2 blocking.
Agent troubleshooting
Broader Agent failures to rule out when the Hooks channel is clean.
Claude Code hooks guide
If you maintain shared hooks for both Claude Code and Cursor imports.
Open: 1 spot per week
One labeled sponsor for this topic each week; this week's spot is open. See open weeks →
All tools for “Fix Cursor hooks that never fire or fail open” →
Related fixes
- Stop a Cursor agent loopHow to fix a Cursor agent loop (same edit, or work after Stop)Fix →
- Claude Code vs Codex vs Cursor ~$20 plansClaude Code vs Codex vs Cursor $20 plan limits: how to pick without burning the weekFix →
- Scan a vibe-coded app for leaked API keysCheck a vibe-coded app for leaked API keys before you share itFix →
- Add an MCP server to Claude Code, Cursor, or CodexHow to add an MCP server to Claude Code, Cursor, or CodexFix →
See also AI tools launched today on the daily board.
NewAIToolsToday Daily
Top 3 AI launches, one model or news item that matters, and one simple fix. A 5-minute read, every weekday.