skills/worktree/SKILL.md
Creates a git worktree for isolated parallel development — new branch in a separate directory with project setup and test baseline. Enables multiple Claude Code sessions on different tasks simultaneously. Multi-repo aware. Use when you need to work on something else without disturbing current work.
npx skillsauth add oprogramadorreal/optimus-claude skills/worktreeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Create a git worktree for isolated parallel development. Sets up a new branch in a separate directory (.worktrees/) with project setup and test baseline, so the main workspace stays untouched. Each worktree can host an independent Claude Code session.
Read $CLAUDE_PLUGIN_ROOT/skills/init/references/multi-repo-detection.md for workspace detection. If a multi-repo workspace is detected:
.git/, so git commands must target individual repos)AskUserQuestion — header "Target repo", question "Which repo should the worktree be created for?": list each repo as an optionRead $CLAUDE_PLUGIN_ROOT/skills/worktree/references/worktree-setup.md and run the worktree detection guard from that reference. If the guard detects you are already inside a linked worktree, inform the user:
Already running inside a worktree (`<worktree-path>`).
To create another worktree, run this skill from the main workspace instead.
Then stop — do not create recursive worktrees.
Record the current branch:
git rev-parse --abbrev-ref HEAD
Determine a meaningful description for the branch from the first source that provides enough signal (check in this priority order):
/optimus:worktree "fix login timeout"), use it directlyIf neither source provides enough signal, use AskUserQuestion — header "Worktree scope", question "What will you work on in the new worktree?":
Read $CLAUDE_PLUGIN_ROOT/skills/commit/references/branch-naming.md for the naming convention. Determine <type> and generate the slug from the description.
Handle collisions: if git show-ref --verify --quiet refs/heads/<branch-name> succeeds (branch exists), append -2 to the slug. If that also exists, try -3, and so on up to -9. If all collide, inform the user and stop.
Create the branch without switching to it:
git branch <branch-name>
Follow the setup procedure from $CLAUDE_PLUGIN_ROOT/skills/worktree/references/worktree-setup.md using <branch-name> and <original-branch> from Step 3. The procedure handles:
.worktrees/ and ensuring it is gitignoredgit worktree add .worktrees/<worktree-dir> <branch-name>If worktree creation fails, report the error with diagnostic information and stop.
## Worktree Created
Working directory: `.worktrees/<worktree-dir>`
Branch: `<branch-name>` (from `<original-branch>`)
Main workspace: `<original-branch>` (unchanged)
Tests: passing / no test command detected
### Open the worktree
**VSCode** (recommended — each worktree gets its own window, terminal, and file watchers):
- Source Control panel → right-click the worktree → "Open Worktree in New Window"
- Or from terminal: `code .worktrees/<worktree-dir>`
- Or Command Palette → "Git: Open Worktree in New Window"
**Claude Code CLI**: `cd .worktrees/<worktree-dir> && claude`
### Cleanup
When done: `git worktree remove .worktrees/<worktree-dir>`
Recommend running /optimus:tdd in the new worktree for test-driven development, or /optimus:init if the worktree needs project setup.
Tell the user: Tip: for best results, start a fresh conversation for the next skill — each skill gathers its own context from scratch.
<original-branch>.worktrees/ (gitignored) to keep the project root cleandevelopment
Iterative test-coverage improvement loop — dispatches `/optimus:unit-test` (unit-test phase) and `/optimus:refactor` with testability focus (refactor phase) into fresh subagent contexts per cycle, applies tests, runs the test suite, bisects refactor failures, and continues until coverage plateaus or the cycle cap (default 5, hard cap 10). Use to drive coverage up on a codebase that has untestable barriers — the loop alternates between writing tests and unblocking testability so a single skill cannot stall.
development
Iterative project-wide refactoring — runs `/optimus:refactor` in a fresh subagent context per iteration, applies fixes, runs tests, bisects failures, and continues until convergence or the iteration cap (default 8, hard cap 20). Supports `testability` or `guidelines` focus to prioritize finding categories. Each iteration runs in an isolated subagent so context does not accumulate. Requires a test command in .claude/CLAUDE.md. Use for thorough guideline alignment or testability cleanup before /optimus:unit-test.
development
Iterative auto-fix code review — runs `/optimus:code-review` in a fresh subagent context per iteration, applies fixes, runs tests, bisects failures, and continues until convergence or the iteration cap (default 8, hard cap 20). Each iteration runs in an isolated subagent so context does not accumulate. Requires a test command in .claude/CLAUDE.md. Use when single-pass review leaves issues or for thorough cleanup before a release.
development
Implements an approved spec by having Claude design and run its own Claude Code dynamic workflow (real parallel subagents) — you hand it the goal and constraints, it chooses the orchestration. Test-first is enforced as a quality bar (tests accompany or precede code and the suite is left green), not as supervised Red-Green-Refactor. A peer of /optimus:tdd for spec implementation; prefer it for large or parallelizable specs where one linear pass is slow. Requires /optimus:init and a spec (auto-detects docs/specs/ or docs/jira/, or pass a path). Uses meaningfully more tokens than a normal session. Use when a spec is ready to build and you want fan-out implementation instead of turn-by-turn TDD cycles.