# Claude Code Worktrees in 7 Minutes

Source: https://www.youtube.com/watch?v=z_VI51k-tn0
Recap page: https://rapidrecap.app/video/z_VI51k-tn0
Generated: 2026-02-21T03:33:21.715+00:00

---
## Quick Overview

The video demonstrates how to leverage Git worktrees with Claude Code, allowing developers to run multiple, isolated Claude Code sessions simultaneously within the same repository for parallel development tasks, such as creating five distinct variations of an HTML landing page, one for each sub-agent, without interference.

**Key Points:**
- Boris Cherry introduces built-in Git worktree support for Claude Code, extending functionality previously only available in the Claude Code Desktop app to the CLI.
- Git worktrees allow multiple branches of the same repository to be checked out simultaneously in different directories, sharing the underlying Git data.
- The demonstration involves creating five variations of an `index.html` file using five different sub-agents, each running in its own isolated Git worktree.
- The speaker explicitly creates a `frontend-dev` sub-agent configuration file specifying the `haiku` model and `worktree` isolation.
- Worktree isolation ensures that agents working on different variations do not cause code edits to clash with each other, enabling parallel work.
- The technique is useful for complex scenarios like rewriting large sections of code or exploring divergent paths without merging conflicts.
- The demonstration concludes by showing the five generated HTML files, each corresponding to a different theme (e.g., Minimal Dark Mode, Gradient Dreamscape).

![Screenshot at 00:26: The initial visual showing the Git repository structure connected via worktrees to three separate directories: ../main, ../feature1, and ../feature2, illustrating the concept of parallel isolation.](https://ss.rapidrecap.app/screens/z_VI51k-tn0/00-00-26.jpg)

**Context:** The video explains an advanced feature of the Anthropic Claude Code tool: the integration of Git worktrees. Git worktrees enable a developer to have multiple working directories checked out from the same repository, each pointing to a different branch or commit, which is crucial for isolating concurrent work streams. This feature is brought to the Claude Code CLI, allowing developers to manage multiple AI agents working on parallel, isolated tasks directly within the command line interface.

## Detailed Analysis

The video begins by referencing a tweet from Boris Cherry announcing built-in `git worktree` support for the Claude Code CLI, a feature previously limited to the desktop application. The presenter explains that Git worktrees allow users to check out multiple branches of the same Git repository simultaneously in different directories, sharing the same Git data but allowing independent work. To demonstrate, the presenter initializes a Git repository, creates an empty `index.html` file, commits it, and then launches Claude Code using the `--worktree` flag. The goal is to create five different variations of the `index.html` file using five different sub-agents, leveraging worktree isolation to prevent interference between the agents' parallel tasks. The presenter first researches how to create custom agents, fetching documentation on sub-agents. Then, the presenter creates a directory for agents and defines a `frontend-dev` sub-agent configuration file, specifying the `haiku` model and setting `isolation` to `worktree`. This worktree isolation ensures that the agent works on an isolated copy of the repo, meaning changes can be reviewed before merging. The process then spawns five task agents in parallel, each working on a unique variation of the landing page. The output shows the agents running concurrently, each working on its own isolated worktree path (e.g., `.../claude/worktrees/agent-a01ee76a/index.html`). Finally, the presenter summarizes the results, showing a table listing the five variations (Minimal Dark Mode, Gradient Dreamscape, etc.) and their unique paths, proving that the isolation mechanism successfully created independent versions of the code.

### Introduction to Git Worktrees in Claude Code

- Introducing built-in git worktree support for Claude Code CLI
- Previously only in the Desktop App
- Enables parallel, isolated work on one repository

### Demonstration Setup

- Initializing a Git repo and creating an empty index.html
- Launching Claude Code with `claude --worktree`
- Goal is to create 5 variations of the HTML file using 5 sub-agents

### Creating a Custom Sub-Agent

- Researching custom agent setup using `claude-code-guide`
- Creating a `frontend-dev` agent configuration file
- Agent specified to use the `haiku` model and `worktree` isolation

### Parallel Execution and Isolation

- Spawning 5 task agents in parallel, each in its own isolated git worktree
- Agents work on different variations simultaneously without conflict
- Worktree isolation ensures changes are reviewed before merging

### Results Summary

- Five variations of the landing page created successfully
- Each variation resides in a unique worktree path
- Worktree isolation prevents tool conflicts across concurrent agents

![Screenshot at 00:04: The terminal showing the initial command claude --worktree being used, signaling the start of the worktree demonstration.](https://ss.rapidrecap.app/screens/z_VI51k-tn0/00-00-04.jpg)
![Screenshot at 00:26: The diagram illustrating the core concept: a single repository branching out to multiple, isolated worktree directories.](https://ss.rapidrecap.app/screens/z_VI51k-tn0/00-00-26.jpg)
![Screenshot at 01:11: The initial commit being made in the base repository before creating worktrees, establishing the starting point.](https://ss.rapidrecap.app/screens/z_VI51k-tn0/00-01-11.jpg)
![Screenshot at 01:21: The Claude Code interface running within the first worktree, showing the agent's initial prompt.](https://ss.rapidrecap.app/screens/z_VI51k-tn0/00-01-21.jpg)
![Screenshot at 06:20: The generated agent configuration file \(frontend-dev.md\) detailing the agent's role, Haiku model, and crucial isolation: worktree setting.](https://ss.rapidrecap.app/screens/z_VI51k-tn0/00-06-20.jpg)
