بنقرة واحدة
superpowers-using-git-worktrees
Feature work needing an isolated workspace, or executing a plan? Load first.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Feature work needing an isolated workspace, or executing a plan? Load first.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
Got a spec or requirements for a multi-step task? Load first, before touching code.
Sync this port with upstream obra/superpowers or Reasonix main-v2: detect drift, re-port, bench-gate
Building a feature or starting from an idea? STOP. Load first for an approved design before code.
Executing a written plan step-by-step in this session, with checkpoints? Load this first.
Branch finished, tests green? Load first to merge, PR, or clean up.
Got review feedback? Load BEFORE changing anything — verify each point, push back if wrong.
استنادا إلى تصنيف SOC المهني
| name | superpowers-using-git-worktrees |
| description | Feature work needing an isolated workspace, or executing a plan? Load first. |
Work in isolated workspace. Prefer native worktree tools; manual git worktrees only when none.
Core principle: Detect existing isolation first. Then native tools. Then git fallback. Never fight harness.
Announce at start: "I'm using the superpowers-using-git-worktrees skill to set up an isolated workspace."
Before creating anything, check if already in isolated workspace. Via bash:
GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
BRANCH=$(git branch --show-current)
Submodule guard: GIT_DIR != GIT_COMMON also true inside submodules. Verify not a submodule before concluding "worktree":
# If this returns a path, you're in a submodule, not a worktree — treat as normal repo
git rev-parse --show-superproject-working-tree 2>/dev/null
If GIT_DIR != GIT_COMMON (and not a submodule): Already in linked worktree. Skip to Step 3, do NOT create another. Report branch state:
<path> on branch <name>."<path> (detached HEAD, externally managed). Branch creation needed at finish."If GIT_DIR == GIT_COMMON (or in a submodule): Normal repo checkout. Preference declared? Honor it, no asking. Else ask consent:
"Would you like me to set up an isolated worktree? It protects your current branch from changes."
Declines: work in place, skip to Step 3 — do NOT start editing feature code on the current branch first.
Already have a worktree mechanism — a tool named EnterWorktree, WorktreeCreate, a /worktree command, or a --worktree flag? Use it, skip to Step 3.
Native tools handle placement, branch creation, cleanup. Using git worktree add when a native tool exists creates phantom state the harness can't manage. No native tool: proceed to Step 1b.
Only use if Step 1a does not apply. Explicit user preference always beats filesystem state.
ls -d .worktrees 2>/dev/null # Preferred (hidden)
ls -d worktrees 2>/dev/null # Alternative
Both exist? .worktrees wins.project=$(basename "$(git rev-parse --show-toplevel)")
ls -d ~/.config/reasonix/worktrees/$project 2>/dev/null
.worktrees/ at project root.MUST verify directory ignored before creating worktree:
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
If NOT ignored: add to .gitignore, commit, proceed. Why critical: prevents committing worktree contents. Global directories need no verification.
# For project-local: path="$LOCATION/$BRANCH_NAME"
# For global: path="~/.config/reasonix/worktrees/$project/$BRANCH_NAME"
git worktree add "$path" -b "$BRANCH_NAME"
cd "$path"
Sandbox fallback: git worktree add fails with permission error (sandbox denial — Reasonix confines writes to [sandbox] workspace_root)? Tell the user the sandbox blocked it, working in the current directory instead. Run setup and baseline tests in place.
Auto-detect and run setup, bash:
if [ -f package.json ]; then npm install; fi
if [ -f Cargo.toml ]; then cargo build; fi
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f pyproject.toml ]; then poetry install; fi
if [ -f go.mod ]; then go mod download; fi
Run tests, ensure clean baseline (npm test / cargo test / pytest / go test ./...).
Tests fail: report failures, ask whether to proceed or investigate. Pass: report ready.
Worktree ready at <full-path>
Tests passing (<N> tests, 0 failures)
Ready to implement <feature-name>
| Situation | Action |
|---|---|
| Already in linked worktree | Skip creation (Step 0) |
| In a submodule | Treat as normal repo (Step 0 guard) |
| Native worktree tool available | Use it (Step 1a) |
| No native tool | Git worktree fallback (Step 1b) |
.worktrees/ exists | Use it (verify ignored) |
Both .worktrees/ and worktrees/ exist | Use .worktrees/ |
| Neither exists | Check instruction file, then default .worktrees/ |
| Directory not ignored | Add to .gitignore + commit |
| Permission error on create | Sandbox fallback, work in place |
| Tests fail during baseline | Report failures + ask |
Never:
git worktree add when a native worktree tool exists — #1 mistakeAlways: run Step 0 first; prefer native tools; follow directory priority (existing > global legacy > instruction file > default); verify ignored for project-local; auto-detect and run setup; verify clean test baseline.