name: isolate-work description: "Create isolated git worktrees for feature work. Smart directory selection and safety verification." disable-model-invocation: true phase: any
Isolate Work
Create an isolated git worktree for feature work so the main working directory stays clean. User-invoked only: do not auto-trigger this skill.
Directory Selection Priority
- Existing directory: check for
.worktrees/orworktrees/in the project root. If both exist,.worktrees/wins. - CLAUDE.md preference: check for a worktree directory preference in the project's CLAUDE.md.
- Ask user: offer two choices:
.worktrees/in the project root (local, hidden)~/.config/forge/worktrees/<project-name>/(global location)
Check: git check-ignore -q <directory> 2>/dev/null
If NOT ignored:
- Add the directory to .gitignore
- Commit the .gitignore change
- THEN proceed with worktree creation
One missed check means worktree contents committed to the repository. No exceptions.
Process Flow
digraph isolate_work {
"Select directory" [shape=box];
"Safety check" [shape=box];
"gitignore verified?" [shape=diamond];
"Add to gitignore + commit" [shape=box];
"Create worktree" [shape=box];
"Install deps" [shape=box];
"Run baseline tests" [shape=box];
"Report" [shape=doublecircle];
"Select directory" -> "Safety check";
"Safety check" -> "gitignore verified?";
"gitignore verified?" -> "Create worktree" [label="yes"];
"gitignore verified?" -> "Add to gitignore + commit" [label="no"];
"Add to gitignore + commit" -> "Create worktree";
"Create worktree" -> "Install deps";
"Install deps" -> "Run baseline tests";
"Run baseline tests" -> "Report";
}
Creation Steps
Create the worktree with a new branch:
git worktree add <dir>/<branch-name> -b <branch-name>Branch naming:
forge/<feature-name>by default, or user-specified.Auto-detect project setup and install dependencies:
package.jsonfound:npm install(oryarn installif yarn.lock present)Cargo.tomlfound:cargo buildpyproject.tomlfound:poetry installgo.modfound:go mod download- Nothing found: skip dependency install
Run baseline tests using the project's test command. This establishes a known-good state. If tests fail, report the failures and ask whether to proceed.
Report: worktree path, branch name, baseline test results.
Anti-Patterns
"Skip the gitignore check" One missed check means worktree contents committed to the repo. The HARD-GATE exists for a reason.
"Skip baseline tests" Without a known-good baseline, you cannot distinguish new regressions from pre-existing failures.
"Hardcode setup commands" Auto-detect from project manifest files. Different projects use different tools.
"Assume the directory location" Follow the priority: existing directory, then CLAUDE.md, then ask the user. Consistency matters.
Evidence Requirements
- Worktree directory is in
.gitignore(verified withgit check-ignore) - Baseline tests pass in the new worktree
- Worktree path and branch name reported to user
Cleanup
Handled by land-changes. When the user chooses merge, PR, keep, or discard, land-changes runs git worktree remove as part of workspace cleanup.