Worktrees
Separate working directories that share one repository history, so multiple Claudes can work on different things at once without colliding.
Working on a new feature, a bug fix, and an experiment all at once means you don't want those Claude Code sessions interfering with each other or your production environment. Worktrees solve this with genuinely separate working directories that each have their own files and branch, while still sharing the same underlying repository history. Launch one with claude --worktree feature-name (or the short form -w); the value you pass becomes both the directory name and the branch name. Three terminal panes, three worktrees, three Claudes working on completely separate copies of your code — merge each branch back in when it's ready, the normal git way.
What's grown since the video: Claude Code now enforces isolation itself — it actively blocks file edits or commands that would reach outside the worktree back into your main checkout, catching mistakes rather than just relying on you keeping track. Cleanup on exit is smarter (it checks whether the worktree has uncommitted work before offering to remove it), a .worktreeinclude file lets you carry gitignored files like .env into every new worktree automatically, and subagents can each get their own isolated worktree too, cleaned up automatically when they finish.
Real-life use cases
Feature work and a hotfix in parallel
A production bug needs an immediate fix while a larger feature is mid-development. Instead of stashing the feature branch, the developer opens a second worktree for the hotfix — both Claude sessions work simultaneously without either one's changes touching the other's files.
Three experiments, one afternoon
Unsure which of three architectural approaches will work best, a developer runs each in its own worktree at the same time, compares the actual working results side by side, and merges only the winner — the other two branches are simply discarded.
Source
- Source video: “Claude Code Explained” — 27 concepts in 27 minutes (YouTube)https://www.youtube.com/watch?v=ZlDnsf_DOzg
- Run parallel sessions with worktreeshttps://code.claude.com/docs/en/worktrees