Skip to content

Refactor setup-process: canonical setup-worktree.sh + thin delegators#3

Open
robinebers wants to merge 1 commit into
mainfrom
setup-process/dry-canonical-sh
Open

Refactor setup-process: canonical setup-worktree.sh + thin delegators#3
robinebers wants to merge 1 commit into
mainfrom
setup-process/dry-canonical-sh

Conversation

@robinebers
Copy link
Copy Markdown
Owner

@robinebers robinebers commented May 15, 2026

Summary

  • Replaces per-agent inline install/copy logic in the setup-process skill with a single canonical scripts/setup-worktree.sh.
  • Each agent config (Cursor, Codex, Conductor, Grok) now invokes that sh via a SOURCE_ROOT / WORKTREE_ROOT env-var contract.
  • Adds a full template for the canonical script (3 steps: install, copy AI-tool config dirs incl. .grok, copy env files) and documents the contract explicitly so a delegator that forgets to set the vars fails loudly.
  • Restores Codex template detail that was previously trimmed (full TOML with version, name, both Dev Server and Build [[actions]] blocks, common icons list).

Caveats / things to verify before relying on this

  • Cursor string-filepath form: the doc claims .cursor/worktrees.json accepts a string path for setup-worktree-unix. Not verified against official Cursor docs in this PR — confirm before using.
  • Grok worktree integration: the doc references ~/.grok/worktrees.db + GROK_WORKSPACE_ROOT auto-detection. Not verified in this PR.

Test plan

  • Verify Cursor accepts the string-filepath form for setup-worktree-unix against current Cursor docs
  • Verify the Grok worktree DB + env-var claim (or pull the Grok section if it's not real)
  • Generate scripts/setup-worktree.sh in a real project and confirm Codex + Conductor delegators run it end-to-end

🤖 Generated with Claude Code


Note

Low Risk
Documentation-only refactor that changes recommended setup patterns but no runtime code in this repo. Risk is mainly that the Cursor/Grok delegation details may be incorrect and could mislead users when configuring worktrees.

Overview
Refactors the setup-process skill docs to standardize all agent worktree setup on a single canonical scripts/setup-worktree.sh, with Cursor/Codex/Conductor (and Grok) reduced to thin delegators that pass SOURCE_ROOT/WORKTREE_ROOT.

Updates templates to remove per-agent inline copy/install snippets, adds the canonical bash script template (including .grok config dir + multiple env files), and expands the Codex TOML example to include full metadata and action shortcuts.

Reviewed by Cursor Bugbot for commit b173bf9. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Replaced per-agent setup logic with a single canonical scripts/setup-worktree.sh and thin delegators so Cursor, Codex, Conductor, and Grok share identical worktree setup. Adds an explicit SOURCE_ROOT/WORKTREE_ROOT contract and DRY examples; restores full Codex template details.

  • Refactors

    • Adds canonical scripts/setup-worktree.sh (install deps, copy .agents/.claude/.codex/.cursor/.grok, copy env files) with fail-fast SOURCE_ROOT/WORKTREE_ROOT.
    • Updates delegator patterns for Cursor (string filepath), Codex ([setup].script), and Conductor (scripts.setup) to invoke the script; notes Grok auto-detection.
    • Restores full Codex TOML (includes version, name, both Dev Server and Build [[actions]], common icons).
  • Migration

    • Add and customize scripts/setup-worktree.sh (set {INSTALL_CMD} and env-file list), then chmod +x.
    • Point .cursor/worktrees.json, .codex/environments/environment.toml, and conductor.json to the script using SOURCE_ROOT/WORKTREE_ROOT (see examples in the docs).
    • Commit and run a new worktree to verify all agents use the same setup.

Written for commit b173bf9. Summary will update on new commits.

… + thin delegators

Each agent config (Cursor, Codex, Conductor, Grok) now invokes the same
scripts/setup-worktree.sh via a SOURCE_ROOT / WORKTREE_ROOT contract,
replacing the per-agent inline copy/install logic.

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

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b173bf9. Configure here.

"for d in .agents .claude .codex .cursor; do [ -d \"$ROOT_WORKTREE_PATH/$d\" ] && mkdir -p \"$d\" && rsync -a \"$ROOT_WORKTREE_PATH/$d/.\" \"$d/\"; done",
"[ -f \"$ROOT_WORKTREE_PATH/{ENV_FILE}\" ] && cp \"$ROOT_WORKTREE_PATH/{ENV_FILE}\" \"{ENV_FILE}\" || true"
]
"setup-worktree-unix": "../scripts/setup-worktree.sh"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor delegator never sets required env vars

