using-git-worktrees
Skill1 starsChanged 4 months agoMITView on GitHub
Creates an isolated git worktree for a task and checkpoints work there. Use when a repository is about to be edited for the first time in a task, when work needs an isolated checkout and its own resources, or at a local task checkpoint. Reuse a linked worktree only when this task or the harness owns it; there, skip creating a workspace but keep checkpoint discipline. Skip read-only work.
139 other projects use a version of this.
Adopted by
Most recently taken up by
- JorgeMenaDev/skillstheir own version, first seen Oct 4, 2026
- LayneChai/superpowers-dshtheir own version, first seen Oct 3, 2026
- HanksChen0110/skillstheir own version, first seen Oct 3, 2026
- JameMy0001/antigravity-skills-hubtheir own version, first seen Oct 2, 2026
- lsy041015/orchestratheir own version, 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 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.
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 · 0
None found.
Wrote their own version · 139
- obra/superpowers★ 314ksame name
- jnMetaCode/superpowers-zh★ 8.3ksame name
- openai/plugins★ 7.3ksame name
- microsoft/FluidFramework★ 4.9ksame name
- GanyuanRan/Aegis★ 1.3ksame name
- usewhale/Whale★ 932same name
- coco-research/coco★ 437same name
- Ibrahim-3d/orchestrator-supaconductor★ 380same name
- KbWen/agentic-os★ 206same name
- totvs/engpro-advpl-tlpp-skills★ 138same name
129 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 repository40 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- writing-specsSkill
- clarifying-intentSkill
- dispatching-parallel-agentsSkill
- handoffSkill
- mapping-the-codebaseSkill
- prototypingSkill
- using-sdlc-skillsSkill
- viewing-artifactsSkill
- writing-skillsSkill
- yagniSkill
- finishing-a-branchSkill
- release-readinessSkill
- architecture-decisionsSkill
- coding-standardsSkill
- data-modelSkill
- migration-strategySkill
- reviewing-plansSkill
- system-architectureSkill
- ui-ux-designSkill
- writing-plansSkill
- executing-plansSkill
- subagent-driven-developmentSkill
- test-driven-developmentSkill
- complexity-auditSkill
- containing-an-incidentSkill
- debuggingSkill
- diagnosing-a-sessionSkill
- post-mortemSkill
- refactor-architectureSkill
- define-goalsSkill
- feasibility-checkSkill
- scopingSkill
- receiving-code-reviewSkill
- requesting-code-reviewSkill
- security-auditsSkill
- verification-before-completionSkill
- verification-strategySkill
- visual-ui-verificationSkill
The file
We split this skill into the rules it gives an agent
11 rules. 0 are common, 7 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 132 edited versions we read keep these.
7
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 7
NEVER START REPO EDITS IN A SHARED CHECKOUT — one where Step 1 reports git-dir equal to common-dir — WHATEVER BRANCH IT IS ON.
- Distinctive: line 19
Skip creation: when the user explicitly says to stay, or Step 1 confirms a linked worktree owned by this task or the harness.
- Distinctive: line 39
Read the submodule line first: inside a submodule the two directories match without a linked worktree.
- Distinctive: line 43
Write every resource and dirty change into the inventory, by who created it.
- Very specific: line 58
Read references/baseline-contract.md before any install or baseline command.
- Distinctive: line 101
Create from the proven base and enter:
- Distinctive: line 116
Run project setup inside the worktree by the project's own instructions.
- Very specific: line 117
Run the real baseline under references/baseline-contract.md after setup.
- Distinctive: line 134
COMMIT LOCALLY AS YOU GO — after each independently testable piece, not once at the end — when the user or project policy authorizes local …
- Distinctive: line 141
After each coherent piece a reviewer could accept or reject separately:
- Very specific: line 160
Read references/checkpointing.md when the task will make more than one commit: the unit, and what git commit does not grant.
“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
<EXTREMELY-IMPORTANT>
NEVER START REPO EDITS IN A SHARED CHECKOUT — one where Step 1 reports
`git-dir` equal to `common-dir` — WHATEVER BRANCH IT IS ON. Create or enter a
dedicated workspace — a git worktree unless the user or project says otherwise —
*before* the first edit, unless the user explicitly okayed the current checkout.
Writing anything under `.sdlc-skills/` is not a repo edit here; product code,
tests, and project gates are.
</EXTREMELY-IMPORTANT>Using Git Worktrees
When to use
- Skip creation when the user explicitly says to stay, or Step 1 confirms a linked worktree owned by this task or the harness. Reuse its current workspace and baseline record; retain Step 5 checkpoints. Skip read-only work.
Step 1: Detect what you are in
Open assets/workspace-record.md before the first command. Fill each section as its step runs.
Run this:
git rev-parse --show-toplevel git status --short --branch git rev-parse --show-superproject-working-tree # non-empty: you are in a submodule git_dir="$(cd "$(git rev-parse --git-dir)" && pwd -P)" common_dir="$(cd "$(git rev-parse --git-common-dir)" && pwd -P)" [ "$git_dir" != "$common_dir" ] && echo "already inside a linked worktree" git worktree list- Read the submodule line first: inside a submodule the two directories match without a linked worktree.
- Detached or host-owned checkout with unknown owner → do not nest, attach, switch, or clean it.
- Write every resource and dirty change into the inventory, by who created it. Never stash dirty state you do not own.
- Planned in another workspace → rerun 1 before the first product edit.
Step 2: Prove the base
Take the base from direct user or project guidance. None → the current branch this task started from. Detached HEAD or conflicting guidance → ask and stop. Record its revision and remote freshness:
git fetch origin "$BASE" # only with network authority; otherwise record "not fetched" git rev-parse "$BASE" "origin/$BASE"- Read
references/baseline-contract.mdbefore any install or baseline command.
Step 3: Create the workspace
Name it by project convention, or
feature/{{short-task}},fix/{{short-task}},docs/{{short-task}}. Check collisions:git check-ref-format --branch "$BRANCH" git show-ref --verify --quiet "refs/heads/$BRANCH" && echo "local branch exists" git show-ref --verify --quiet "refs/remotes/origin/$BRANCH" && echo "remote branch exists"Anything prints → pick another name. Never overwrite or reuse.
- Pick the mechanism, first that applies: user instruction → project guidance → a harness-native worktree command (with the name above, HEAD at the proven base; skip to Step 4) → the steps below.
Inside a submodule → stop here. Create an owned branch in the submodule and write an explicit plan for the parent gitlink; never run the rest of Step 3 from the superproject's paths. Otherwise choose the directory and prove it is ignored; a user-given path wins. A common git directory that is not a checkout's
.git— bare repository, separate git directory — has no main checkout: ask where the worktree goes and stop.[ -z "$(git rev-parse --show-superproject-working-tree)" ] || echo "SUBMODULE: stop" root="${common_dir%/.git}" [ "$root" != "$common_dir" ] && git -C "$root" rev-parse --is-inside-work-tree >/dev/null 2>&1 || echo "NO MAIN CHECKOUT: ask where the worktree goes" cd "$root" dir=".worktrees" git check-ignore -q "$dir/" || echo "$dir/ is not ignored"That line printed → exclude it locally; that is the whole change. Never add
{{dir}}/to.gitignorein any checkout: local commit authority covers task checkpoints, not a project change nobody requested.printf '%s/\n' "$dir" >> "$common_dir/info/exclude"Create from the proven base and enter:
path="$root/$dir/${BRANCH//\//-}" git worktree add "$path" -b "$BRANCH" --no-track "$BASE" cd "$path" && git status --short --branch # expect: ## $BRANCH, cleanworktree addorcdfails on a sandbox or permission boundary → try a path the boundary allows, confirmed with the user. None works → report and stop; never edit the shared checkout instead.
Step 4: Baseline it
- Claim distinct runtime identities (ports, databases, fixtures).
- Run project setup inside the worktree by the project's own instructions.
- Run the real baseline under
references/baseline-contract.mdafter setup. Red cell you cannot attribute, or an effect you did not contain → stop work. - Hand the completed record to whatever invoked this skill.
Pressure points
| The thought | The reality |
| "I'll just inspect first" | For edit requests, branch/status is the first inspection. |
| "It's only a small change" | Small changes still land on the wrong branch. Create the branch first. |
| "The harness made a detached checkout, so I'll add my own worktree" | First determine whether the host already owns isolation and cleanup. |
| "I'll make the branch after the first edit" | After the edit, you may already have mixed unrelated state. |
| "It looks like a plain checkout" | Looking is not detecting. git-dir against common-dir, plus the superproject check, is the inspection. |
Step 5: Checkpoint while you work
<EXTREMELY-IMPORTANT>
COMMIT LOCALLY AS YOU GO — after each independently testable piece, not once at
the end — when the user or project policy authorizes local commits. None
recorded → ask once for this task and record the answer; after a yes, never ask
per checkpoint. A checkpoint never grants push, publication, or integration
authority.
</EXTREMELY-IMPORTANT>- After each coherent piece a reviewer could accept or reject separately:
REQUIRED SUB-SKILL: invoke
verification-before-completion, run its smallest real gate, and commit locally under the recorded authority. - Candidate ready for integration → REQUIRED SUB-SKILL: invoke
finishing-a-branchwith the recorded workspace, base, and ownership. Run no push, publish, integrate, discard, delete, history rewrite, or cleanup from this skill.
| The thought | The reality |
| "I'll commit once it all works" | One terminal commit cannot be reviewed or reverted in pieces, and every good intermediate state is gone. |
| "Nothing is finished, so there is nothing to commit" | The unit is an independently testable change, not a finished feature. If a gate can accept it, it can be a checkpoint. |
| "I should ask before each commit" | Ask once per task when no policy covers local commits; the recorded answer covers every later checkpoint. Asking again re-decides what the user decided. |
| "The gate is slow — I'll run it once at the end" | Then a red gate at the end leaves every change a suspect. The smallest gate per checkpoint is what keeps that cheap. |
| "It passes locally, so committing can wait" | An uncommitted passing state is one crash, wrong checkout, or overwrite away from not existing. |
| "A mid-task commit looks unfinished" | It claims nothing. Nothing reads a checkpoint as done until finishing-a-branch runs. |
Gotchas
- Read
references/checkpointing.mdwhen the task will make more than one commit: the unit, and whatgit commitdoes not grant. - A gate written during planning lands on whatever branch the shared checkout is on.
- A branch a harness-native command cuts from a remote ref can still track it;
git status --short --branchprinting...origin/{{base}}on the new branch is the tell. Unset the upstream before the first checkpoint.
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.

