Skip to content

Fix sessionStart hook for Cursor#709

Closed
kevinzwang wants to merge 1 commit intoobra:mainfrom
kevinzwang:kev/cursor-hooks-support
Closed

Fix sessionStart hook for Cursor#709
kevinzwang wants to merge 1 commit intoobra:mainfrom
kevinzwang:kev/cursor-hooks-support

Conversation

@kevinzwang
Copy link

Problem

The superpowers plugin's sessionStart hook doesn't fire in Cursor. The current hooks.json uses the Claude Code hooks format (SessionStart, matcher, nested hooks array), which Cursor doesn't recognize. Cursor expects a different schema — sessionStart (camelCase) with a flat command field.

Changes

  • Add hooks/hooks-cursor.json using Cursor's hooks format
  • Update plugin.json to reference the new Cursor-compatible hooks file
  • Existing hooks.json is unchanged for Claude Code compatibility

The existing hooks.json uses the Claude Code hooks format. This adds
hooks-cursor.json with the Cursor hooks format and points plugin.json
to it so session-start hooks work correctly in Cursor.
@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

📝 Walkthrough

Walkthrough

The pull request updates the Cursor plugin configuration to reference a new hooks manifest file and introduces that manifest file. The new hooks-cursor.json defines a session start hook pointing to session-start.sh, establishing the hook trigger mechanism for the Cursor environment.

Changes

Cohort / File(s) Summary
Plugin Configuration
.cursor-plugin/plugin.json
Updated hooks entry point from ./hooks/hooks.json to ./hooks/hooks-cursor.json.
Cursor Hooks Manifest
hooks/hooks-cursor.json
New hooks manifest file added, defining version and registering ./hooks/session-start.sh as the sessionStart hook trigger.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

Suggested labels

bug, hooks

Poem

🐰 A hop, a skip, a config change,
Hooks now point to paths rearranged,
SessionStart shall spring to life,
Cursor plugin, sharp and bright!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: fixing the sessionStart hook for Cursor by adding Cursor-compatible hook configuration.
Description check ✅ Passed The description clearly explains the problem (hook format incompatibility), the solution (new Cursor-specific hooks file), and implementation details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can customize the high-level summary generated by CodeRabbit.

Configure the reviews.high_level_summary_instructions setting to provide custom instructions for generating the high-level summary.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@hooks/hooks-cursor.json`:
- Line 6: The "command" value "./hooks/session-start.sh" refers to a
non-existent file; update the hook entry (the "command" field in
hooks-cursor.json) to point to the actual executable "hooks/session-start"
(remove the .sh extension) so the session-start hook will run correctly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 021c0894-252b-488f-a143-19ff81024d1d

📥 Commits

Reviewing files that changed from the base of the PR and between 363923f and d6b9d8e.

📒 Files selected for processing (2)
  • .cursor-plugin/plugin.json
  • hooks/hooks-cursor.json

@obra
Copy link
Owner

obra commented Mar 15, 2026

Thanks for identifying this! The core idea is right — Cursor needs its own hooks file with camelCase event names (sessionStart vs Claude Code's SessionStart).

We've merged an improved version to dev that addresses several issues in this PR:

Bugs fixed:

  1. Wrong filename: ./hooks/session-start.sh doesn't exist — the file is hooks/session-start (no .sh extension)
  2. No Windows support: Cursor uses PowerShell to execute hooks on Windows, which can't run .sh files. Our version uses the existing run-hook.cmd polyglot wrapper that works on both PowerShell/CMD and bash.
  3. Fragile relative paths: ./hooks/session-start.sh resolves relative to the project root (Cursor's cwd for plugin hooks), not the plugin directory. Our version uses ${CURSOR_PLUGIN_ROOT} for reliable path resolution.
  4. Platform detection: If Cursor sets both CURSOR_PLUGIN_ROOT and CLAUDE_PLUGIN_ROOT, the session-start script would incorrectly output Claude Code format. Fixed by checking CURSOR_PLUGIN_ROOT first.

What we merged:

  • hooks/hooks-cursor.json — Cursor-format hooks (version: 1, camelCase events, ${CURSOR_PLUGIN_ROOT}, run-hook.cmd)
  • Updated .cursor-plugin/plugin.json to reference hooks-cursor.json
  • Fixed platform detection in hooks/session-start

Closing in favor of our dev implementation. Thank you for the contribution!

@obra obra closed this Mar 15, 2026
@kevinzwang kevinzwang deleted the kev/cursor-hooks-support branch March 15, 2026 20:15
obra pushed a commit that referenced this pull request Mar 16, 2026
Add hooks/hooks-cursor.json with Cursor's camelCase format (sessionStart,
version: 1) and update .cursor-plugin/plugin.json to reference it. Uses
${CURSOR_PLUGIN_ROOT} and run-hook.cmd for cross-platform support.

Fix session-start platform detection: check CURSOR_PLUGIN_ROOT first
(Cursor may also set CLAUDE_PLUGIN_ROOT), ensuring correct output format
for each platform.

Based on PR #709 with fixes for: wrong filename (.sh extension), missing
Windows support, fragile relative paths, and incorrect platform detection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
obra pushed a commit that referenced this pull request Mar 16, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
vladivis pushed a commit to vladivis/superpowers that referenced this pull request Mar 18, 2026
Add hooks/hooks-cursor.json with Cursor's camelCase format (sessionStart,
version: 1) and update .cursor-plugin/plugin.json to reference it. Uses
${CURSOR_PLUGIN_ROOT} and run-hook.cmd for cross-platform support.

Fix session-start platform detection: check CURSOR_PLUGIN_ROOT first
(Cursor may also set CLAUDE_PLUGIN_ROOT), ensuring correct output format
for each platform.

Based on PR obra#709 with fixes for: wrong filename (.sh extension), missing
Windows support, fragile relative paths, and incorrect platform detection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
vladivis pushed a commit to vladivis/superpowers that referenced this pull request Mar 18, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants