Lesson 464 of 2116
Worktrees: Isolated Agent Workspaces
Git worktrees let you run multiple Claude Code sessions on the same repo without stepping on each other's diffs. They're the underrated unlock for parallel agent work.
Lesson map
What this lesson covers
Learning path
The main moves in order
- 1What worktrees solve
- 2worktree
- 3branch isolation
- 4parallel sessions
Concept cluster
Terms to connect while reading
Section 1
What worktrees solve
Two Claude Code sessions in the same checkout will fight. They both see the same files, both edit them, and your diff becomes a salad. Worktrees give each session its own working directory backed by the same git repo, so each can have its own branch and its own state without conflict.
The basic move
Each worktree is a separate folder backed by the same repo. Clean up when the work merges.
# From your main checkout
git worktree add ../my-project-feat-auth feat-auth
git worktree add ../my-project-refactor-api refactor-api
# Run a Claude session in each
(cd ../my-project-feat-auth && claude)
(cd ../my-project-refactor-api && claude)
# When done
git worktree remove ../my-project-feat-authWhere worktrees shine
- 1Two features in flight, two agents progressing each one
- 2Spawning a 'spike' agent on an experimental branch while you keep working on main
- 3Reviewing a teammate's PR with an agent without leaving your active branch
- 4Hot-fix on top of a long-running refactor, neither blocking the other
- 5Trying three different approaches to the same problem, one per worktree
Apply: spin up one parallel session
- 1Pick a feature branch you're partway through
- 2Create a worktree on a different branch
- 3Run a separate Claude Code session in it
- 4Make sure both sessions are working on truly independent files
- 5Merge or remove the worktree when the work lands
Key terms in this lesson
The big idea: one agent, one worktree. The git worktree command turns chaotic parallelism into clean parallelism.
End-of-lesson quiz
Check what stuck
15 questions · Score saves to your progress.
Tutor
Curious about “Worktrees: Isolated Agent Workspaces”?
Ask anything about this lesson. I’ll answer using just what you’re reading — short, friendly, grounded.
Progress saved locally in this browser. Sign in to sync across devices.
Related lessons
Keep going
Creators · 9 min
What Perplexity Is: Search-Augmented LLM, Not A Chatbot
Perplexity is built around the idea that every answer should cite its sources. Treating it like ChatGPT misses the point — and the reliability gap that comes with it.
Creators · 10 min
Spaces: Building Team Knowledge Bases In Perplexity
Spaces are Perplexity's project containers — system prompts, files, and shared chat history. They turn the search engine into a research workspace.
Creators · 10 min
Comet Browser: What It Does That Atlas And Operator Don't
Comet is Perplexity's full browser with a research-native sidebar and an action-capable agent. It plays differently than ChatGPT Atlas or Operator — and the differences matter.
