Where does the bug appear (feature/product)?
Cursor CLI
Describe the Bug
Cursor CLI 2026.11.05-86047df, macOS, Cursor IDE 3.25.6 on the same machine.
Expected: hooks in ~/.cursor/hooks.json run in the CLI (docs and the January CLI notes say user and project hooks load the same way).
Actual: none of the hooks in ~/.cursor/hooks.json fire in the CLI, neither in an interactive session nor with agent -p, with or without --trust, in a git repo or a plain
folder. The same file fires in the IDE.
Repro
~/.cursor/hooks.json(valid,"version": 1):{"version":1,"hooks":{"sessionStart":[{"command":"bash /tmp/probe.sh sessionStart"}],"preToolUse":[{"command":"bash /tmp/probe.sh
preToolUse"}],“beforeShellExecution”:[{“command”:“bash /tmp/probe.sh beforeShell”}],“stop”:[{“command”:“bash /tmp/probe.sh stop”}]}}
```
where probe.sh appends "$1" and the stdin JSON keys to /tmp/probe.log and exits 0.
2. mkdir t && cd t && git init
3. agent -p --force "Run the shell command: echo canary. Then reply with the single word done."
4. /tmp/probe.log is never created.
Control (same machine, same version): the same hooks in ./.cursor/hooks.json in the workspace root. sessionStart, preToolUse and beforeShellExecution then fire (with
and without --trust). stop did not fire in -p mode.
Also checked
- A
hooks.jsonin a parent folder of the workspace is not picked up. - User-level hooks in
~/.claude/settings.jsonare not loaded either. - The IDE fires the full set for the same prompt: beforeSubmitPrompt, preToolUse/postToolUse, beforeReadFile, beforeShellExecution/afterShellExecution, afterFileEdit,
afterAgentResponse, stop. --debuglistshooks_configand “Team hooks config merged” but shows no user-hook execution, so there is no sign of a spawn failure.
Related: Hooks not firing. Cannot have guardrails (Windows, user-level hooks not run) and Cursor-agent CLI never invokes hooks.json on Linux (2026.08.11) — same version works on macOS (Linux, no hook invoked). In both, the reply says hooks are spawned and then
fail. Here a probe that writes a file on its first line never runs, while project-level hooks with the same command work.
Steps to Reproduce
- Create a probe script:
cat > /tmp/probe.sh <<‘EOF’
#!/usr/bin/env bash
echo “$(date +%T) $1 $(cat | head -c 200)” >> /tmp/probe.log
echo ‘{}’
EOF
chmod +x /tmp/probe.sh && rm -f /tmp/probe.log - Put user-level hooks in ~/.cursor/hooks.json (back up any existing file):
{“version”:1,“hooks”:{“sessionStart”:[{“command”:“bash /tmp/probe.sh sessionStart”}],“preToolUse”:[{“command”:“bash /tmp/probe.sh
preToolUse”}],“beforeShellExecution”:[{“command”:“bash /tmp/probe.sh beforeShell”}],“stop”:[{“command”:“bash /tmp/probe.sh stop”}]}} - mkdir /tmp/t && cd /tmp/t && git init -q
- agent -p --force “Run the shell command: echo canary. Then reply with the single word done.”
- cat /tmp/probe.log → the file does not exist (an interactive agent session gives the same result).
- Control: mkdir -p /tmp/t/.cursor && cp ~/.cursor/hooks.json /tmp/t/.cursor/hooks.json, delete /tmp/probe.log, repeat step 4. sessionStart, preToolUse and beforeShell now appear
in /tmp/probe.log (stop does not appear in -p mode).
Expected Behavior
Hooks in ~/.cursor/hooks.json run in the CLI, as they do in the IDE. The docs and the January 2026 CLI notes say user and project hooks load the same way. In step 5, /tmp/probe.log
should contain sessionStart, preToolUse and beforeShell entries.
Operating System
MacOS
Version Information
Current Cursor Version: CLI 2026.11.05-86047df and IDE 3.25.6.
Does this stop you from using Cursor
No - Cursor works, but with this issue