What a git worktree is in an agent pipeline
A git worktree is an extra working directory that shares one repository; DevFlow creates 1 per task and keeps it for 168 hours, or 7 days, after the task is done.
The git feature
git worktree add checks out a branch into a second folder while sharing the original repository's object store. Creating one is instant, needs no network and avoids a full clone. Each checkout has its own index and HEAD, so work in one never disturbs another.
Why agents need it
Several tasks can run at once, and each AI run edits files. Giving every task its own folder keeps parallel changes apart and leaves the main checkout clean. Cleanup is simple too: remove the folder and its ref, and nothing is left behind.
How DevFlow lays it out
Starting planning creates the checkout under <REPO_PATH>/.devflow/worktrees/<task_id>/, on a branch named devflow/<short_task_id>. Agents write inside it and in a small writable set that the Landlock sandbox defines: the repository's .git directory, the home directory, /tmp and /dev. On the Landlock path, other checkouts and the main working tree are invisible to the run.
At mark-done, the commits are squashed, pushed to the remote, and a pull request opens. The folder is not removed at once: it stays for 168 hours by default, so you can still read the diff and logs in the Review tab.
Cleanup and rework
Removal is event-driven, not a cron job. A sweep runs at server start and after work is marked done or deleted. Deleting a task removes the folder first, then its local ref.
If you rework something whose checkout is gone, DevFlow fetches the pushed copy from the remote and recreates it. If that branch cannot be fetched, the new checkout starts from the remote's default branch instead. The existing pull request link is kept.
Setting the retention to 0 removes the checkout on the next sweep, which matches the older behaviour of cleaning up at mark-done.
FAQ
Do two DevFlow tasks on the same repository conflict?
Not on disk. Each DevFlow task has its own git worktree directory and branch; conflicts can only appear later, when both pull requests change the same code.
Can a DevFlow git worktree be kept forever?
The retention period of a DevFlow git worktree is configurable, and removal after done can be switched off entirely with an environment setting.