Skip to content

fix(ce-worktree): resolve script path against skill dir, not user CWD#772

Merged
tmchow merged 2 commits intomainfrom
tmchow/worktree-script-path
May 4, 2026
Merged

fix(ce-worktree): resolve script path against skill dir, not user CWD#772
tmchow merged 2 commits intomainfrom
tmchow/worktree-script-path

Conversation

@tmchow
Copy link
Copy Markdown
Collaborator

@tmchow tmchow commented May 4, 2026

Summary

  • /ce-worktree invoked bash scripts/worktree-manager.sh, a relative path the runtime Bash tool resolves against the user's project CWD (not the skill directory). The bundled script lives under <plugin-cache>/skills/ce-worktree/scripts/, so every invocation failed with "No such file or directory".
  • Switched the four invocation sites to bash "${CLAUDE_SKILL_DIR}/scripts/worktree-manager.sh" and added a narrow allowed-tools: Bash(bash *worktree-manager.sh) so users without bypassPermissions are not prompted every run. This mirrors the proven pattern already in ce-update.
  • Added tests/skills/ce-worktree.test.ts with three regression guards: forbid the bare relative-path antipattern, require the ${CLAUDE_SKILL_DIR}-prefixed form, and require the narrow allowed-tools entry. Mirrors tests/skills/ce-update.test.ts.

Note: the same bash scripts/<name>.sh antipattern exists in seven other skills (ce-optimize, ce-resolve-pr-feedback, ce-code-review, ce-session-inventory, ce-polish-beta, ce-setup, ce-clean-gone-branches). Out of scope here — issue #764 only covers ce-worktree — but worth a follow-up.

Fixes #764

Test plan

  • bun test tests/skills/ce-worktree.test.ts — 3 new regression tests pass
  • bun test — full suite (1336 tests) passes
  • bun run release:validate — clean
  • Manually verified the fixed path resolves and runs in the cached install layout: bash "${CLAUDE_SKILL_DIR}/scripts/worktree-manager.sh" finds and executes the script
  • Manually reproduced the original bug: bash scripts/worktree-manager.sh from the project root fails with "No such file or directory"

🤖 Generated with Claude Code

The skill instructed agents to run `bash scripts/worktree-manager.sh`,
which resolves against the user's project CWD at runtime — not the
skill directory — so the bundled script is never found and the skill
fails with "No such file or directory" on every invocation.

Switch to `bash "${CLAUDE_SKILL_DIR}/scripts/worktree-manager.sh"`
(the same pattern ce-update already uses) and add a narrow
`allowed-tools: Bash(bash *worktree-manager.sh)` pattern so users
without bypassPermissions don't get prompted on every run.

Adds regression guards mirroring ce-update.test.ts: forbid the bare
relative-path antipattern, require the CLAUDE_SKILL_DIR-prefixed
form, and require the narrow allowed-tools entry.

Fixes #764

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8c044878f5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/compound-engineering/skills/ce-worktree/SKILL.md Outdated
…gets

ce-worktree has no `ce_platforms` restriction, so filterSkillsByPlatform
exports it to Codex/Gemini/Pi/Kiro/Droid/Copilot/Opencode. None of
those converters substitute `${CLAUDE_SKILL_DIR}`, so the previous
unguarded form expanded to `/scripts/worktree-manager.sh` and failed.

Switch to `${CLAUDE_SKILL_DIR:-.}` so:
- Claude Code (var set) -> absolute path to bundled script (works)
- Non-Claude targets (var unset) -> `./scripts/worktree-manager.sh`,
  matching the prior bare-relative behavior on those harnesses.

Adds a regression guard requiring the `:-` fallback so this concern
cannot regress, and loosens the `${CLAUDE_SKILL_DIR}` guard's regex
to accept the fallback form.

Addresses PR #772 review feedback from chatgpt-codex-connector.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tmchow tmchow merged commit 4cc1ee6 into main May 4, 2026
2 checks passed
@github-actions github-actions Bot mentioned this pull request May 4, 2026
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.

ce-worktree: script path resolves against project root instead of plugin directory

1 participant