Skip to content

fix(cursor): run SessionStart via run-hook.cmd on Windows - #1250

Closed
sgoettl17 wants to merge 1 commit into
obra:mainfrom
sgoettl17:fix/cursor-windows-sessionstart-hook
Closed

sgoettl17 wants to merge 1 commit into
obra:mainfrom
sgoettl17:fix/cursor-windows-sessionstart-hook

Conversation

@sgoettl17

Copy link
Copy Markdown

Problem

On Windows, Cursor runs plugin sessionStart hook commands under CMD. The Cursor hooks file pointed at ./hooks/session-start, an extensionless bash script. CMD does not execute it as bash; Windows shows the file-association / Open with dialog when a new agent session starts.

Fix

Use the same run-hook.cmd polyglot wrapper already used by hooks/hooks.json for Claude Code SessionStart: ./hooks/run-hook.cmd session-start. That locates Git Bash and runs the script.

Plugin-relative ./hooks/... matches the Cursor plugins reference pattern for hook commands.

Testing

From the plugin root, cmd /c ".\hooks\run-hook.cmd session-start" returns valid JSON with additional_context on Windows with Git for Windows installed.

Cursor runs plugin hook commands under CMD.exe. Invoking the extensionless
bash script session-start directly triggers the Windows file-association
dialog. Delegate to the existing polyglot run-hook.cmd (same pattern as
hooks.json for Claude Code) so Git Bash runs session-start.

Made-with: Cursor
Copilot AI review requested due to automatic review settings April 22, 2026 16:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Cursor’s sessionStart hook command to execute the existing Windows-compatible run-hook.cmd wrapper so the session-start script runs under Git Bash instead of being handled by CMD file-association behavior.

Changes:

  • Switch Cursor sessionStart hook from ./hooks/session-start to ./hooks/run-hook.cmd session-start.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hooks/hooks-cursor.json
"sessionStart": [
{
"command": "./hooks/session-start"
"command": "./hooks/run-hook.cmd session-start"

Copilot AI Apr 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command path isn’t quoted. If the plugin root path contains spaces (common on Windows, e.g. under "Program Files"), CMD will treat ./hooks/run-hook.cmd as multiple tokens and the hook won’t run. Quote the script path (as done in hooks/hooks.json) so run-hook.cmd is invoked reliably, then pass session-start as the argument.

Suggested change
"command": "./hooks/run-hook.cmd session-start"
"command": "\"./hooks/run-hook.cmd\" session-start"

Copilot uses AI. Check for mistakes.
@obra obra added hooks Hook system (SessionStart, Stop, etc.) windows cursor Cursor IDE integration pr-template-rules-ignored PR filed after template was added but didn't use it labels Apr 27, 2026
@arittr

arittr commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR. This is the same hooks/hooks-cursor.json change as the newer #1280, so let’s keep #1280 as the active review thread for the Cursor Windows hook fix.

Closing this one as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cursor Cursor IDE integration hooks Hook system (SessionStart, Stop, etc.) pr-template-rules-ignored PR filed after template was added but didn't use it windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants