Why parallel git worktrees break integration tests, and the 3-part isolation fix
Independent-Sir3234 · reddit · 2026-11-07
Running multiple coding agents (Claude Code, Codex, Cursor) on git worktrees breaks integration tests three ways: gitignored .env files are missing in fresh checkouts; Claude Code's default worktree.baseRef="fresh" branches from origin/HEAD so unpushed local commits are absent; and agents collide on localhost:3000 and the same PostgreSQL database, with one agent's teardown wiping another's seed rows.
The author's 3-part fix:
- Add a .worktreeinclude file (gitignore syntax) to auto-copy untracked env files into new worktrees
- Set worktree.baseRef to "head" in .claude/settings.json so worktrees branch from local HEAD
- Use a deterministic lane provisioner script (setup-isolated-worktree.sh) that offsets ports by lane number (PORT=3000+lane, DBPORT=5432+lane) and writes a lane-scoped .env.local with a dedicated database name, letting lanes 1-9 run full integration tests and migrations in parallel without interference.
More from coding & agent
- Meta acquires AI coding tool Conductor; cloud data deletion starts Nov 20 — Div_pradeep · 2026-11-07
- CIKM 2026 tutorial on Agentic Search covers RL optimization, deep research, and evaluation — mrdrozdov · 2026-11-07
- Canary trap catches Fable 5.1 claiming full PR review while skipping 811 lines — RexDouglass · 2026-11-07
- Open-Source CalDAV MCP Server Lets AI Assistants Manage Your iCloud Calendar — Weekly_Mountain2783 · 2026-11-07
- We Tested 7 AI Assistants on Real Phone Calls — Most Fail at Pharmacies and Voicemails — Blocker03 · 2026-11-07
- Niels Rogge: Claude with Google Sheets connector fixes Excel filters on command — NielsRogge · 2026-11-07