Skip to main content
Mythos

A Worktree in 📝Claude Code is an isolated git worktree the harness creates for an agent's file edits, spawned via isolation: "worktree" in the Agent tool to prevent parallel agents from colliding on the main checkout.

When the harness spawns a subagent (via the Agent tool) with isolation: "worktree", it runs git worktree add to a temporary path branched from the current HEAD, then directs all of the subagent's file operations to that isolated working tree. The parent session continues editing the main checkout untouched. When the subagent completes, the harness reports the worktree path and branch in the result; if the subagent made no changes, the worktree is automatically cleaned up.

The pattern matters most when multiple subagents work in parallel. Without worktree isolation, two agents editing the same file produce a race condition or merge conflict. With worktrees, each agent has its own filesystem view, and integration happens at the parent level after agents return. This is the foundation of safe parallel-fan-out workflows — design exploration, multi-implementation experiments, or large refactors split across agents.

For practitioners who orchestrate beyond a single Claude Code session, the 📝Agent Worktree System extends the pattern with branch management, status tracking, and cross-session continuity, treating worktrees as first-class units of agent work rather than ephemeral scratch space.

Contexts

Created with 💜 by One Inc | Copyright 2026