using-git-worktrees
Skill15 starsChanged 5 days agoMITView on GitHub
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates an isolated git worktree (via the native opencode v2 worktree tools) and moves the session into it
- Installs packages
We split this skill into the rules it gives an agent
17 rules. 0 are common, 9 are distinctive, and 8 are very specific to this project.
0
Common
Most of the 181 edited versions we read keep these.
9
Distinctive
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 19
Use this when running inside opencode v2 (the normal case).
- Very specific: line 23
Call worktree_create with a name — use the feature/branch name (e.g.
- Very specific: line 30
Do not hand-roll the location with git worktree add — opencode only records and manages worktrees it created itself, so manual ones are …
- Very specific: line 32
If the user wants a non-default location, the v2-idiomatic move is to set worktree.directory in the config (and note it in AGENTS.md or …
- Very specific: line 46
Call session_move with the worktree directory as directory.
- Very specific: line 52
When worktree.directory places worktrees inside the checkout (.worktrees/, worktrees/, …), verify the directory is ignored before creating …
- Very specific: line 58
If not ignored: add it to .gitignore, commit, then create.
- Distinctive: line 81
Run the project's tests to confirm the worktree starts green:
- Distinctive: line 100
Never remove a worktree with unpushed, unmerged commits without explicit confirmation — that deletes the work.
- Distinctive: line 105
Use git worktree add directly only when:
- Distinctive: line 131
Problem: Only the shell's CWD changes.
- Very specific: line 132
Fix: Call session_move; put dependent work in the next turn.
- Distinctive: line 136
Fix: Use the native tools in v2.
- Distinctive: line 145
Commit on the detached HEAD (create the branch first)
- Distinctive: line 146
Remove a worktree with unpushed/unmerged work without confirmation
- Distinctive: line 151
Use native tools in opencode v2, raw git only in the fallback cases
- Distinctive: line 153
Verify gitignore for in-repo locations
“Common” is measured: kept by at least 6 in 10 of the 181 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
Overview
Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching.
Core principle: In opencode v2, worktrees are created with the native worktree_* tools, and the session moves into the worktree — not just the shell. This keeps opencode's tracking (list/remove), project config, and AGENTS.md discovery pointing at the right place.
Announce at start: "I'm using the using-git-worktrees skill to set up an isolated workspace."
Default Path: Native Worktree Tools
Use this when running inside opencode v2 (the normal case). The tools are worktree_create, worktree_list, worktree_remove (Code Mode namespace opencode), plus session_move.
1. Create the worktree
Call worktree_create with a name — use the feature/branch name (e.g. auth, fix-login-timeout). It returns { directory }.
Where the worktree lands is decided by the worktree.directory setting in the project's opencode config, not by the skill:
- Not set (default): opencode's data directory,
worktree/<project-id prefix>/<name>— outside the repo, so nothing to gitignore. - Set (e.g.
"worktree": { "directory": ".worktrees" }): relative paths resolve against the project's canonical checkout. If the directory is inside the repo, it must be gitignored (see below).
Do not hand-roll the location with git worktree add — opencode only records and manages worktrees it created itself, so manual ones are invisible to worktree_list / worktree_remove.
If the user wants a non-default location, the v2-idiomatic move is to set worktree.directory in the config (and note it in AGENTS.md or memory) — not to pick a path per session.
2. Create the branch
worktree_create does not take a branch name: the new worktree is at a detached HEAD on the repo's current commit. Create the branch from inside the worktree:
git checkout -b "<branch-name>"(git checkout main would fail — main is already checked out in the primary worktree; that is expected and not an error.)
3. Move the session into the worktree
Call session_move with the worktree directory as directory. The move takes effect at a safe boundary, so destination-dependent work (reads, edits, setup commands) belongs in the next call.
Why this instead of cd: a shell cd only changes one command's working directory; session_move re-roots the session's Location, so tool calls, config discovery, and instruction files all resolve against the worktree checkout.
4. Project-local location safety (only if inside the repo)
When worktree.directory places worktrees inside the checkout (.worktrees/, worktrees/, …), verify the directory is ignored before creating the worktree:
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/nullIf not ignored: add it to .gitignore, commit, then create. This prevents worktree contents from polluting git status or being accidentally committed.
5. Run project setup
The worktree is a fresh checkout — dependencies are not shared with the main worktree. Auto-detect and run setup:
# Node.js
[ -f package.json ] && npm install
# Rust
[ -f Cargo.toml ] && cargo build
# Python
[ -f requirements.txt ] && pip install -r requirements.txt
[ -f pyproject.toml ] && poetry install
# Go
[ -f go.mod ] && go mod download6. Verify clean baseline and report
Run the project's tests to confirm the worktree starts green:
# project-appropriate: npm test / cargo test / pytest / go test ./...If tests fail: report the failures and ask whether to proceed or investigate. If they pass: report ready.
Worktree ready at <full-path> (branch <name>)
Session moved. Tests passing (<N> tests, 0 failures)
Ready to implement <feature-name>Cleanup
Pairs with finishing-a-development-branch after the work is done:
worktree_removewith the worktreedirectoryremoves a worktree opencode recorded for the project. It uses theeditpermission on that directory; setforce: trueonly to discard uncommitted changes.- Never remove a worktree with unpushed, unmerged commits without explicit confirmation — that deletes the work.
- A worktree created manually with raw git (fallback below) is not recorded by opencode; remove it with
git worktree remove <path>instead.
Fallback: Raw Git
Use git worktree add directly only when:
- Running in a harness without the native tools (Claude Code, Codex, plain terminal).
- The worktree needs a base other than the current HEAD (
git worktree add <path> -b <branch> <base-commit>). - The user explicitly asks for a manual worktree.
The same safety rules apply: gitignore check for project-local paths, setup, baseline tests, and announce the location.
Quick Reference
| Situation | Action |
| In opencode v2 | worktree_create → git checkout -b → session_move → setup → baseline |
| Non-default location wanted | Set worktree.directory in opencode config |
| Location inside repo | git check-ignore first; add to .gitignore + commit if not |
| Needs a base other than HEAD | Fallback: git worktree add <path> -b <branch> <base> |
| Tests fail during baseline | Report failures + ask |
| Work done | finishing-a-development-branch → worktree_remove |
Common Mistakes
Assuming worktree_create makes a branch
- Problem: It leaves a detached HEAD; commits land nowhere a branch points at.
- Fix:
git checkout -b <branch>inside the worktree immediately after creation.
cd-ing into the worktree instead of session_move
- Problem: Only the shell's CWD changes; the session, config, and instruction discovery still point at the old location.
- Fix: Call
session_move; put dependent work in the next turn.
Hand-rolling git worktree add in opencode
- Problem: opencode doesn't record manual worktrees, so
worktree_list/worktree_removecan't see them, and the location ignoresworktree.directory. - Fix: Use the native tools in v2; raw git is the fallback above.
Proceeding with failing baseline tests
- Problem: Can't distinguish new bugs from pre-existing issues.
- Fix: Report failures, get explicit permission to proceed.
Red Flags
Never:
- Commit on the detached HEAD (create the branch first)
- Remove a worktree with unpushed/unmerged work without confirmation
- Skip baseline test verification
- Assume the default location when the user has a project-local preference — check/set
worktree.directory
Always:
- Use native tools in opencode v2, raw git only in the fallback cases
- Move the session with
session_moveafter creation - Verify gitignore for in-repo locations
- Auto-detect and run project setup, then a clean test baseline
Example Workflow
You: I'm using the using-git-worktrees skill to set up an isolated workspace.
[worktree_create name="auth" -> C:\Users\osmon\.local\share\opencode\worktree\c3488b\auth]
[git checkout -b feature/auth]
[session_move directory=<worktree dir>]
[npm install, npm test - 47 passing]
Worktree ready at C:\Users\osmon\.local\share\opencode\worktree\c3488b\auth (branch feature/auth)
Session moved. Tests passing (47 tests, 0 failures)
Ready to implement auth featureIntegration
Called by:
- subagent-driven-development - REQUIRED before executing any tasks
- executing-plans - REQUIRED before executing any tasks
- Any skill needing an isolated workspace
Pairs with:
- finishing-a-development-branch - REQUIRED for cleanup after work complete
Other versions189 projects use a version of this.
Word for word · 0
None found.
Edited · 81
- coco-research/coco★ 79719% same
- Ibrahim-3d/conductor-orchestrator-superpowers★ 38119% same
- Ibrahim-3d/orchestrator-supaconductor★ 37819% same
- totvs/engpro-advpl-tlpp-skills★ 16619% same
- haojing8312/WorkClaw★ 14119% same
- aaddrick/claude-pipeline★ 12811% same
- ARounder-183/HiFiShifter★ 9317% same
- coctostan/pi-superpowers★ 7118% same
- cooker/wxHm★ 7017% same
- myths-labs/muse★ 3716% same
71 more not listed
Wrote their own version · 108
- obra/superpowers★ 305ksame name
- jnMetaCode/superpowers-zh★ 8.4ksame name
- openai/plugins★ 7.4ksame name
- farm-fe/farm★ 5.6ksame name
- microsoft/FluidFramework★ 5ksame name
- silvertakana/worldwideview★ 1.9ksame name
- GanyuanRan/Aegis★ 1.4ksame name
- pcvelz/superpowers★ 1.3ksame name
- usewhale/DeepSeek-Code-Whale★ 933same name
- usewhale/Whale★ 928same name
98 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.
Used alongsideProjects 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.
GEd520Skillchinese-code-review
中文 review 沟通参考——话术模板、分级标注(必须修复/建议修改/仅供参考)、国内团队常见反模式应对。仅在用户显式 /chinese-code-review 时调用,不要根据上下文自动触发。
Also in 7 projects that use this
GEd520Skillchinese-commit-conventions
中文 commit 与 changelog 配置参考——Conventional Commits 中文适配、commitlint/husky/commitizen 中文模板、conventional-changelog 中文配置。仅在用户显式 /chinese-commit-conventions 时调用,不要根据上下文自动触发。
Also in 7 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 12 projects that use this
10CGSkillworkflow-runner
十步循环轻量编排器,协调 Phase Skills 执行,支持灵活组合。
Also in 7 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
- +2 more from GEd520
In this repository33 other files it gives its agents.
- AGENTS.mdAGENTS.md
- applying-themesSkill
- brainstormingSkill
- building-accessible-interfacesSkill
- building-finetuning-datasetsSkill
- building-mcp-serversSkill
- building-web-artifactsSkill
- coauthoring-docsSkill
- creating-algorithmic-artSkill
- creating-skillsSkill
- designing-canvas-artSkill
- designing-frontend-interfacesSkill
- designing-user-experienceSkill
- dispatching-parallel-agentsSkill
- evolving-apis-and-schemasSkill
- executing-plansSkill
- finishing-a-development-branchSkill
- investigating-performanceSkill
- processing-pdfSkill
- receiving-code-reviewSkill
- requesting-code-reviewSkill
- reviewing-interface-qualitySkill
- reviewing-securitySkill
- subagent-driven-developmentSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- testing-skillsSkill
- testing-webappsSkill
- using-superpowersSkill
- verifying-before-completionSkill
- writing-internal-commsSkill
- writing-plansSkill
- writing-release-notesSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

