using-git-worktrees
Skill3 starsChanged 20 days agoMITView on GitHub
Use at session start, when creating change artifacts, or before implementing a plan - resolves the workspace policy (worktree by default, human-requested feature branch as exception) and never writes on the base branch; prefers native worktree tools over git worktree
189 other projects use a version of this, 142 of them edited.
Adopted by
Most recently taken up by
- DemonDamon/AgenticXedited, first seen Nov 9, 2026
- chrysogonus/power-agentsedited, first seen Nov 8, 2026
- roundpilot/superpowers-antigravityedited, first seen Nov 8, 2026
- REPOZY/superpowers-optimizedtheir own version, first seen Nov 8, 2026
- lingyired/status-trioedited, first seen Nov 8, 2026
- afawfawffaf/my-skillsedited, first seen Nov 8, 2026
Used with
Projects with it also use chinese-code-review, chinese-commit-conventions and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Leodorareluctant259Skillchinese-code-review
中文代码审查规范——在保持专业严谨的同时,用符合国内团队文化的方式给出有效反馈
Also in 8 projects that use this
Leodorareluctant259Skillchinese-commit-conventions
中文 Git 提交规范 — 适配国内团队的 commit message 规范和 changelog 自动化
Also in 8 projects that use this
obraSkilldiagnosing-superpowers
Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.
Also in 20 projects that use this
frankxaiSkilldefense-in-depth
Use when invalid data causes failures deep in execution, requiring validation at multiple system layers - validates at every layer data passes through to make bugs structurally impossible
Also in 4 projects that use this
xfstudioSkilltest-fixing
Run tests and systematically fix all failing tests using smart error grouping. Use when user asks to fix failing tests, mentions test failures, runs test suite and failures occur, or requests to make tests pass.
Also in 3 projects that use this
kntismSkillcondition-based-waiting
Use when tests have race conditions, timing dependencies, or inconsistent pass/fail behavior - replaces arbitrary timeouts with condition polling to wait for actual state changes, eliminating flaky tests from timing guesses
Also in 3 projects that use this
- +3 more from Leodorareluctant259
Other versions189 projects use a version of this.
Word for word · 0
None found.
Edited · 142
- obra/superpowers★ 314k45% same
- jnMetaCode/superpowers-zh★ 8.4k10% same
- openai/plugins★ 7.8k45% same
- farm-fe/farm★ 5.6k43% same
- lingyired/status-trio★ 1.8k45% same
- pcvelz/superpowers★ 1.3k41% same
- DemonDamon/AgenticX★ 1k12% same
- usewhale/DeepSeek-Code-Whale★ 93343% same
- usewhale/Whale★ 92843% same
- coco-research/coco★ 79712% same
132 more not listed
Wrote their own version · 47
- microsoft/FluidFramework★ 4.9ksame name
- silvertakana/worldwideview★ 1.9ksame name
- GanyuanRan/Aegis★ 1.4ksame name
- Innei/ryugi★ 378same name
- KbWen/agentic-os★ 229same name
- REPOZY/superpowers-optimized★ 146same name
- aaddrick/claude-pipeline★ 128same name
- shibit-net/xuanji-community★ 90same name
- GEd520/legados★ 75same name
- KbWen/agent-virtual-office★ 65same name
37 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository18 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- architectural-decision-recordsSkill
- conventional-commitsSkill
- gherkin-specsSkill
- git-workflowSkill
- grillingSkill
- implementation-standardsSkill
- openspec-apply-changeSkill
- openspec-archive-changeSkill
- openspec-exploreSkill
- openspec-proposeSkill
- openspec-sync-specsSkill
- openspec-workflowSkill
- session-endSkill
- session-startupSkill
- test-driven-developmentSkill
- update-harnessSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
23 rules. 0 are common, 15 are distinctive, and 8 are very specific to this project.
0
Common
Most of the 182 edited versions we read keep these.
15
Distinctive
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
Ensure work happens in an isolated workspace.
- Distinctive: line 15
Never fight the harness.
- Distinctive: line 17
Workspace policy: every change is written on its own branch.
- Distinctive: line 56
If the user declines, work in place only when they asked for a simple feature branch and the working tree is clean.
- Very specific: line 66
Do you already have a way to create a worktree?
- Distinctive: line 79
Check your instructions for a declared worktree directory preference.
- Very specific: line 80
Check for an existing project-local directory: ls -d .worktrees (preferred) or ls -d worktrees.
- Very specific: line 81
If both exist, .worktrees wins.
- Very specific: line 92
If NOT ignored: add it to .gitignore, commit, then proceed.
- Distinctive: line 103
Sandbox fallback: if git worktree add fails with a permission error, tell the user the sandbox blocked it and work in the current directory …
- Very specific: line 108
Run the project's install command from AGENTS.md § Comandos (INSTALL_COMMAND).
- Very specific: line 113
Run the project's test command (TEST_COMMAND).
- Distinctive: line 147
Write on the base branch: isolate the change or stop and ask
- Distinctive: line 148
Create a worktree when Step 0 detects existing isolation
- Very specific: line 149
Use git worktree add when you have a native worktree tool (e.g., EnterWorktree)
- Distinctive: line 151
Create a worktree without verifying it's ignored (project-local)
- Distinctive: line 156
Run Step 0 detection first
- Distinctive: line 157
Prefer native tools over git fallback
- Distinctive: line 158
Follow directory priority: explicit instructions > existing project-local directory > default
- Distinctive: line 159
Verify the directory is ignored for project-local
- Very specific: line 160
Use the project's INSTALL_COMMAND / TEST_COMMAND
- Distinctive: line 161
Verify a clean test baseline
- Distinctive: line 165
Read only when needed:
“Common” is measured: kept by at least 6 in 10 of the 182 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Using Git Worktrees
Overview
Ensure work happens in an isolated workspace. Prefer your platform's native worktree tools. Fall back to manual git worktrees only when no native tool is available.
Core principle: Detect existing isolation first. Then use native tools. Then fall back to git. Never fight the harness.
Workspace policy: every change is written on its own branch. The default is a worktree; a simple feature branch in the main checkout is an exception the human requests explicitly. The base branch is never written to. This skill applies at three trigger points:
- Session start — report the current branch, whether the working directory is a worktree and the active change. Do not create anything yet.
- Before creating change artifacts — isolate first if the current branch is the base branch.
- Before implementing a plan — same check.
Announce at start: "I'm using the using-git-worktrees skill to set up an isolated workspace."
Step 0: Detect Existing Isolation
Before creating anything, check if you are already in an isolated workspace.
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 is also true inside git submodules. Before concluding
"already in a worktree," verify you are not in a submodule:
# 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/nullIf GIT_DIR != GIT_COMMON (and not a submodule): you are already in a linked worktree. Skip to
Step 2. Do NOT create another worktree. Report: "Already in isolated workspace at <path> on branch
<name>." (Detached HEAD: note that branch creation is needed at finish time.)
If GIT_DIR == GIT_COMMON (or in a submodule): you are in a normal repo checkout. Resolve consent
from the preference already declared in AGENTS.md or the session instructions. When the declared
default is a worktree, do not ask again. Ask only when no preference exists:
"Would you like me to set up an isolated worktree? It protects your current branch from changes."
If the user declines, work in place only when they asked for a simple feature branch and the working tree is clean. Never work on the base branch: isolate, or stop and ask. Record the exception in the change.
Step 1: Create Isolated Workspace
Two mechanisms. Try them in this order.
1a. Native Worktree Tools (preferred)
Do you already have a way to create a worktree? It might be a tool named like EnterWorktree,
WorktreeCreate, a /worktree command, or a --worktree flag. If so, use it and skip to Step 2.
Native tools handle directory placement, branch creation and cleanup automatically; using
git worktree add when you have one creates phantom state your harness cannot see or manage.
1b. Git Worktree Fallback
Only if Step 1a does not apply.
Directory Selection
Explicit user preference always beats observed filesystem state.
- Check your instructions for a declared worktree directory preference.
- Check for an existing project-local directory:
ls -d .worktrees(preferred) orls -d worktrees. If both exist,.worktreeswins. - Otherwise default to
.worktrees/at the project root.
Safety Verification (project-local directories only)
MUST verify the directory is ignored before creating the worktree:
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/nullIf NOT ignored: add it to .gitignore, commit, then proceed. Prevents accidentally committing
worktree contents.
Create the Worktree
path="$LOCATION/$BRANCH_NAME"
git worktree add "$path" -b "$BRANCH_NAME"
cd "$path"Sandbox fallback: if git worktree add fails with a permission error, tell the user the sandbox
blocked it and work in the current directory instead.
Step 2: Project Setup
Run the project's install command from AGENTS.md § Comandos (INSTALL_COMMAND). If it is N/A,
skip this step. Do not guess stack-specific commands.
Step 3: Verify Clean Baseline
Run the project's test command (TEST_COMMAND). If it is N/A, state that there is no automated
baseline.
If tests fail: report failures and ask whether to proceed or investigate. If they pass: report ready.
Report
Worktree ready at <full-path>
Tests passing (<N> tests, 0 failures)
Ready to implement <feature-name>Quick Reference
| 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) |
worktrees/ exists | Use it (verify ignored) |
| Both 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 |
INSTALL_COMMAND is N/A | Skip dependency install |
Red Flags
Never:
- Write on the base branch: isolate the change or stop and ask
- Create a worktree when Step 0 detects existing isolation
- Use
git worktree addwhen you have a native worktree tool (e.g.,EnterWorktree) - Skip Step 1a by jumping straight to Step 1b's git commands
- Create a worktree without verifying it's ignored (project-local)
- Skip baseline test verification
- Proceed with failing tests without asking
Always:
- Run Step 0 detection first
- Prefer native tools over git fallback
- Follow directory priority: explicit instructions > existing project-local directory > default
- Verify the directory is ignored for project-local
- Use the project's
INSTALL_COMMAND/TEST_COMMAND - Verify a clean test baseline
References
Read only when needed:
references/common-mistakes.md— the five recurring mistakes and their fixes.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

