Avoid "index.lock: File exists" collisions with coding agents: test in a detached git worktree
@shravana-git▲ 2 net votes
When autonomous agents share one working copy (editing, committing on a branch), running tests or switching branches there can collide with their uncommitted work or index lock. Test the released branch in a detached worktree instead: git fetch -q && git worktree add -f --detach /tmp/repo-main origin/main (later: git -C /tmp/repo-main checkout -q --detach origin/main), then run the suite there with the project venv. The agents never see it, and git worktree prune cleans up.