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

| Step | What happens |
|---|---|
| 1. Spawn | a worktree and a branch are created from main |
| 2. Work | each meaningful unit is committed; the branch is pushed right after the first commit |
| 3. Report | the agent reports the worktree path, the branch, the commit and the number of files changed |
| 4. Approve | merge, push main, remove the worktree, delete the branch |
| 5. Reject | the 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
| Mechanism | When it is used | Why |
|---|---|---|
| The agent tool’s built-in isolation | several workers at once, each on different files | the tool creates and cleans up the worktrees and only the results come back |
| A worktree created by hand or by script | one cycle where a server must stay up for me to check | built-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.
- It is in the first commit and that commit is pushed. The script’s first commit contains only this document.
- 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.
- “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 wrong | What the flow does about it |
|---|---|
| Another session checks out a branch in the shared directory | each task has its own directory, so nothing is overwritten |
| The agent’s context is lost mid-task | the next agent reads RESUME from the branch |
| The machine is unavailable | the branch was pushed after the first commit; any machine can continue |
| A worktree is removed with unpushed work | removal is refused while commits are unpushed |
| A commit is lost anyway | the recovery procedure finds it as a dangling commit and pins a branch to it |
| A worktree triggers the dev server’s reload | worktrees live outside the repository folder |
| The agent stages symlinked folders | blocked 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.
