Skip to content
LoopCodeDocs

Concepts

Parallel work in worktrees

Run several LoopCode sessions on the same repository at once, each in its own git worktree and branch, without touching each other's files.

Why worktrees

Two agents editing the same checkout trip over each other. A git worktree is a second checkout of the same repository, on its own branch, sharing the history. LoopCode can start a session in a fresh worktree so its changes never touch the checkout you are working in.

Start a session in a worktree

bash
loopcode -w                  # a generated name
loopcode -w payments-fix     # a name of your choice

LoopCode creates .loopcode/worktrees/<name> on a new branch loopcode/<name>, and works there. The folder is kept out of git status automatically.

In a running session, /worktree starts or continues a conversation in a new worktree, and lists and manages existing ones.

Bring along ignored files

Files git ignores but the checkout needs to run — .env, local configuration — are not in a new worktree. List them in a .worktreeinclude file at the repository root, in gitignore syntax, and LoopCode copies them in:

.worktreeinclude
.env
.env.local
config/local.json

When you're done

When you leave a worktree session, LoopCode looks at what is in it:

  • Nothing changed — the worktree is removed.
  • Changes or commits — it asks: keep it, merge it into the main checkout, or remove it (with its branch). Keep is the default.

A kept worktree can be continued later:

bash
cd .loopcode/worktrees/payments-fix && loopcode -c

LoopCode refuses to remove a worktree with uncommitted changes or unmerged commits unless you confirm it.

Subagents in worktrees

LoopCode can also give a subagent its own worktree, so an Agent working on a separate change does not touch your files. Its changes come back as a branch to review and merge.