From 4cc68ed3ae1b91c23ca93fc4438ca0bd1c5d1442 Mon Sep 17 00:00:00 2001 From: Christian Nennemann Date: Tue, 31 Mar 2026 21:39:04 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20principle=20#34=20=E2=80=94=20git=20wor?= =?UTF-8?q?ktrees=20for=20agent=20isolation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 5738305..5a90918 100644 --- a/README.md +++ b/README.md @@ -374,6 +374,26 @@ The goal is not containers for containers' sake — it's **isolation + reproduci - Dev environment already uses `.devcontainer/Dockerfile` - Next step: containerized worker execution (docker/podman per job) +### 34. Git Worktrees for Agent Isolation + +When multiple agents work on the same repo, use git worktrees instead of branches. Each agent gets a full working copy without cloning. + +- Agent writes to its own worktree — no merge conflicts during work +- Main branch stays clean until merge +- Agents can work in parallel on the same files +- Worktree = disposable sandbox. Commit → merge → delete. +- Cheaper than containers for code-only isolation (no image build, instant) + +**Combination with containers:** Container for runtime isolation (process, network, filesystem). Worktree for code isolation (git history, no conflicts). Best of both: +- Agent runs in container (sandboxed execution) +- Container mounts a worktree (isolated code copy) +- Agent commits to worktree branch +- Team lead merges worktree branches → main + +**Origin:** "Genauso wie git worktree, was wohl auch sehr clever ist" + +**Caveat:** Worktree safety is critical — agents MUST commit before worktree deletion. See Principle #17 (Worktree Safety). + --- ## (inbox — unsorted ideas)