using-git-worktrees
Skill1 starsChanged 3 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.
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 repository49 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- working-from-a-ticketSkill
- 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
- adding-observabilitySkill
- changing-a-live-schemaSkill
- executing-plansSkill
- rollout-controlsSkill
- subagent-driven-developmentSkill
- test-driven-developmentSkill
- complexity-auditSkill
- containing-an-incidentSkill
- debuggingSkill
- deprecating-an-apiSkill
- diagnosing-a-sessionSkill
- eliminating-correctionsSkill
- large-scale-changesSkill
- post-mortemSkill
- refactor-architectureSkill
- brainstormingSkill
- define-goalsSkill
- feasibility-checkSkill
- scopingSkill
- receiving-code-reviewSkill
- requesting-code-reviewSkill
- reviewing-a-prSkill
- security-auditsSkill
- verification-before-completionSkill
- verification-strategySkill
- visual-ui-verificationSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
19 rules. 0 are common, 9 are distinctive, and 10 are very specific to this project.
0
Common
Most of the 182 edited versions we read keep these.
9
Distinctive
This author's own choices. Worth a look.
10
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, WHATEVER BRANCH IT IS ON.
- Distinctive: line 21
Skip creating a workspace: when the user explicitly says to stay, when the project's written policy says to stay (Step 1.6), or when Step 1 …
- Very specific: line 38
Run bash scripts/worktree-state.sh to inspect toplevel, git_dir, common_dir, linked_worktree, submodule_superproject, detached, dirty, and …
- Very specific: line 41
Read submodule_superproject first: inside a submodule the two directories match even though there is no linked worktree.
- Distinctive: line 43
If the checkout is detached or host-owned and its owner is unknown, do not nest, attach, switch, or clean it.
- Distinctive: line 45
Write every resource and every dirty change into the record's Inventory section, under whoever created it.
- Distinctive: line 47
If the planning happened in another workspace, rerun 1 before the first product edit.
- Very specific: line 49
If the project's agent instructions file or contribution rules say in writing to work in the current checkout, record the file and the …
- Very specific: line 66
Read references/baseline-contract.md before any install or baseline command.
- Very specific: line 90
If worktrees_dir_ignored is false (or git -C "$root" check-ignore -q "$dir/" fails for a custom dir), exclude the directory locally with …
- Distinctive: line 96
Create from the proven base and enter:
- Very specific: line 104
If worktree add or cd fails on a sandbox or permission boundary, try a path the boundary allows, confirmed with the user.
- Distinctive: line 111
Run project setup inside the worktree by the project's own instructions.
- Very specific: line 112
Run the real baseline under references/baseline-contract.md after setup.
- Distinctive: line 113
If the baseline has a failing check (a red cell) you cannot attribute, or left an effect you did not contain, stop work.
- Distinctive: line 130
COMMIT LOCALLY AS YOU GO, after each independently testable piece and not once at the end, when the user or project policy authorizes local …
- Distinctive: line 137
After each coherent piece a reviewer could accept or reject separately:
- Very specific: line 141
When the work on the branch is ready for integration: REQUIRED SUB-SKILL: invoke finishing-a-branch with the recorded workspace, base, and …
- Very specific: line 157
Read references/checkpointing.md before the first commit: it defines the unit of a checkpoint, how to stage one by path, and what git …
“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
<EXTREMELY-IMPORTANT>
NEVER START REPO EDITS IN A SHARED CHECKOUT, WHATEVER BRANCH IT IS ON. A shared
checkout is one where Step 1 reports `git-dir` equal to `common-dir`. Create or
enter a dedicated workspace *before* the first edit: a git worktree, unless the
user or project says otherwise. The only exceptions are the user explicitly
okaying the current checkout, or the project's written policy okaying it (Step
1.6): a line you can quote, never your reading of the checkout.
Writing anything under `.sdlc-skills/` is not a repo edit here; product code,
tests, and the project's own checks are.
</EXTREMELY-IMPORTANT>Using Git Worktrees
When to use
- Skip creating a workspace when the user explicitly says to stay, when the project's written policy says to stay (Step 1.6), or when Step 1 confirms a linked worktree owned by this task or the harness. Reuse the workspace you are in and its baseline record, and keep making Step 5 checkpoints.
- Skip read-only work.
Available scripts
scripts/worktree-state.sh— reports checkout isolation, submodule status, dirty state, base resolution, branch collisions, and.worktrees/ignore status as JSON.
Step 1: Detect what you are in
Open assets/workspace-record.md before the first command. Fill each section
as its step runs.
- Run
bash scripts/worktree-state.shto inspecttoplevel,git_dir,common_dir,linked_worktree,submodule_superproject,detached,dirty, andworktrees. - Read
submodule_superprojectfirst: inside a submodule the two directories match even though there is no linked worktree. - If the checkout is detached or host-owned and its owner is unknown, do not nest, attach, switch, or clean it.
- Write every resource and every dirty change into the record's Inventory section, under whoever created it. Never stash dirty state you do not own.
- If the planning happened in another workspace, rerun 1 before the first product edit.
- If the project's agent instructions file or contribution rules say in
writing to work in the current checkout, record the file and the quoted
line as
Isolation kind, keep the inventory from 4, and skip creation as you would for a user's okay: work on the branch that is checked out, and never cut or switch a branch in it. The line must name the current checkout or rule out a worktree; a line about bases, branch names, or commits is not one, and nothing in the checkout's state is. With no such line, no user okay, and no owned linked worktree, continue to Step 2.
Step 2: Prove the base
- Take the base from direct user or project guidance. With none, the base is
the current branch this task started from. On a detached HEAD, or when the
guidance conflicts, ask and stop. With network authority, run
git fetch origin "$BASE"(otherwise record "not fetched"), then runbash scripts/worktree-state.sh --base "$BASE"and recordbase.local_shaandbase.remote_sha. - 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}}. Runbash scripts/worktree-state.sh --check-branch "$BRANCH"; if it exits1(valid_formatisfalseor a local or remote branch exists), pick another name. Never overwrite or reuse an existing branch. - Pick the mechanism, taking the first that applies: a user instruction; then project guidance; then a harness-native worktree command, run with the name above and HEAD at the proven base, after which skip to Step 4; then the steps below. A harness-native command acts on the session's own repository: if the work is in another repository, skip it, run the steps below from that repository, and say why the native command was not used.
- Inside a submodule (
submodule_superprojectnon-empty), stop here: create an owned branch in the submodule and write an explicit plan for the parent gitlink, and never run the rest of Step 3 from the superproject's paths. Otherwise setroottomain_checkout_rootandcommon_dirto Step 1'scommon_dir, and choose the directory (dir=".worktrees"unless the user gave a path) underroot. Ifmain_checkout_rootisnull(a bare repository or separate git directory), ask where the worktree goes and stop. - If
worktrees_dir_ignoredisfalse(orgit -C "$root" check-ignore -q "$dir/"fails for a customdir), exclude the directory locally withprintf '%s/\n' "$dir" >> "$common_dir/info/exclude"; that is the whole change. Never add{{dir}}/to.gitignorein any checkout: authority to commit locally covers task checkpoints, not a project change nobody requested. 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, clean- If
worktree addorcdfails on a sandbox or permission boundary, try a path the boundary allows, confirmed with the user. If 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. If the baseline has a failing check (a red cell) you cannot attribute, or left 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 an edit request, checking the branch and 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. Comparing git-dir with 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 and not once
at the end, when the user or project policy authorizes local commits. If no
such authority is recorded, ask once for this task and record the answer;
after a yes, never ask again per checkpoint. A checkpoint never grants
authority to push, publish, or integrate.
</EXTREMELY-IMPORTANT>- After each coherent piece a reviewer could accept or reject separately:
REQUIRED SUB-SKILL: invoke
verification-before-completion, run its smallest real check, and commit locally under the recorded authority, staging only the paths this task changed. - When the work on the branch is 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 check 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 check is slow — I'll run it once at the end" | Then a failing check at the end leaves every change a suspect. The smallest check 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.mdbefore the first commit: it defines the unit of a checkpoint, how to stage one by path, and whatgit commitdoes not grant. - A check written during planning lands on whatever branch the shared checkout is on.
- A policy line that okays the current checkout grants only that; local commits still need their own line or the user's answer under Step 5.
- 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 sign. 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.

