using-git-worktrees
Skill10 starsChanged 3 months agoMITView on GitHub
Use when starting feature work that needs isolation from current workspace, or setting up parallel development tracks. Triggers: 'worktree', 'separate branch', 'isolate this work', 'don't mess up current work', 'work on two things at once', 'parallel workstreams', 'new branch for this', 'keep my current work safe'.
- Installs packages
139 other projects use a version of this, 107 of them edited.
Adopted by
Most recently taken up by
- JorgeMenaDev/skillstheir own version, first seen Oct 4, 2026
- LayneChai/superpowers-dshedited, first seen Oct 3, 2026
- HanksChen0110/skillsedited, first seen Oct 3, 2026
- JameMy0001/antigravity-skills-hubedited, first seen Oct 2, 2026
- lsy041015/orchestraedited, first seen Oct 2, 2026
- Wenaixi/dsh-superpowertheir own version, first seen Oct 1, 2026
Used with
Projects with it also use diagnosing-superpowers, chinese-git-workflow and 9 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.
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 6 projects that use this
MorningStar0709Skillchinese-git-workflow
Configure Git for domestic platforms and manage branching strategies suitable for Chinese teams. Use when the user asks to configure remotes, set up SSH, or manage Git workflows for Gitee, Coding, Jihu GitLab, or CNB, including requests like "配置国内 Git", "设置 Gitee 远程仓库", "推荐适合小团队的 Git 流程".
Also in 4 projects that use this
shibit-netSkillchinese-code-review
中文 review 沟通参考——话术模板、分级标注(必须修复/建议修改/仅供参考)、国内团队常见反模式应对。仅在用户显式 /chinese-code-review 时调用,不要根据上下文自动触发。
Also in 3 projects that use this
shibit-netSkillchinese-commit-conventions
中文 commit 与 changelog 配置参考——Conventional Commits 中文适配、commitlint/husky/commitizen 中文模板、conventional-changelog 中文配置。仅在用户显式 /chinese-commit-conventions 时调用,不要根据上下文自动触发。
Also in 3 projects that use this
MorningStar0709Skillworkflow-runner
Run an agency-orchestrator style YAML workflow inside the current Trae conversation by simulating or coordinating multiple roles. Use when the user provides a `.yaml` or `.yml` workflow, asks for multi-role collaboration, says things like “用多个角色一起评审这个 PRD”“多角色协作”“先生成工作流再执行”“让产品经理、架构师、QA 一起看一下”, or wants roles such as product manager, architect, reviewer, or QA to work together. Supports layered execution, role prompting, variable interpolation, document-backed inputs, and parallel steps only when the current environment has a clear subagent mapping. Do not use for ordinary implementation plans, simple code changes, or tasks already covered by `writing-plans`, `executing-plans`, `subagent-driven-development`, or single-purpose review/debug skills.
Also in 4 projects that use this
MicrosoftSkilltesting-anti-patterns
Use when writing or changing tests, adding mocks, or tempted to add test-only methods to production code - prevents testing mock behavior, production pollution with test-only methods, and mocking without understanding dependencies
Also in 3 projects that use this
- +1 more from shibit-net
Other versions139 projects use a version of this.
Word for word · 0
None found.
Edited · 107
- obra/superpowers★ 314k11% same
- openai/plugins★ 7.3k11% same
- microsoft/FluidFramework★ 4.9k13% same
- usewhale/Whale★ 93212% same
- coco-research/coco★ 43731% same
- Ibrahim-3d/orchestrator-supaconductor★ 38031% same
- totvs/engpro-advpl-tlpp-skills★ 13831% same
- CommandCodeAI/agent-skills★ 13132% same
- aaddrick/claude-pipeline★ 12913% same
- Houseofmvps/ultraship★ 12331% same
97 more not listed
Wrote their own version · 32
- jnMetaCode/superpowers-zh★ 8.3ksame name
- GanyuanRan/Aegis★ 1.3ksame name
- KbWen/agentic-os★ 206same name
- thiientv/godmode★ 96same name
- shibit-net/xuanji-community★ 93same name
- andreaswasita/copilot-agents-dojo★ 54same name
- drvoss/everything-copilot-cli★ 47same name
- KbWen/agent-virtual-office★ 35same name
- felvieira/claude-skills-fv★ 23same name
- Wenaixi/dsh-superpower★ 19same name
22 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 repository65 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- documentation-updatesSkill
- spellbook-auditingSkill
- advanced-code-reviewSkill
- adversarial-reviewSkill
- agent2agentSkill
- analyzing-domainsSkill
- analyzing-skill-usageSkill
- assembling-contextSkill
- async-await-patternsSkill
- auditing-green-mirageSkill
- autonomous-modeSkill
- branch-contextSkill
- code-reviewSkill
- creating-issues-and-pull-requestsSkill
- debuggingSkill
- dedupeSkill
- deep-researchSkill
- dehallucinationSkill
- design-explorationSkill
- designing-workflowsSkill
- developSkill
- devils-advocateSkill
- dispatching-parallel-agentsSkill
- distilling-prsSkill
- documenting-projectsSkill
- documenting-toolsSkill
- emotional-stakesSkill
- enforcing-code-qualitySkill
- estimating-ticketsSkill
- executing-plansSkill
- fact-checkingSkill
- finding-dead-codeSkill
- finishing-a-development-branchSkill
- fixing-testsSkill
- fractal-thinkingSkill
- gathering-requirementsSkill
- generating-diagramsSkill
- instruction-engineeringSkill
- isolated-testingSkill
- managing-artifactsSkill
- merging-worktreesSkill
- opportunity-awarenessSkill
- optimizing-instructionsSkill
- polish-repoSkill
- reflexionSkill
- requesting-code-reviewSkill
- resolving-merge-conflictsSkill
- reviewing-design-docsSkill
- reviewing-impl-plansSkill
- reviewing-prsSkill
- rounding-up-worktree-sessionsSkill
- sharpening-promptsSkill
- smart-readingSkill
- test-driven-developmentSkill
- testing-strategySkill
- tooling-discoverySkill
- using-lsp-toolsSkill
- using-skillsSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. 1 is common, 11 are distinctive, and 2 are very specific to this project.
1
Common
Most of the 132 edited versions we read keep these.
11
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 52
When multiple repos share a branch name or belong to the same feature, they nest under the same workspace directory.
- Distinctive: line 70
Follow this priority order:
- Distinctive: line 77
If override found: Use it without asking.
- Very specific: line 85
If found: Use ~/Development/worktrees/{workspace-name}/{project}.
- Very specific: line 93
Default: ~/Development/worktrees/{branch-slug}/{project}.
- Distinctive: line 118
If NOT ignored: add to .gitignore + commit immediately.
- Distinctive: line 122
Add appropriate line to .gitignore
- Common: line 169
Run tests to ensure worktree starts clean:
- Distinctive: line 179
Do tests pass in new worktree?
- Distinctive: line 180
IF NO to any: Report failure, do NOT proceed with implementation.
- Distinctive: line 197
Check context for autonomous mode indicators:
- Distinctive: line 201
When autonomous mode is active:
- Distinctive: line 213
All tests failing (baseline completely broken)
- Distinctive: line 266
Before reporting worktree ready -- if ANY unchecked, STOP and resolve:
“Common” is measured: kept by at least 6 in 10 of the 132 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
<ROLE>
Build Engineer specializing in workspace isolation. Your reputation depends on clean, reproducible development environments that never corrupt the main workspace. Improper worktree setup causes repository corruption and lost work. This is very important.
</ROLE>Announce: "Using git-worktrees skill for isolated workspace."
Invariant Principles
- Directory precedence: CLAUDE.md/AGENTS.md override > existing ~/Development/worktrees/ > default (never assume)
- Safety gate: Project-local worktrees MUST be gitignored before creation
- Clean baseline: Tests must pass before implementation begins (interactive default; autonomous mode applies graduated policy -- see Autonomous Mode)
- Auto-detect over hardcode: Infer setup from manifest files
Inputs
| Input | Required | Description |
feature_name | Yes | Name for the worktree branch (e.g., "add-dark-mode") |
base_branch | No | Branch to base worktree on (defaults to current HEAD) |
worktree_preference | No | Explicit path preference from CLAUDE.md or user |
Outputs
| Output | Type | Description |
worktree_path | Path | Absolute path to created worktree directory |
branch_name | String | Name of the created branch |
baseline_status | Report | Test results confirming clean starting state |
Workspace Structure
Worktrees are organized by workspace (branch or feature name), not by project:
~/Development/worktrees/
{workspace-name}/
{repo-a}/ <- git worktree
{repo-b}/ <- git worktreeWhen multiple repos share a branch name or belong to the same feature, they nest under the same workspace directory. This makes it easy to find all repos related to a single effort.
Examples:
~/Development/worktrees/mcp-events/fastmcp/ # shared branch across repos
~/Development/worktrees/mcp-events/python-sdk/
~/Development/worktrees/mcp-events/typescript-sdk/
~/Development/worktrees/fix-auth-flow/myproject/ # single-repo featureProject CLAUDE.md or AGENTS.md may specify a different naming convention for the
workspace name (e.g., ODY-2863-card-reader-eligibility for ticket-grouped tools).
The nesting structure remains the same: {workspace}/{repo}/.
Directory Selection Process
Follow this priority order:
1. Check CLAUDE.md / AGENTS.md for Project Override
Some projects override the default worktree location (e.g., ticket-grouped workspace tools). Check for explicit worktree path instructions.
If override found: Use it without asking.
2. Check Existing Global Directory
ls -d ~/Development/worktrees/ 2>/dev/nullIf found: Use ~/Development/worktrees/{workspace-name}/{project}.
3. Default to Global Location
mkdir -p ~/Development/worktrees/Default: ~/Development/worktrees/{branch-slug}/{project}. No gitignore needed (outside project).
Safety Verification
The default location (~/Development/worktrees/) is outside the project, so no gitignore
verification is needed. If a project override directs worktrees to a
project-local path, the following gate applies:
<CRITICAL>
Worktree contents committed to the repository causes permanent pollution. This gate is non-negotiable: verify gitignore status before creating any project-local worktree.
</CRITICAL>For Project-Local Directories (only when override specifies one)
MUST verify directory is ignored before creating worktree:
git check-ignore -q "$WORKTREE_DIR" 2>/dev/null<analysis>
Before creating worktree:
- Does target directory already exist?
- Is directory preference established (override > default)?
- Is project-local path gitignored?
If NOT ignored: add to .gitignore + commit immediately. Worktree contents must never be tracked.
</analysis>If NOT ignored:
- Add appropriate line to .gitignore
- Commit the change
- Proceed with worktree creation
For Global Directory (~/Development/worktrees/ -- the default)
No .gitignore verification needed -- outside project entirely.
Creation Steps
1. Detect Project Name
project=$(basename "$(git rev-parse --show-toplevel)")2. Create Worktree
# Default path (override may change this)
path="$HOME/Development/worktrees/$BRANCH_NAME/$project"
mkdir -p "$(dirname "$path")"
# Check if branch/worktree already exists
git worktree list | grep -q "$BRANCH_NAME" && echo "ERROR: Worktree exists"
# Create worktree with new branch
git worktree add "$path" -b "$BRANCH_NAME"
cd "$path"3. Run Project Setup
Auto-detect and run appropriate setup:
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 || uv sync; fi
if [ -f go.mod ]; then go mod download; fiIf setup fails: Report specific failure. Ask whether to proceed or troubleshoot.
4. Verify Clean Baseline
Run tests to ensure worktree starts clean:
# Use project-appropriate command: npm test / cargo test / pytest / go test ./...<reflection>
After worktree creation:
- Did `git worktree add` succeed?
- Are dependencies installed?
- Do tests pass in new worktree?
IF NO to any: Report failure, do NOT proceed with implementation.
</reflection>If tests fail: Report failures, ask whether to proceed or investigate.
If tests pass: Report ready.
5. Report Location
Worktree ready at <full-path>
Tests passing (<N> tests, 0 failures)
Ready to implement <feature-name>Autonomous Mode Behavior
Check context for autonomous mode indicators:
- "Mode: AUTONOMOUS" or "autonomous mode"
worktreepreference specified (e.g., "single", "per_parallel_track", "none")
When autonomous mode is active:
Skip These Interactions
- "Where should I create worktrees?" -- use
~/Development/worktrees/{branch}/{project}or CLAUDE.md override - "Tests fail during baseline -- ask whether to proceed" -- proceed if minor, pause if critical
Make These Decisions Autonomously
- Directory location: Use
~/Development/worktrees/{branch}/{project}as default if no CLAUDE.md override - Gitignore fix: Always fix automatically (add to .gitignore + commit)
- Minor test failures: Log and proceed; major failures pause
Circuit Breakers (Always Pause For)
- All tests failing (baseline completely broken)
- Git worktree command fails (structural git issue)
- .gitignore cannot be modified (permissions or other issue)
Quick Reference
| Situation | Action |
| CLAUDE.md/AGENTS.md override | Use specified path |
| No override | Use ~/Development/worktrees/{branch-slug}/{project} |
| Override points to project-local path | Verify gitignored first |
| Directory not ignored | Add to .gitignore + commit |
| Tests fail during baseline | Report failures + ask |
| Worktree already exists | Report error, ask for new name |
| Setup command fails | Report failure, ask how to proceed |
| No package.json/Cargo.toml | Skip dependency install |
Common Mistakes
| Mistake | Problem | Fix |
| Skip ignore verification | Worktree contents get tracked, pollute git status | Always git check-ignore before creating project-local worktree |
| Assume directory location | Creates inconsistency, violates project conventions | Follow priority: override > default |
| Proceed with failing tests | Can't distinguish new bugs from pre-existing issues | Report failures, get explicit permission to proceed |
| Hardcode setup commands | Breaks on projects using different tools | Auto-detect from manifest files |
| Put worktrees under project name | Multi-repo features get scattered | Group by workspace (branch/feature), nest repos inside |
Example Workflow
[Check CLAUDE.md -- no override]
[Default to ~/Development/worktrees/feature-auth/myproject]
[Create worktree: git worktree add ~/Development/worktrees/feature-auth/myproject -b feature/auth]
[Run npm install]
[Run npm test -- 47 passing]
Worktree ready at ~/Development/worktrees/feature-auth/myproject
Tests passing (47 tests, 0 failures)
Ready to implement auth feature<FORBIDDEN>
- Creating worktrees in unignored project-local directories
- Proceeding with implementation when baseline tests fail
- Assuming worktree location without checking precedence
- Modifying files in main workspace while in worktree context
- Leaving orphaned worktrees after feature completion
- Skipping safety verification for speed
</FORBIDDEN><CRITICAL>
## Self-CheckBefore reporting worktree ready -- if ANY unchecked, STOP and resolve:
- Directory location follows precedence (override > default)
- Project-local path verified gitignored (or global path used)
git worktree addcompleted successfully- Dependencies installed for project type
- Baseline tests pass in new worktree
</CRITICAL>
Integration
Called by:
- design-exploration (Phase 4) -- REQUIRED when design is approved and implementation follows
- Any skill needing isolated workspace
Pairs with:
- finishing-a-development-branch -- REQUIRED for cleanup after work complete
- executing-plans -- Work happens in this worktree (supports both batch and subagent modes)
<FINAL_EMPHASIS> Worktree isolation protects the main workspace from experimental damage. Skipping safety verification causes repository pollution requiring manual cleanup. Proceeding without baseline tests makes it impossible to distinguish new bugs from pre-existing failures. Take the time to do it right. </FINAL_EMPHASIS>
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.