High Severity

The Cursor delegator uses the string-filepath form ("../scripts/setup-worktree.sh") which provides no mechanism to set SOURCE_ROOT and WORKTREE_ROOT. The canonical script enforces these via ${SOURCE_ROOT:?...} and ${WORKTREE_ROOT:?...}, so it will immediately abort when invoked by Cursor. Cursor only exposes $ROOT_WORKTREE_PATH and cwd — neither of which is mapped to the required contract vars. The Codex and Conductor delegators correctly perform this mapping inline, but the Cursor delegator does not and cannot in the string-filepath form.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b173bf9. Configure here.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="skills/setup-process/SKILL.md">

<violation number="1" location="skills/setup-process/SKILL.md:21">
P2: The PR description states Grok worktree integration is "not verified in this PR," but the doc presents Grok-specific paths (`~/.grok/worktrees.db`, `GROK_WORKSPACE_ROOT`) and auto-detection behavior as established fact. This can mislead users into expecting a working Grok integration that may not exist in the claimed form. Either mark as unverified or remove until confirmed.</violation>

<violation number="2" location="skills/setup-process/SKILL.md:84">
P1: The Cursor delegator uses the string-filepath form which cannot set `SOURCE_ROOT` and `WORKTREE_ROOT` before invoking the script. The canonical `setup-worktree.sh` enforces these via `${SOURCE_ROOT:?...}` / `${WORKTREE_ROOT:?...}` and will immediately abort.

Cursor provides `$ROOT_WORKTREE_PATH` (source) and sets cwd to the new worktree, but the string-filepath form just executes the script directly — there's no way to map those into the contract vars inline.

Either switch to the array form with an inline wrapper (e.g., `["SOURCE_ROOT=$ROOT_WORKTREE_PATH WORKTREE_ROOT=$(pwd) ../scripts/setup-worktree.sh"]`) or have the script detect the Cursor environment and fall back to `ROOT_WORKTREE_PATH`/cwd when `SOURCE_ROOT`/`WORKTREE_ROOT` are unset.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

"for d in .agents .claude .codex .cursor; do [ -d \"$ROOT_WORKTREE_PATH/$d\" ] && mkdir -p \"$d\" && rsync -a \"$ROOT_WORKTREE_PATH/$d/.\" \"$d/\"; done",
"[ -f \"$ROOT_WORKTREE_PATH/{ENV_FILE}\" ] && cp \"$ROOT_WORKTREE_PATH/{ENV_FILE}\" \"{ENV_FILE}\" || true"
]
"setup-worktree-unix": "../scripts/setup-worktree.sh"
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 15, 2026

Choose a reason for hiding this comment

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

P1: The Cursor delegator uses the string-filepath form which cannot set SOURCE_ROOT and WORKTREE_ROOT before invoking the script. The canonical setup-worktree.sh enforces these via ${SOURCE_ROOT:?...} / ${WORKTREE_ROOT:?...} and will immediately abort.

Cursor provides $ROOT_WORKTREE_PATH (source) and sets cwd to the new worktree, but the string-filepath form just executes the script directly — there's no way to map those into the contract vars inline.

Either switch to the array form with an inline wrapper (e.g., ["SOURCE_ROOT=$ROOT_WORKTREE_PATH WORKTREE_ROOT=$(pwd) ../scripts/setup-worktree.sh"]) or have the script detect the Cursor environment and fall back to ROOT_WORKTREE_PATH/cwd when SOURCE_ROOT/WORKTREE_ROOT are unset.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At skills/setup-process/SKILL.md, line 84:

