swe-worktree
Skill2 starsChanged 6 months agoMITView on GitHub
Create an isolated git worktree for an SWE change workspace. Use before implementation when the user wants the change isolated from the current working tree.
In this repository10 other files it gives its agents.
- gitSkill
- handoff-sessionSkill
- html-artifactsSkill
- prompt-writerSkill
- swe-executeSkill
- swe-planSkill
- swe-researchSkill
- swe-reviewSkill
- swe-shapeSkill
- swe-specSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 11 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
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 20
Create a safe isolated branch and git worktree, copy the complete SWE change workspace into it, and report where implementation should …
- Distinctive: line 33
Use the change directory named by the user.
- Distinctive: line 39
Inspect repository state: Read repository git guidance and inspect git status --short, current branch, existing branches, and worktrees.
- Distinctive: line 40
Resolve names: Follow repository branch and worktree conventions.
- Distinctive: line 41
Handle conflicts: If the branch or path already exists, report the exact conflict and ask whether to reuse it or choose another name.
- Distinctive: line 42
Create the worktree: Run:
- Distinctive: line 48
If creation fails, stop and report the command error before retrying.
- Distinctive: line 56
Ask first before reusing, overwriting, force-creating, or deleting an existing branch or worktree, and before changing anything in the …
- Distinctive: line 58
Never install dependencies, run migrations, commit, push, deploy, open a pull request, or begin implementation.
- Very specific: line 62
Do not require plan.md when the spec is intentionally one slice.
- Distinctive: line 63
Do not copy, branch, or duplicate the shared research corpus.
- Distinctive: line 64
Stop immediately when worktree creation or artifact copying fails.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Pipeline
swe-shape → swe-spec → [swe-plan] → [swe-worktree] → swe-execute → swe-review, with swe-research available at any point.
Each stage runs in its own session: the user invokes one skill, reviews the result, clears the context, then invokes the next. Assume no memory of other stages beyond the files named below.
- This stage: optional infrastructure. Isolate the change before implementation.
- Reads: the change directory produced by earlier stages —
brief.md,spec.html, andplan.mdwhen present. Their contents are not needed; only their location. - Writes: a git branch and worktree, with the change directory copied into it.
- Next: the user runs
swe-executeinside the new worktree. Do not invoke it.
Purpose
Create a safe isolated branch and git worktree, copy the complete SWE change workspace into it, and report where implementation should continue. Worktrees are optional execution infrastructure, not a required specification stage.
Inputs
Infer from user input or an artifact path:
CHANGE_DIR:.swe/<change>/SLUG: kebab-case change labelREPO_NAME: repository root basenameBRANCH_NAME: repository convention, otherwise<slug>WORKTREE_PARENT: repository convention, otherwise../worktrees/<repo-name>/WORKTREE_PATH:<worktree-parent>/<slug>
Use the change directory named by the user. If it is ambiguous, ask which one to prepare.
The shared research corpus at .swe/research/ is not change scope. It is repository documentation that outlives any branch, so it is not copied and not branched: research produced during implementation is written to the corpus in the main working tree and committed independently. Copying it would fork the corpus per branch and guarantee divergence.
Workflow
- Inspect repository state. Read repository git guidance and inspect
git status --short, current branch, existing branches, and worktrees. Preserve unrelated changes. - Resolve names. Follow repository branch and worktree conventions. Fall back to the defaults above only when guidance is absent.
- Handle conflicts. If the branch or path already exists, report the exact conflict and ask whether to reuse it or choose another name.
Create the worktree. Run:
git worktree add -b "$BRANCH_NAME" "$WORKTREE_PATH"If creation fails, stop and report the command error before retrying.
- Copy artifacts. Copy the complete
CHANGE_DIRto the same repository-relative location inside the worktree —brief.md,spec.htmland any splitspec-<area>.htmlfiles,mockups/,plan.mdwhen present, andstate.md. Do not copy.swe/research/. - Verify readiness. Confirm the new path, branch, copied artifact paths, and clean worktree status.
Autonomy
Inspect git state, and create the branch, worktree, and artifact copies described in Inputs and Workflow without asking.
Ask first before reusing, overwriting, force-creating, or deleting an existing branch or worktree, and before changing anything in the original working tree.
Never install dependencies, run migrations, commit, push, deploy, open a pull request, or begin implementation.
Constraints
- Do not require
plan.mdwhen the spec is intentionally one slice. - Do not copy, branch, or duplicate the shared research corpus.
- Stop immediately when worktree creation or artifact copying fails.
Output
## Worktree ready
- **Path:** `<absolute worktree path>`
- **Branch:** `<branch>`
- **Artifacts:** `<worktree>/.swe/<change>/`
- **Execution source:** `plan.md` | `spec.html` as one slice
- **Next:** Run `swe-execute` in the new worktree.Completion Criteria
- The worktree and branch exist without overwriting user state.
- Selected artifacts are present at the expected relative path.
- The original working tree has no changes caused by this skill beyond artifact copying requested by the user.
- The final response gives the exact absolute path and branch.
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.

