worktrees
Skill2 starsChanged 9 days agoMITView on GitHub
Choose and enter the git worktree a unit of work lives in, and list, finish, sweep or release worktrees. Use before the first file change or commit in a repo whose AGENTS.md has the `### Worktrees` rule, when a skill says to resolve a worktree, or when the user asks to list worktrees, finish one, clean up merged ones or release a lock.
20 other projects use a version of this.
Adopted by
Most recently taken up by
- domengabrovsek/agent-configtheir own version, first seen Nov 8, 2026
- domengabrovsek/claudetheir own version, first seen Nov 8, 2026
- chewygumxx/agentic-librarytheir own version, first seen Nov 8, 2026
- delorenj/skillstheir own version, first seen Nov 7, 2026
- theyoungastronauts/polaristheir own version, first seen Nov 1, 2026
- snuffish/dotfilestheir own version, first seen Nov 1, 2026
Used with
Projects with it also use resolve-conflicts, debug and 4 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.
ralphkraussSkillresolve-conflicts
Resolve git merge conflicts or re-apply changes from a stale branch onto current main. Use when user says "resolve conflicts", "merge conflicts", "rebase branch", "branch is behind", "re-apply changes", "port branch", or a branch is too far behind main to merge cleanly.
Also in 3 projects that use this
AnthropicSkilldebug
Structured debugging session — reproduce, isolate, diagnose, and fix. Trigger with an error message or stack trace, "this works in staging but not prod", "something broke after the deploy", or when behavior diverges from expected and the cause isn't obvious.
Also in 4 projects that use this
BlockSkillplan
Draft a TDD, PRD, or lightweight plan in the conversation without committing it.
Also in 3 projects that use this
AWSSkillship
Finalize dev work on an issue branch — update docs, push, and open a PR.
Also in 3 projects that use this
Microsoft AzureSkillverify
End-to-end app testing pipeline for browser-based web apps on cloud browsers via Azure Playwright Workspaces: verify the live app, author tests for working flows, heal failing tests, then re-run with video and produce one consolidated report. Three phases (app verification, test authoring, test healing) plus a scoped final sanity run; each phase emits a sub-report. Use when asked to "verify my app", "make sure my app works and has good test coverage", "do a full QA pass", "add tests where I'm missing coverage", "fix failing tests and add new ones", "smoke test before deploy", "QA my deployment", or any combined verify-and-test ask. Requires Azure CLI (`az login`) and a Playwright Workspace resource ID — bootstraps configs on first invocation. Browser-based web apps with Playwright only — not for unit/API tests, native mobile/desktop, load/perf, or full accessibility audits.
Also in 3 projects that use this
NVIDIASkillresearch
Before designing a feature, research how comparable libraries solve the problem, check best practices, known pitfalls, and upstream changes. Use when starting a new feature, investigating an unfamiliar area, or the user asks to research something.
Also in 3 projects that use this
Other versions20 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 20
- GetStream/stream-chat-react★ 844same name
- akitaonrails/my-skills★ 283same name
- maragudk/skills★ 49same name
- nilecui/SkillsBase★ 27same name
- domengabrovsek/agent-config★ 22same name
- domengabrovsek/claude★ 22same name
- delorenj/skills★ 17same name
- ariadoss/superskills★ 12same name
- theyoungastronauts/polaris★ 4same name
- divanc/skills★ 3same name
10 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 repository30 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- code-commentsSkill
- dev-stackSkill
- diagnosing-bugsSkill
- domain-modelingSkill
- prose-styleSkill
- prototypeSkill
- prSkill
- review-changesSkill
- setup-pre-commitSkill
- tddSkill
- ui-designSkill
- check-sdlcSkill
- deslopSkill
- grill-with-docsSkill
- handoffSkill
- implementSkill
- implement-specSkill
- improve-codebase-architectureSkill
- refresh-specSkill
- retroSkill
- setup-sdlcSkill
- to-specSkill
- to-ticketsSkill
- triageSkill
- update-designSkill
- codebase-designSkill
- grillingSkill
- run-reportSkill
- writing-for-agentsSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 1 is distinctive, and 3 are very specific to this project.
0
Common
Most of the 20 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 6
Every unit of work lives in its own Worktree under the Main checkout's .claude/worktrees/<slug>/, and the main checkout itself is the …
- Very specific: line 53
Run worktree.sh release <path>.
- Distinctive: line 63
Leave it first if the session is inside it, and release this session's own lock on it.
- Very specific: line 64
Run worktree.sh finish <path>.
“Common” is measured: kept by at least 6 in 10 of the 20 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
Every unit of work lives in its own Worktree under the Main checkout's .claude/worktrees/<slug>/, and the main checkout itself is the user's: read it, never edit or commit there.
scripts/worktree.sh in this skill's folder does the mechanical work: run it with bash from any directory inside the repo, worktree or main checkout. It finds the main checkout from git's common directory, so worktrees are never nested. It prints messages on stderr and refuses with exit 1 and a reason; relay its messages to the user as they are.
Moving the session
If your agent can switch its session into an existing worktree by path, do it with the path create printed. Otherwise work there with absolute paths and git -C <path>, and run every command from that path. Agents that switch sessions between worktrees often allow it only under .claude/worktrees/, which is why the folder is fixed; an agent whose own worktree tool names the branch after the folder needs git -C <path> branch -m <branch> afterwards, so prefer creating with the script and switching by path.
To leave a worktree, switch the session back to the main checkout, keeping the worktree on disk, or into another worktree.
Resolve
The entry point. A writing skill opens with this sentence, and it means this section:
Load the
worktreesskill and resolve the worktree for this work before writing anything.
Given a Spec, a Ticket, an idea or nothing, end with the session in one worktree holding its lock, in this order:
- Already in a fitting worktree. When the session is in a linked worktree (its top level differs from
worktree.sh main) and its branch is the one the work's Feature branch link names, or this session already worked there on the same work, stay. This covers a session the agent started in a worktree (in Claude Code,claude -w) and a grilling session moving on toto-specorimplement. Go to step 4. - A Spec or Ticket. Read its Feature branch link: the line
Branch: <branch>at the top of the body. A Ticket without one follows its parent Spec's link. With a link, runworktree.sh create <branch>: it reuses the branch's worktree, or adds one for a branch that exists locally or onorigin. A Spec with no link (one written before links existed) gets a newfeat/<slug>branch as in step 3, and then you writeBranch: <branch>as the first line of the Spec's body through the issue tracker (docs/agents/issue-tracker.md). A Ticket with no Spec is an idea. - An idea, or nothing. Pick the prefix from the work:
fix/for a bug,feat/for new behaviour,chore/for everything else (docs, config, setup, dependencies, a one-line change asked in passing). Name it in two to four lowercase words joined by hyphens, and keep the name for the life of the branch even when the idea changes shape. Runworktree.sh create <prefix>/<name>: it fetchesoriginand branches offorigin/<default>. - Take the lock. Run
worktree.sh lock <path> "<description>"before writing anything there. The description is one line naming the skill, the work and when the session started (implement #42, started 2026-10-30 14:05); reuse the exact string for every later lock call in this session, since the script treats a matching description as the same session.- Exit 3, busy: another session holds a fresh lock. Stop and tell the user who holds it. When the work is one Ticket of a Spec, add that
implement-specruns a Spec's Tickets in parallel. - Exit 4, stale: the lock was taken over two hours ago, and the worktree has had no file change and no commit for two hours. Ask the user whether to take it over; on yes, run
worktree.sh lock --take-over <path> "<description>". In an unattended run, stop with the holder's name instead of asking.
- Exit 3, busy: another session holds a fresh lock. Stop and tell the user who holds it. When the work is one Ticket of a Spec, add that
- Move the session into the worktree (above).
- Report one line:
Worktree: <path> (<branch>).
create stops in two cases, and both end the resolution with its message: the branch is checked out in the main checkout (never switch the user's checkout to free it), or the branch's Slug is taken by another worktree. For a slug clash on a new branch, pick a different name; for a linked branch, stop.
Slug
The branch's last / segment, lowercased, every character outside [a-z0-9-] turned into -, repeats collapsed, leading and trailing - trimmed, at most 63 characters: feat/Login_Flow.v2 gives login-flow-v2. This is how Portless names the worktree's Dev URL, so the folder and the URL agree. worktree.sh slug <branch> prints it.
Bootstrap
create bootstraps every worktree it adds. It copies the gitignored files the repo's docs/agents/worktrees.md lists from the main checkout and runs its install command; WORKTREES-DOC.md has the format. Without the doc it copies and installs nothing and says so in one line. When the new branch's .gitignore misses the worktrees folder or .sdlc/, it adds them in their own commit, chore: ignore worktrees and session locks. When the install or that commit fails, create stops with the worktree in place, and the next create for the branch runs the bootstrap again.
Create
Resolve without the "stay" step: worktree.sh create <branch> [<base>], then lock, move and report. <base> defaults to origin/<default>; pass another ref only when the caller names one, such as implement-spec basing an Implementer worktree on the previous branch of the Stack.
Release
A writing skill closes with this sentence, and it means this section:
Release this session's worktree lock, as the
worktreesskill's Release section says.
Run worktree.sh release <path>. It deletes the lock and nothing else.
List
Run worktree.sh list and show it as a table. Each tab-separated row is a worktree's Slug, branch, commits ahead of and behind origin/<default>, lock holder (with (stale) when it is), lock age, and Dev stack status from the repo's scripts/dev-stack status (- when the repo has no contract).
Finish
For one worktree the user names, or one this session's work is done in:
- Leave it first if the session is inside it, and release this session's own lock on it.
- Run
worktree.sh finish <path>. It refuses on uncommitted changes (exit 1, listing them), on a lock (exit 3, naming the holder), and on a branch that is neither merged intoorigin/<default>nor pushed (exit 5). Show the user what it listed; a lock held by another session stays. - On exit 5, ask the user whether an open PR covers the branch. Only on a clear yes, run
worktree.sh finish <path> --pr-open.
An Implementer worktree or merger worktree holds a Ticket branch that is pushed and has an open PR, so it finishes with these same rules: pushed counts, and --pr-open covers a branch the script cannot see on origin. worktree.sh finish <path> --merged-into <branch> stays for a branch merged into a branch other than the default: the same refusals, with that branch in place of origin/<default>.
Once it passes, the script runs scripts/dev-stack destroy when the repo has a contract, removes the worktree, deletes the branch with git branch -d and prunes. Neither step forces: a branch git branch -d refuses is kept and reported.
Sweep
Cleanup after PRs merge: run worktree.sh sweep. It fetches origin, finishes every clean, unlocked worktree whose branch is merged into origin/<default>, and prints one line for each worktree it finished or left, with the reason. Relay the lines. A squash-merged branch shows as not merged; offer to finish it if the user says its PR merged.
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.

