Worktree Isolation: Safe Parallel Work

Day 47 · Week 10 · Mastery

Slack Message — copy & paste

🤖 Tip #47 — Worktree isolation gives agents their own repo copy — they can break things without touching your working directory.

#47 Claude Code

How Worktrees Protect You

  • **What it does**`isolation: "worktree"` creates a temporary git worktree, a separate checkout of your repo. The agent works there instead of in your active directory.
  • **Safety guarantees**Agent can make experimental changes, run builds that might fail, and explore freely. Your uncommitted work is completely untouched. If anything goes wrong, delete the worktree with zero impact.
  • **Cleanup behavior**If the agent makes no changes, the worktree is auto-cleaned. If it made changes, you get the worktree path and branch name to review before deciding what to keep.
Worktree Isolation Safety
#47 Mastery

Best Use Cases

  1. 1 **Code review**Our `dx-code-reviewer` runs in a worktree. It checks out the PR branch, reads the code, maybe even runs the build to verify. Your main workspace stays exactly as you left it.
  2. 2 **Parallel features**Two agents working on two different features simultaneously, each in their own worktree, while you do a third thing in your main directory.
  3. 3 **Best candidates for worktree isolation**
    • Code review agents — need to checkout PR branches
    • Build verification agents — might break things
    • Experimental refactoring — safe to explore without risk
    • Parallel feature work — multiple agents, multiple branches
  4. 4 **Try it now**Next time you spawn an agent for research or review, add `isolation: "worktree"` to feel the safety. Run `git worktree list` to see current worktrees.
Worktree Isolation Safety
Your screenshot here Optional — add a screenshot from your own workflow
KAI by Dragan Filipovic