Blog · Comparison · 16 November 2026

Git Worktrees vs File Leases for Parallel Agents

Git worktrees vs file leases is the main design choice when several agents edit one repository. A worktree gives each agent its own copy of the files, so nothing collides until merge. A file lease lets agents share a copy, or a codebase, while each one claims the paths it is working on for a limited time. They are not rivals. They fail in different places, and the larger the group of parallel agents, the more likely you need both. This article compares them using what Anthropic, Conductor and Cursor have published, and Forkit's own documentation for leases.

How git worktrees isolate agents

A git worktree is a separate working directory with its own files and branch that shares the repository's history. Anthropic's Claude Code docs describe the use directly: run each session in its own worktree so one session can build a feature while another fixes a bug.

Claude Code supports this natively. claude --worktree feature-auth creates a worktree under .claude/worktrees/feature-auth/ on a new branch and starts the session there. Subagents can be given isolation: worktree, and a worktree with no changes is removed automatically.

Other tools build on the same idea. Conductor's docs describe isolated workspaces: a separate, git-backed copy of a project for one stream of work, one branch per workspace. Vibe Kanban's site says it automates creating git worktrees and running setup scripts; the same site now carries a notice that Vibe Kanban is sunsetting and will continue as a community-maintained open-source project. Claude Squad's README says each task gets its own isolated git workspace, built on git worktrees.

What worktrees guarantee: two agents can never overwrite each other's files on disk.

What they do not guarantee: that the two branches will merge. If both agents rewrote the same function, you find out at merge time, after both have spent their tokens. Worktrees remove edit conflicts by turning them into merge conflicts.

How file locking and leases work

File locking is the older idea: before editing, take a lock; others wait. Cursor's research on long-running agents tried a lock of this kind, on a shared file its agents used to claim tasks, and reported that it failed. Agents held locks too long or forgot to release them, some failed while holding locks, and twenty agents slowed to the throughput of two or three.

A lease fixes the worst of that by expiring. Forkit's file leases, as documented, work like this:

  • An agent claims repo-relative paths or globs with a time limit: 30 minutes by default, 4 hours at most.
  • Activity on the agent's thread renews the lease, and the end of its session releases it. A crashed agent's claim simply runs out.
  • A claim that overlaps another agent's is still granted. Both agents get one conflict notice per pair every ten minutes, naming only the overlapping patterns.
  • The edit is what gets refused. Before an edit, the Claude Code hook checks the paths, and an edit under another agent's exclusive lease is denied with the holder's name.
  • Leases are exclusive or shared, and they are per repository.

So nobody waits in a queue. An agent learns early that someone else is in those files, and either works elsewhere or messages the holder.

Git worktrees vs file leases compared

Git worktrees File leases
What is isolated The whole working directory Named paths, by agreement that the server checks
When a conflict shows up At merge Before the edit
Cost of a conflict Work already done on both sides A refused edit and a notice
Needs a server No Yes
Works across machines Each machine has its own worktrees; nothing is shared Yes; claims are per repository, wherever agents run
Crashed agent Leaves a directory to clean up The lease expires
Separate build and test state Yes, each worktree has its own No, if agents share a directory
Supported out of the box Git, Claude Code, several desktop tools Forkit; Claude Code agent teams use guidance instead

When git worktrees are the better choice

  • Tasks are independent and should ship separately. One branch and one pull request per task is exactly what a worktree gives you.
  • Agents run builds and tests. Two agents sharing one directory will fight over build output, ports and lockfiles. Separate directories end that.
  • You work alone on one machine. There is nothing to install beyond git.
  • You want to throw experiments away. Delete the worktree and the branch.

For most people running three or four agents on unrelated tasks, worktrees alone are enough, and adding a lease server would be overhead.

When file leases are the better fit

  • The work is one change spread over many agents. A migration where each worker takes one package. Workers are in separate sandboxes, so they already have separate directories, but nothing tells them that two of them picked overlapping files. A claim does.
  • Agents are on different machines. Your worktrees and your colleague's are invisible to each other until both push.
  • Merge conflicts are expensive. With fifty branches, late conflicts mean rework at the worst moment.
  • You want a record of who is working where. Live claims double as a map of activity.

Why not plain locks

It is tempting to ask for a hard lock: nobody else may touch src/billing/ until I am done. Cursor's experience with locks on its coordination file shows the cost. A lock held by a stalled agent stops everyone, and Cursor reported agents that forgot to release theirs.

Expiry and "grant, then notify" are the two changes that make leases workable. The claim never blocks another claim; only the edit is refused, at the last moment, with a reason the agent can act on. A pattern in Forkit must be a path or glob without spaces or quotes, so a claim cannot carry instructions to other agents either.

Using both together

The strongest setup uses each for what it is good at:

  1. Give every agent its own worktree or sandbox, so builds, tests and half-finished edits never interfere.
  2. Have each agent claim the paths of its task before it starts editing.
  3. Let the planner split work so claims rarely overlap, and treat a conflict notice as a planning bug to fix.
  4. Merge often, so branches do not drift far apart.

Worktrees handle the disk. Leases handle the plan. How to run 50 coding agents without merge conflicts walks through this as a procedure, and file locking for AI agents goes deeper on lease design. For the Claude Code side, see how to run Claude Code in parallel.

Where Forkit fits

Forkit does not create worktrees. It provides the lease half: claim_paths, check_path, release_paths and list_leases through its MCP endpoint, an HTTP API for the same, and a hook that checks claims before an edit. Use your preferred tool for isolated workspaces and Forkit for claims between agents. It is free to try. More at forkit-mcp.com.

Sources

Read on 16 Nov 2026: