using-git-worktrees
Skill24 starsChanged 24 days agoMITView on GitHub
Create or verify an isolated git worktree before starting any development work. Prevents main branch contamination, enables parallel feature development, and gives subagents a clean baseline. Use at the start of every feature branch.
- Installs packages
189 other projects use a version of this.
Adopted by
Most recently taken up by
- DemonDamon/AgenticXtheir own version, first seen Nov 9, 2026
- chrysogonus/power-agentstheir own version, first seen Nov 8, 2026
- roundpilot/superpowers-antigravitytheir own version, first seen Nov 8, 2026
- REPOZY/superpowers-optimizedtheir own version, first seen Nov 8, 2026
- lingyired/status-triotheir own version, first seen Nov 8, 2026
- afawfawffaf/my-skillstheir own version, 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 · 0
None found.
Wrote their own version · 189
- obra/superpowers★ 314ksame name
- jnMetaCode/superpowers-zh★ 8.4ksame name
- openai/plugins★ 7.8ksame name
- farm-fe/farm★ 5.6ksame name
- microsoft/FluidFramework★ 4.9ksame name
- silvertakana/worldwideview★ 1.9ksame name
- lingyired/status-trio★ 1.8ksame name
- GanyuanRan/Aegis★ 1.4ksame name
- pcvelz/superpowers★ 1.3ksame name
- DemonDamon/AgenticX★ 1ksame name
179 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 repository22 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/rules/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- api-contract-firstSkill
- architecture-auditSkill
- brainstormingSkill
- data-migrationSkill
- dispatching-parallel-agentsSkill
- executing-plansSkill
- finishing-a-development-branchSkill
- five-whysSkill
- incident-responseSkill
- performance-auditSkill
- skill-duplication-auditSkill
- smart-initSkill
- subagent-driven-developmentSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- using-a-teamSkill
- verification-before-completionSkill
- writing-plansSkill
- writing-skillsSkill
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 7 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 182 edited versions we read keep these.
7
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Use at the START of every feature or bug fix.
- Distinctive: line 38
If you're already in a worktree for this feature: proceed to Step 3 (verify clean baseline).
- Distinctive: line 39
If you're in the main checkout: proceed to Step 2.
- Very specific: line 53
If the project uses .claude/worktrees/, use that path instead:
- Distinctive: line 69
If status shows unexpected changes: something is wrong — investigate before proceeding.
- Distinctive: line 81
If baseline build or tests fail: STOP.
- Distinctive: line 89
After the branch is merged or abandoned:
- Distinctive: line 115
Always use worktrees for subagent work.
“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
Why Worktrees
A worktree is a second checkout of the same repo in a separate directory. Each worktree has its own working tree and HEAD, but shares the git object store. This means:
- Subagents work in isolation — no interference with your main session
- You can switch tasks without stashing
- Parallel features develop independently
- Clean rollback: abandon the worktree, nothing pollutes main
When to Use
Use at the START of every feature or bug fix. Do NOT start implementation until a clean worktree exists or you've confirmed you're already in one.
Mandatory before:
subagent-driven-developmentskillexecuting-plansskill- Any work touching more than one file
The Process
Step 1: Detect Existing Isolation
First check — are you already isolated?
# Check if current directory is a worktree (not the main checkout)
git worktree list
pwdIf you're already in a worktree for this feature: proceed to Step 3 (verify clean baseline). If you're in the main checkout: proceed to Step 2.
Step 2: Create the Worktree
# Create worktree + new branch in one command
git worktree add ../worktrees/<feature-name> -b feat/<feature-name>
# Examples:
git worktree add ../worktrees/stripe-billing -b feat/stripe-billing
git worktree add ../worktrees/fix-auth-bug -b fix/auth-token-expiryThe worktree is created at ../worktrees/<feature-name> (sibling of the project root).
If the project uses .claude/worktrees/, use that path instead:
git worktree add .claude/worktrees/<feature-name> -b feat/<feature-name>Step 3: Verify Clean Baseline
Move into the worktree and confirm it starts clean:
cd ../worktrees/<feature-name> # or .claude/worktrees/<feature-name>
git status # Should show: "nothing to commit"
git log --oneline -3 # Confirm you branched from the right pointIf status shows unexpected changes: something is wrong — investigate before proceeding.
Step 4: Run Project Setup
Install dependencies and confirm the baseline builds:
npm install # or pip install -r requirements.txt / go mod download
npm run build # Confirm baseline build passes BEFORE any changes
npm test # Confirm baseline tests pass BEFORE any changesIf baseline build or tests fail: STOP. Fix the issue on main first, then recreate the worktree.
Step 5: Proceed with Work
Now development starts. The worktree is isolated, the baseline is confirmed clean.
Cleanup After Work Completes
After the branch is merged or abandoned:
# From the main checkout (not from inside the worktree)
git worktree remove ../worktrees/<feature-name>
git branch -d feat/<feature-name> # Only after mergeCommon Issues
| Issue | Fix |
| "already checked out" error | The branch exists in another worktree — use a different branch name |
| Worktree has unexpected changes | Run git status to investigate; never force-remove with uncommitted work |
| Setup script fails in worktree | Check for absolute paths in scripts; worktrees use different working directories |
| Submodules not initialized | Run git submodule update --init --recursive in the new worktree |
Worktree vs Branch Checkout
git worktree | git checkout -b | |
| Main session disrupted | No | Yes |
| Parallel work possible | Yes | No |
| Independent node_modules | Yes (separate dir) | Shared |
| Subagent isolation | Clean | Risk of contamination |
Always use worktrees for subagent work. The isolation is the point.
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.

