Skip to content

Fix SessionStart hook variable expansion on Linux#584

Closed
04cb wants to merge 1 commit into
obra:mainfrom
04cb:fix/sessionstart-hook-variable-expansion
Closed

Fix SessionStart hook variable expansion on Linux#584
04cb wants to merge 1 commit into
obra:mainfrom
04cb:fix/sessionstart-hook-variable-expansion

Conversation

@04cb
Copy link
Copy Markdown

@04cb 04cb commented Mar 1, 2026

Fixes issue #577. The hook command used single quotes around CLAUDE_PLUGIN_ROOT which prevented shell variable expansion on Linux. This caused the hook to fail with No such file or directory error.

Changed from single quotes to no quotes since the JSON string already provides proper quoting. The shell will now correctly expand the CLAUDE_PLUGIN_ROOT environment variable.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 1, 2026

📝 Walkthrough

Walkthrough

The change modifies the hooks.json configuration file by removing outer single quotes from a command string and restructuring argument placement. The SessionStart hook command is updated to pass the session-start argument as part of the same string rather than as a separate quoted element.

Changes

Cohort / File(s) Summary
Configuration Update
hooks/hooks.json
Modified SessionStart hook command: removed outer single quotes and reorganized argument positioning for run-hook.cmd session-start invocation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 Quotes around paths causing quite the fuss,
A rabbit removes them without making a fuss,
Now the argument flows in one gleaming stream,
Session-start runs smoother than ever—a dream! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main change: fixing variable expansion for the SessionStart hook on Linux systems.
Description check ✅ Passed The description is directly related to the changeset, explaining the issue being fixed, the root cause, and the solution applied.
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

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.

Copy link
Copy Markdown

