Do you have some example of how creating a hook in Windows and return 0? My created hooks exit with 1 and the logs are displayed as if the hook had failed.
Also, what would be the best solution for running hooks in a cross platform way? (like running the same command in windows and linux)
Why you see “exit code: 1” even with trivial hooks
Several current Windows-specific issues can make even a trivial hook “fail” with exit code 1 even though the command works in a regular terminal:
Shell mismatch / PowerShell snippet sent to Bash:
If your integrated terminal profile is Git Bash, Cursor’s internal PowerShell-based hook bootstrap is sent to Bash and explodes with syntax errors like [Convert]::FromBase64String, causing an exit 1 before your script runs.
Launcher bug for hooks on Windows:
There are cases where a minimal echo '{\"continue\":true,...}' hook works in a normal terminal but fails from Cursor with a low-level error and exit code 1. That failure happens in Cursor’s hook launcher layer, not in the script.
Project-level hooks not executing / no output:
Hooks are recognized and “processed” but don’t actually run, yielding no stdout and appearing as failed.
Given that, a few pragmatic steps:
Force PowerShell in the command
Always start your hook with powershell -NoProfile -ExecutionPolicy Bypass ... instead of relying on the default terminal profile.
Return JSON and exit 0 explicitly
JSON to stdout (single object, no extra noise): e.g. {"continue":true,"permission":"allow"}.
Explicit exit 0 at the end of the script, especially in .ps1 or .bat.
Check Cursor’s Hooks output panel
View → Output → select “Hooks”.
If you see PowerShell/Bash syntax errors or low-level launcher errors, the launcher is failing before your script; in that case your code is fine and you’re hitting a Cursor bug.
Work around known Windows bugs
Temporarily use user-global hooks instead of project-level if the latter are flaky in your build.
Try switching Cursor’s integrated terminal profile to PowerShell in settings, at least while debugging hooks.