<comment>The Cursor delegator uses the string-filepath form which cannot set `SOURCE_ROOT` and `WORKTREE_ROOT` before invoking the script. The canonical `setup-worktree.sh` enforces these via `${SOURCE_ROOT:?...}` / `${WORKTREE_ROOT:?...}` and will immediately abort.

Cursor provides `$ROOT_WORKTREE_PATH` (source) and sets cwd to the new worktree, but the string-filepath form just executes the script directly — there's no way to map those into the contract vars inline.

Either switch to the array form with an inline wrapper (e.g., `["SOURCE_ROOT=$ROOT_WORKTREE_PATH WORKTREE_ROOT=$(pwd) ../scripts/setup-worktree.sh"]`) or have the script detect the Cursor environment and fall back to `ROOT_WORKTREE_PATH`/cwd when `SOURCE_ROOT`/`WORKTREE_ROOT` are unset.</comment>

<file context>
@@ -15,54 +15,81 @@ Generate the right config so AI agents start in their isolated worktrees / envir
-        "for d in .agents .claude .codex .cursor; do [ -d \"$ROOT_WORKTREE_PATH/$d\" ] && mkdir -p \"$d\" && rsync -a \"$ROOT_WORKTREE_PATH/$d/.\" \"$d/\"; done",
-        "[ -f \"$ROOT_WORKTREE_PATH/{ENV_FILE}\" ] && cp \"$ROOT_WORKTREE_PATH/{ENV_FILE}\" \"{ENV_FILE}\" || true"
-    ]
+    "setup-worktree-unix": "../scripts/setup-worktree.sh"
 }

</file context>


</details>

<a href="https://www.cubic.dev/action/fix/violation/7c0d464f-6dd4-49d9-82f9-8e40cee00c18" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://cubic.dev/buttons/fix-with-cubic-dark.svg">
    <source media="(prefers-color-scheme: light)" srcset="https://cubic.dev/buttons/fix-with-cubic-light.svg">
    <img alt="Fix with Cubic" src="https://cubic.dev/buttons/fix-with-cubic-dark.svg">
  </picture>
</a>

- **Cursor:** `.cursor/worktrees.json` (string path to `scripts/setup-worktree.sh`).
- **Codex:** `.codex/environments/environment.toml` ([setup].script delegates to the sh).
- **Conductor:** `conductor.json` at root (setup script invokes the sh).
- **Grok:** `~/.grok/worktrees.db` + auto-detection of the same sh.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 15, 2026

Choose a reason for hiding this comment

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

P2: The PR description states Grok worktree integration is "not verified in this PR," but the doc presents Grok-specific paths (~/.grok/worktrees.db, GROK_WORKSPACE_ROOT) and auto-detection behavior as established fact. This can mislead users into expecting a working Grok integration that may not exist in the claimed form. Either mark as unverified or remove until confirmed.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At skills/setup-process/SKILL.md, line 21:

<comment>The PR description states Grok worktree integration is "not verified in this PR," but the doc presents Grok-specific paths (`~/.grok/worktrees.db`, `GROK_WORKSPACE_ROOT`) and auto-detection behavior as established fact. This can mislead users into expecting a working Grok integration that may not exist in the claimed form. Either mark as unverified or remove until confirmed.</comment>

<file context>
@@ -15,54 +15,81 @@ Generate the right config so AI agents start in their isolated worktrees / envir
+- **Cursor:** `.cursor/worktrees.json` (string path to `scripts/setup-worktree.sh`).
+- **Codex:** `.codex/environments/environment.toml` ([setup].script delegates to the sh).
+- **Conductor:** `conductor.json` at root (setup script invokes the sh).
+- **Grok:** `~/.grok/worktrees.db` + auto-detection of the same sh.
 
 ## The shared pattern
</file context>
Suggested change
- **Grok:** `~/.grok/worktrees.db` + auto-detection of the same sh.
- **Grok:** `~/.grok/worktrees.db` + auto-detection of the same sh (unverified — confirm before using).
Fix with Cubic

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.

1 participant