@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.json`:
- Line 9: The command value in hooks.json currently interpolates
${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd without quotes, which breaks on Windows
paths with spaces; update the "command" entry so the executable path portion is
wrapped in double quotes while leaving the session-start argument unquoted
(i.e., quote ${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd but keep session-start as
a separate argument) so the "command" key correctly handles paths with spaces.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4a2375 and 5dcb888.

📒 Files selected for processing (1)
  • hooks/hooks.json

Comment thread hooks/hooks.json
{
"type": "command",
"command": "'${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd' session-start",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd session-start",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

fd hooks.json -x cat -n {}

Repository: obra/superpowers

Length of output: 479


🏁 Script executed:

# Look for other hook commands to see if there's a consistent pattern
rg "command.*CLAUDE_PLUGIN_ROOT" -A 2 -B 2

Repository: obra/superpowers

Length of output: 1225


🏁 Script executed:

# Search for any documentation or comments about variable expansion in hooks
rg -i "variable.*expansion|quote|CLAUDE_PLUGIN_ROOT" --type json --type md --type txt

Repository: obra/superpowers

Length of output: 1318


🏁 Script executed:

# Check if there are any other similar configuration patterns in the repo
fd -e json -x grep -l "CLAUDE_PLUGIN_ROOT" {}

Repository: obra/superpowers

Length of output: 78


Missing quotes around path variable will break Windows installations with spaces in the plugin directory.

The documentation in docs/windows/polyglot-hooks.md explicitly requires quoting: "The path must be quoted because ${CLAUDE_PLUGIN_ROOT} may contain spaces on Windows (e.g., C:\Program Files\...)." All examples in that file use double quotes around the variable expansion.

Change to:

Diff
-            "command": "${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd session-start",
+            "command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd session-start",
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hooks/hooks.json` at line 9, The command value in hooks.json currently
interpolates ${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd without quotes, which
breaks on Windows paths with spaces; update the "command" entry so the
executable path portion is wrapped in double quotes while leaving the
session-start argument unquoted (i.e., quote
${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd but keep session-start as a separate
argument) so the "command" key correctly handles paths with spaces.

@Jamie-Clayton
Copy link
Copy Markdown

I've been having similar issues loading superpowers as @04cb . I've tried both the fix submitted and the CodeRabbit.

Test environment

  • Claude Code v2.1.50
  • SuperPowers v4.3.1 (installed from claude /plugin)

I've also tried to get Claude to interactively try and resolve the issue with no luck. The issue seems to be triggered by running multiple Claude Code sessions in different terminal windows, in my situation.

Claude Code change log suggests there is some bug fixes in a newer version.

v2.1.61 — Fixed concurrent writes corrupting config on Windows. This is almost certainly contributing to your inconsistent plugin loading, since plugin state is tracked in config files that can corrupt under concurrent access.

Initial testing with Claude Code v2.1.61 looks promising.

Root cause summary for the PR comment: the fix that actually worked on Windows with v2.1.63 was:

  1. Remove single-quotes from the command (fix variable expansion — the Linux bug in SessionStart hook fails on Linux: CLAUDE_PLUGIN_ROOT not expanding #577)
  2. Use .sh extension so Claude Code's auto-detection invokes bash correctly
  3. Remove the additional_context top-level field from the JSON output

rahulsc added a commit to rahulsc/superpowers that referenced this pull request Mar 2, 2026
rahulsc added a commit to rahulsc/superpowers that referenced this pull request Mar 2, 2026
@04cb 04cb closed this by deleting the head repository Mar 2, 2026
rahulsc added a commit to rahulsc/superpowers that referenced this pull request Mar 10, 2026
rahulsc added a commit to rahulsc/superpowers that referenced this pull request Mar 11, 2026
…e management

Comprehensive audit of all 16 skills with fixes and enhancements:

Skills improvements:
- verification-before-completion: canonical evidence format (command/citation/diff)
- using-git-worktrees: rework to layer on native EnterWorktree
- test-driven-development: add pipelined TDD mode and evidence gates
- agent-team-driven-development: add pipelined TDD and evidence gates
- dispatching-parallel-agents: add worktree isolation and autonomy
- composing-teams: add agent hierarchy and test-writer role
- receiving-code-review: add evidence demand and pedantry filter
- systematic-debugging: improve CSO, add fork and worktree support
- writing-skills: align with Anthropic guide, add versioning
- finishing-a-development-branch: fix worktree CWD and add state.yml
- requesting-code-review: require citation evidence from reviewers
- writing-plans: add directory-based plans and test expectations
- brainstorming: add verification gates, research step, assumption challenging
- executing-plans: add evidence gates and cold session resume
- subagent-driven-development: add evidence gates and progress persistence
- using-superpowers: trim red flags, fix subagent context gap

Cross-cutting fixes:
- Generalize "your human partner" to "the user" across all skills
- Restore Cursor/Codex/multi-platform support across skills
- Correct spec-reviewer agent type and remove bias language (CX-4, CX-18, CX-19)
- Align code-reviewer placeholder to {PLAN_OR_REQUIREMENTS} (CX-7)
- Add worktree env file guidance and fix hook bash compatibility (obra superpowers obraGH-521, obraGH-572, obraGH-584)
- Add integration section and sequential fallback to dispatching (CX-17, markelz0r)
- Add announce and cross-task dependency check to agent-team (CX-15, obra superpowers obraGH-578)
- Update stale skill references and verification links (CX-9)
- Address CodeRabbit review findings

Documentation:
- Skills audit brainstorm, design document, and implementation plan
- Skills audit v2 design, research, and implementation plan
- Upstream research: open issues/PRs, closed issues, forks survey, unmerged PRs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
rahulsc added a commit to rahulsc/superpowers that referenced this pull request Mar 12, 2026
…e management

Comprehensive audit of all 16 skills with fixes and enhancements:

Skills improvements:
- verification-before-completion: canonical evidence format (command/citation/diff)
- using-git-worktrees: rework to layer on native EnterWorktree
- test-driven-development: add pipelined TDD mode and evidence gates
- agent-team-driven-development: add pipelined TDD and evidence gates
- dispatching-parallel-agents: add worktree isolation and autonomy
- composing-teams: add agent hierarchy and test-writer role
- receiving-code-review: add evidence demand and pedantry filter
- systematic-debugging: improve CSO, add fork and worktree support
- writing-skills: align with Anthropic guide, add versioning
- finishing-a-development-branch: fix worktree CWD and add state.yml
- requesting-code-review: require citation evidence from reviewers
- writing-plans: add directory-based plans and test expectations
- brainstorming: add verification gates, research step, assumption challenging
- executing-plans: add evidence gates and cold session resume
- subagent-driven-development: add evidence gates and progress persistence
- using-superpowers: trim red flags, fix subagent context gap

Cross-cutting fixes:
- Generalize "your human partner" to "the user" across all skills
- Restore Cursor/Codex/multi-platform support across skills
- Correct spec-reviewer agent type and remove bias language (CX-4, CX-18, CX-19)
- Align code-reviewer placeholder to {PLAN_OR_REQUIREMENTS} (CX-7)
- Add worktree env file guidance and fix hook bash compatibility (obra superpowers obraGH-521, obraGH-572, obraGH-584)
- Add integration section and sequential fallback to dispatching (CX-17, markelz0r)
- Add announce and cross-task dependency check to agent-team (CX-15, obra superpowers obraGH-578)
- Update stale skill references and verification links (CX-9)
- Address CodeRabbit review findings

Documentation:
- Skills audit brainstorm, design document, and implementation plan
- Skills audit v2 design, research, and implementation plan
- Upstream research: open issues/PRs, closed issues, forks survey, unmerged PRs

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