About workspace-isolation
workspace-isolation is a skill for coding agents that uses Git worktrees to keep implementation separate from the user's checkout and other work. It covers isolation detection, setup, baseline testing, and cleanup boundaries before and after changes.
Key features
- 01Detect existing worktree isolation
- 02Prefer harness-managed worktrees
- 03Create a Git worktree when needed
- 04Set up dependencies and run baseline tests
- 05Limit cleanup to worktrees created in the run
Use cases
- 01Protect uncommitted work in the user's checkout
- 02Prepare isolated work for parallel agents
- 03Verify a clean baseline before implementation
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ noobygains/ godmode --skill workspace-isolationAfter installing, type/workspace-isolationin Claude Code to confirm it loaded.
Details
From the project READMEWorkspace Isolation
A git worktree is a second working directory on its own branch that shares the repository's history. Work in one cannot disturb the files in another, so a plan can run without risking the user's checkout, and parallel agents cannot overwrite each other.
Core principle: detect existing isolation first, prefer the harness's own worktree mechanism, fall back to plain git, and never start work on a baseline you have not tested. A worktree created behind the harness's back is state it cannot see or clean up; a worktree started on a red baseline makes every later failure ambiguous.
The Prime Directive
NO IMPLEMENTATION WITHOUT AN ISOLATED WORKSPACE AND A KNOWN BASELINE
No exceptions. No workarounds. No shortcuts.
When to Use
Required:
- Before
godmode:delegated-executionorgodmode:inline-executionstarts Task 1. - Before parallel agents that write files (
godmode:parallel-execution). - When the user's checkout has uncommitted work you must not disturb.
Skip:
- Read-only investigation or review.
- The user has said to work in place; record that in the ledger and still run the baseline tests.
- Not a git repository: say so, and ask the user whether to
git initor work in place.
The Protocol
1. Detect existing isolation
git_dir=$(cd "$(git rev-parse --git-dir)" && pwd -P)
git_common=$(cd "$(git rev-parse --git-common-dir)" && pwd -P)
super=$(git rev-parse --show-superproject-working-tree 2>/dev/null)
branch=$(git branch --show-current)
git_dirdiffers fromgit_commonandsuperis empty: you are already in a linked worktree. Do not create another. Go to step 4.superis not empty: you are in a submodule, not a worktree. Treat it as a normal checkout.- Detached HEAD in a linked worktree: the host manages it. Note that a branch must be created at finish time.
2. Get consent and a name
If the user's instructions already state a worktree preference, follow it. Otherwise say in one line that you will create a worktree to protect their checkout, and proceed unless they have said to work in place. Choose a short branch name from the work (feature/csv-export, fix/login-race).
3. Create the worktree
3a. The harness's own mechanism first. If the harness can create a worktree itself (a built-in action, a command-line flag, or a per-subagent isolation option), use it: it owns placement, branch creation, cleanup and its own isolation checks. The harness reference names the action. Facts to know on Claude Code:
- Session worktrees go under
.claude/worktrees/<name>/on a branchworktree-<name>; add.claude/worktrees/to.gitignore. - New worktrees branch from the repository's default branch, not from your current
HEAD, unless the project's worktree base setting says otherwise. If the work must build on unpushed commits or a feature branch, check the base before relying on it. - Gitignored files such as
.envare not copied unless the project has a.worktreeincludefile listing them. - A subagent run with worktree isolation gets a temporary worktree that is removed automatically if it made no changes.
3b. Plain git otherwise. Pick the directory in this order; an explicit preference always beats what you find on disk:
- A worktree directory the user's instructions declare.
- An existing
.worktrees/at the repository root. - An existing
worktrees/at the repository root (if both exist,.worktrees/wins). - Default: create
.worktrees/.
Verify a project-local directory is ignored before creating anything inside it:
git check-ignore -q .worktrees || echo "NOT IGNORED"
If it is not ignored, add the directory to .gitignore, commit that one-line change on the current branch, and say so. An unignored worktree directory gets committed into the repository wholesale.
base=$(git rev-parse HEAD) # or the branch the plan says to start from
git worktree add ".worktrees/$name" -b "$branch" "$base"
cd ".worktrees/$name"
If creation fails with a permission or sandbox error, tell the user, and work in the current checkout on a new branch instead.
4. Set up the project
Detect and run the project's own setup, preferring what its README or contributing guide says over guesses:
| Marker | Setup |
|---|---|
package-lock.json / pnpm-lock.yaml / yarn.lock | npm ci / pnpm install --frozen-lockfile / yarn install --frozen-lockfile |
pyproject.toml / requirements.txt | the project's tool (uv sync, poetry install, pip install -r requirements.txt) in a virtual environment |
Cargo.toml | cargo build |
go.mod | go mod download |
Copy any local configuration the tests need (for example .env.example to .env) only when the project documents it. Never copy secrets into a tracked file. godmode:environment-awareness covers shell and package-manager differences.
5. Run the baseline tests
Run the project's full test command and read the output.
- Green: record the count.
- Red: report the failures and ask the user whether to proceed or investigate first. If they say proceed, ledger
Baseline: <n> failing before any change: <names>so later failures can be told apart.
6. Report
Worktree: <absolute path> (branch <name>, from <base sha>, created by <harness | git>)
Setup: <command> ok
Baseline: <command> -> <n> passed, <m> failed
This block goes in the plan ledger as well as the message.
Cleanup
Cleanup belongs to godmode:merge-protocol. The rule for this skill: remove only worktrees this run created under .worktrees/ or worktrees/; leave harness-managed worktrees to the harness; never force-remove a worktree that holds uncommitted or untracked files without asking the user.
Cognitive Traps
| Rationalisation | Truth |
|---|---|
| "I'm obviously not in a worktree" | Harness-created isolation and submodules both fool a glance. Run the detection commands. |
"git worktree add is quicker than the harness's way" | The harness cannot see or clean up a worktree it did not make, and its isolation checks do not cover it. |
| "The directory is surely ignored" | Run git check-ignore. One miss commits a whole tree. |
| "The new worktree has my branch's commits" | Some harnesses branch from the default branch. Check git log -1 in the worktree. |
| "Baseline tests can wait, it's a fresh checkout" | A red baseline makes every later failure ambiguous. Run them now. |
| "Dependencies are the same as the main checkout" | A worktree is a fresh checkout. Install them. |
Guardrails
Never:
- Create a worktree inside an existing linked worktree.
- Create a project-local worktree directory that git does not ignore.
- Start implementation on a baseline you have not run.
- Copy secrets into tracked files.
- Remove worktrees you did not create.
Always:
- Prefer the harness's own worktree mechanism when it has one.
- Confirm the worktree's base commit is the one the work needs.
- Report path, branch, base, setup and baseline counts.
Connections
godmode:delegated-execution,godmode:inline-execution: call this before Task 1.godmode:parallel-execution: one worktree per writing agent.godmode:environment-awareness: shells, package managers and Windows paths during setup.godmode:merge-protocol: lands the branch and tears the worktree down.