Skip to content

fix(worktree): link main checkout's .env into fresh worktrees on setup - #125

Merged
robercano-ghbot merged 1 commit into
mainfrom
fix/worktree-env-bootstrap
Jul 16, 2026
Merged

fix(worktree): link main checkout's .env into fresh worktrees on setup#125
robercano-ghbot merged 1 commit into
mainfrom
fix/worktree-env-bootstrap

Conversation

@robercano-ghbot

Copy link
Copy Markdown
Collaborator

Problem

Subagents working in isolated worktrees (implementers, reviewers, test-runners) can't run tasks that need credentials: .env is gitignored, so a fresh git worktree add checkout never contains it, and gates/scripts fail for lack of GH_BOT_TOKEN / RPC URLs rather than real defects.

Fix

worktree.sh setup now symlinks the main checkout's .env into the worktree — the same pattern prepare-pr.sh already uses for test-pr worktrees.

Tests

New worktree.test.sh (auto-discovered by checks.sh test): 11 checks — fresh-worktree link + content, local-.env precedence, main-checkout no-op, missing-.env no-op, teardown no-op, and check-ignore confirming the link stays gitignored.

Gates run locally: buildlinttest (all script smokes incl. new one) ✅ smoke-fanout

Supersedes #123 (same branch — recreated bot-authored so the owner can approve).

🤖 Generated with Claude Code

Isolated implementer/reviewer worktrees are fresh checkouts, and .env is
gitignored — so it never appears in them, and any gate or script that
needs its credentials (GH_BOT_TOKEN, RPC URLs, ...) fails for lack of
setup rather than a real defect.

worktree.sh setup now symlinks the main checkout's .env into the
worktree (same pattern prepare-pr.sh already uses for test-pr
worktrees): resolved from the caller's cwd so it works in both the
repo-tracked and plugin-cache layouts, best-effort, and skip-if-present
so a worktree-local .env always wins. Runs before the adapter checks so
unconfigured repos get it too.

Ships in the plugin's scripts/ — consumers pick it up on plugin update
with no adapter (gates.json) change needed.

Adds worktree.test.sh (auto-discovered by checks.sh test): 11 checks
covering fresh-worktree link, local-.env precedence, main-checkout
no-op, missing-.env no-op, teardown no-op, and gitignore coverage.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@robercano-ghbot
robercano-ghbot merged commit 614f703 into main Jul 16, 2026
18 checks passed
@robercano-ghbot
robercano-ghbot deleted the fix/worktree-env-bootstrap branch July 16, 2026 06:50
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