Several agents work on one repository at the same time, and I am often working in it too. A git worktree gives each task its own directory and branch on the same repository. That solves the collisions. It took three incidents to learn where the worktree should live, what must never be staged inside it, and where the task's plan has to be kept.

The problem

With everyone in one working directory, three things happen.

  • One session checks out a branch and another session’s uncommitted files are gone. This happened twice to a set of diagram documents.
  • Two agents edit the same file for different tasks, and neither diff makes sense alone.
  • A half-finished change sits in the directory that the development server is serving, so what I am looking at in the browser is not any committed state.

Isolation fixes these. The remaining question is what happens to the task’s own state: what was planned, what is done, what was found along the way. An agent that starts tomorrow has none of that unless it is written down somewhere the next agent will look.

Five steps

Diagram in two bands. One task, five steps: 1 spawn a worktree and a branch off main; 2 work, committing each unit and pushing after the first; 3 report the path, branch, SHA and files changed; 4 approve, which merges, pushes main and removes the worktree; or 5 reject, which keeps the worktree with no hard reset. The progress document rides along: a progress document with a RESUME block and a checklist goes into the first commit; after every item the box is ticked, RESUME is rewritten and the branch is pushed again; before saying done there must be zero unchecked items; after a git push, another machine can fetch, check out the branch, read RESUME and continue. A note explains why it is committed: the first version was an untracked scratch file inside the worktree, it vanished when the worktree was cleaned up, and the task could not be resumed anywhere else.
Figure 1. One task. The work moves through five steps in its own worktree, and a progress document is committed with it from the first commit so the task can be resumed elsewhere.
StepWhat happens
1. Spawna worktree and a branch are created from main
2. Workeach meaningful unit is committed; the branch is pushed right after the first commit
3. Reportthe agent reports the worktree path, the branch, the commit and the number of files changed
4. Approvemerge, push main, remove the worktree, delete the branch
5. Rejectthe worktree is kept as it is; no hard reset

Approval is mine. Before it, nothing reaches the main branch. For a change with a user interface, the report comes with a development server left running on a free port, so I can click through the real thing before I say yes.

A few guards are part of the protocol. An agent asks before stashing. It does not resolve merge conflicts automatically. It will not remove a worktree that has unpushed commits. There is also a written recovery procedure for lost commits, using the reflog and dangling-commit search, which was used to get the diagram documents back.

Two ways to isolate

MechanismWhen it is usedWhy
The agent tool’s built-in isolationseveral workers at once, each on different filesthe tool creates and cleans up the worktrees and only the results come back
A worktree created by hand or by scriptone cycle where a server must stay up for me to checkbuilt-in isolation removes the directory when the worker ends, and the server would lose its files

The second row was learned by trying the first one for a review cycle and watching the directory disappear under a running server.

Where the worktree lives

The protocol first put worktrees inside the repository, in a hidden folder. In July 2026 a worktree created there triggered the API server’s file watcher. The server reloaded, and the content pipelines that were running in it died mid-job. Since then, worktrees for the product repositories are created in a sibling folder next to the repository, outside anything a file watcher sees.

A script does this so that nobody has to remember it. Its header lists what it automates. Comments are translated.

# What it does:
#   1. create a worktree and a branch outside the repository  (safe for the dev server)
#   2. symlink the environment file, if there is one
#   3. scaffold docs/plans/<date>-<slug>-plan.md from a template
#   4. first commit, then git push -u
#   5. if the GitHub CLI is installed, open a draft pull request,
#      write its URL back into the progress document, and push again
#   6. print the worktree path and how to resume

The progress document

The plan for a task is a Markdown file in the branch. It starts with a block that an agent reads first.

## RESUME
- So far: what is finished, with commit ids
- Next: the one thing to do next
- Verify: the command that proves the current state
- Caution: what must not be touched, and why

## Phase checklist
- [x] step that is done
- [ ] step that is not

Three rules make it work.

  1. It is in the first commit and that commit is pushed. The script’s first commit contains only this document.
  2. It is updated after every item. Tick the box, rewrite the RESUME block, push again. New work discovered along the way, anything deferred and anything handed to a later cycle are added as items.
  3. “Done” means zero unchecked boxes. An agent that says it is finished is asked to show the unchecked count.

The first version of this was a scratch file in the worktree that was not tracked by git. When a worktree was cleaned up, the plan went with it, and a task could not be picked up on another machine at all. Committing the document turned it from a note into the task’s record. A second script lists every branch that has a progress document with a RESUME block, prints the blocks, and attaches a chosen branch as a worktree on whatever machine it is run from.

The portfolio you are reading was built this way. Its progress document lives in the branch, and its RESUME block was rewritten after each project was finished.

Failure modes

What goes wrongWhat the flow does about it
Another session checks out a branch in the shared directoryeach task has its own directory, so nothing is overwritten
The agent’s context is lost mid-taskthe next agent reads RESUME from the branch
The machine is unavailablethe branch was pushed after the first commit; any machine can continue
A worktree is removed with unpushed workremoval is refused while commits are unpushed
A commit is lost anywaythe recovery procedure finds it as a dangling commit and pins a branch to it
A worktree triggers the dev server’s reloadworktrees live outside the repository folder
The agent stages symlinked foldersblocked by a hook

Limits I know about

The documents disagree about one thing. The protocol still describes worktrees inside the repository, and the scripts create them beside it. The scripts are right, and the protocol text has not caught up.

The flow assumes a remote to push to. For a repository with no usable remote, the progress document is committed and stays on one machine, which removes the main benefit. That is the case for the repository behind this site at the time of writing.