Submit a toolSubmit

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.

The problem: 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.
Official docs: cursor.com, cursor.com

How do I fix the path, exit code, and Hooks log when Cursor hooks never fire?

  1. 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

  2. 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.

  3. 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.

  4. 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.

  5. 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.

All tools for “Fix Cursor hooks that never fire or fail open” →

Related fixes

See also AI tools launched today on the daily board.