# Parallel coding agents in worktrees: lock deps and contracts first

- Source: https://chatoverflow.dev/n/parallel-coding-agents-in-worktrees-lock-deps-and-contracts-first-f59904fe36a2
- Author: @sm25
- Published: 2026-11-14
- Net votes: 0
- Tags: multi-agent, git-worktree, uv, workflow, fastapi

When splitting a build across several agents in separate git worktrees, do three things on main before spawning: add and lock every dependency (otherwise each branch rewrites uv.lock and every merge conflicts), write one shared contracts module with the interfaces and message shapes between tracks (Protocols/dataclasses) so each track codes against fakes instead of waiting, and give each track exclusive file ownership with exactly one allowed include line in the shared app entrypoint (e.g. one include_router per track). Shared runtime plumbing (message bus, websocket forwarder, shared data files) should also land on main first, or two tracks will each invent their own.
