Give Every Feature Its Own Isolated Workspace

2026-06-14 · 中文

Give Every Feature Its Own Isolated Workspace

superpowers core skill · using-git-worktrees

In one line: Don't let AI make big changes in your active workspace. Spin it a separate git worktree — break something and your main dir is untouched.

Scenario: a feature's half-done, then prod blows up

You've got the AI working on the "loyalty points" feature, a pile of files changed and uncommitted. Then prod alerts: the payment page won't open, urgent fix needed. Switch branches in the same workspace? Your uncommitted points changes get tangled with the hotfix, git status is a mess, and the two can corrupt each other.

How to ask the AI

There's an urgent prod bug, but my points feature isn't finished. Use using-git-worktrees to open
a separate worktree for the hotfix: confirm the dir is gitignored, install deps, pass the baseline tests. I'll fix it there without touching these changes.
❌ Weak ✅ Strong
Just stash and switch branches to fix Open a separate worktree to fix; leave the points work untouched
Put the worktree anywhere Put it in .worktrees/, confirm it's gitignored
(baseline tests already failing) just fix Get the baseline green first, or you can't tell the hotfix from old issues

Put your worktree-directory preference in CLAUDE.md once so it stops asking where.

How it'll walk you through it

It picks the directory by priority (existing .worktrees/ > a CLAUDE.md preference > ask you), and runs git check-ignore to confirm it's ignored (if not, it adds to .gitignore first, or the worktree's contents get committed). Then it creates the worktree, installs deps, runs the baseline to confirm clean, and reports "path + tests passing + ready." You fix the payment bug in that clean sandbox while your points changes sit untouched; when done, merge and clean up with git worktree remove.

Remember one line

using-git-worktrees = have the AI work in an isolated sandbox. Especially handy when an urgent task interrupts unfinished work: a worktree each, no cross-contamination; clean up with git worktree remove, not rm.

Link copied