Claude Code spends a lot of a task waiting: on a PR review, an architect’s reply, a deploy, a backfill. Those waits are worth filling with another task. But I work from one Codespace with one VS Code window, and a Codespace has one working tree. That left me two options, both inefficient:
Either way I could not really run two tasks at the same time, so every wait was dead time.
Use git worktrees. A worktree is an extra checkout of the same repo, in its own folder and on its own branch, sharing the main checkout’s .git. Each task gets its own worktree, its own terminal/VS Code window and its own Claude session. No branch switching is needed.
How it works:
cura-environmental-services-269792395). The shared /new-worktree skill runs git worktree add and pnpm install, then verifies the result./compact its session and move to another window. When I come back, I resume that same session and its history is still there./clear-worktree skill removes the worktree only after checking that its branch is merged and the tree is clean./new-worktree needs a TeamworkFX todo. Give it the todo URL or id and it reads the todo title to get the client name. The todo id is required because it becomes part of the worktree folder, the branch and the session name. If you know the RCFX site id, it goes into the session name as well.
After the worktree is created, add it to your VS Code window (screenshot):
claude there to start the task, or claude -c to resume it./new-worktree prints the launch command with the session name already filled in, for example claude -n "Acme Roofing - 54487 - 123". The name is Client – SiteID – todo id, so each task’s session is easy to find later with /resume or claude -c. On first use the skill also offers to add a small SessionStart hook to your Claude settings (a backup is kept, and only if you say yes). After that, plain claude in the worktree names the session automatically.
Gotchas:
pnpm start runs collide.Cleaning up when the task is done:
Once the PR is merged, /clear-worktree removes the worktree and its branch. It deletes nothing until every check passes:
git merge-base --is-ancestor).Then it runs git worktree remove and git branch -d. It never uses --force unless you override one specific failed check. If the task also had a follow-up PR branch, pass that branch name as an extra argument. The session’s folder no longer exists afterward, so more work on that task means a new worktree.
Waiting on one task no longer stops me. I move to another task’s window and keep working. Each task keeps its own branch, uncommitted changes and Claude context, so nothing bleeds between them.
The git commands behind the skills:
git worktree add ../micro-services-<slug> -b <branch>
git worktree list
git worktree remove ../micro-services-<slug>
Resuming a task’s session. Each worktree is its own folder, so claude -c run inside it continues that task’s most recent conversation. Open a terminal in the worktree, then:
cd /workspaces/micro-services-<slug>
claude -c
Skills: new-worktree and clear-worktree are shared in the organization’s Claude skills library, so there is nothing to copy. Use /new-worktree to create a task’s worktree and /clear-worktree to remove it once the PR is merged. To customize one, copy it into your own skills folder under a different name.