git-worktree-setup
Skill2 starsChanged 8 days agoMITView on GitHub
Use when implementation should be isolated from the current checkout, a plan calls for a separate branch workspace such as `work-plan` execution isolating parallel workers, or worktree state must be detected before editing. Reuses existing isolation or creates a worktree through the harness or Git. NOT for merely listing worktrees, deleting them, or publishing a finished branch.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- eliasjnior/claude-skillstheir own version, first seen Nov 1, 2026
- dwfennell/claude-skillstheir own version, first seen Oct 13, 2026
- gigio1023/gigio-skillsword for word, first seen Oct 13, 2026
Other versions3 projects use a version of this.
Word for word · 1
- gigio1023/gigio-skills★ 2100% same
Edited · 0
None found.
Wrote their own version · 2
- dwfennell/claude-skills★ 0same name
- eliasjnior/claude-skills★ 0same name
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 repository53 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- 1password-cliSkill
- codex-delegateSkill
- credo-journalSkill
- credo-paper-planSkill
- credo-releaseSkill
- credo-tasteSkill
- cursor-cli-delegationSkill
- english-prompt-reviewSkill
- mermaid-diagramsSkill
- pdf-page-countSkill
- pr-review-commentSkill
- read-agent-sessionsSkill
- reddit-searchSkill
- release-notesSkill
- small-model-handoffSkill
- spot-gpu-evaluationSkill
- toss-portfolio-stateSkill
- vuln-reportSkill
- zcode-cliSkill
- bug-diagnosisSkill
- coding-standardsSkill
- commit-and-pushSkill
- copydeskSkill
- design-docSkill
- design-explorationSkill
- draft-prSkill
- evaluation-analysisSkill
- evaluation-auditSkill
- evaluation-designSkill
- evaluation-operationsSkill
- find-unknownsSkill
- frontend-designSkill
- idea-critiqueSkill
- insight-dashboardSkill
- install-skill-packSkill
- internal-source-researchSkill
- interviewSkill
- literature-researchSkill
- load-testingSkill
- ml-experimentSkill
- model-routingSkill
- orchestrate-subagentsSkill
- praxis-directionSkill
- prompting-guideSkill
- review-panelSkill
- session-handoffSkill
- skill-builderSkill
- terminologySkill
- work-planSkill
- write-issueSkill
- write-notionSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 9 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
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 13
Start implementation in an isolated workspace without taking ownership of a worktree that the user or harness already manages.
- Distinctive: line 17
Read repository instructions and inspect Git state before changing anything.
- Distinctive: line 19
If isolation is not already present, create it when the user has asked for a worktree or the active mission already grants isolation.
- Distinctive: line 21
Run repository-defined setup and the smallest meaningful baseline check.
- Very specific: line 48
Prefer an explicit project-local directory policy, then an existing .worktrees/ or worktrees/ directory.
- Distinctive: line 50
Check git worktree list --porcelain and branch refs before creation.
- Distinctive: line 51
Create a new branch with:
- Distinctive: line 59
If sandbox or filesystem policy blocks creation, report the failed mechanism.
- Distinctive: line 71
Treat a native, detached-HEAD, or otherwise externally created worktree as externally managed.
- Distinctive: line 72
Treat a Git worktree created by this workflow as workflow-owned, but do not remove it unless a later request explicitly authorizes cleanup.
≈ “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
Git Worktree Setup
Start implementation in an isolated workspace without taking ownership of a worktree that the user or harness already manages.
Quick Path
- Read repository instructions and inspect Git state before changing anything.
- Detect whether the current checkout is already a linked worktree, including the submodule exception below. Reuse it when it is.
- If isolation is not already present, create it when the user has asked for a worktree or the active mission already grants isolation. Do not ask again for the same scope; an inspection-only request still does not grant creation.
- Honor an explicit creation mechanism or directory policy. Otherwise create a Git worktree under the repository's
.worktrees/directory. Use native creation when the user asks for harness-managed lifecycle behavior. - Run repository-defined setup and the smallest meaningful baseline check.
- Report the path, branch state, creation mechanism, and validation evidence.
Detect Existing Isolation
Resolve both paths rather than comparing Git's sometimes-relative output:
git_dir=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
git_common=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
superproject=$(git rev-parse --show-superproject-working-tree 2>/dev/null)
branch=$(git branch --show-current)When git_dir differs from git_common and superproject is empty, the current checkout is already a linked worktree. Keep working there; do not create a nested or replacement worktree. An empty branch means detached HEAD, which is valid when the harness owns the workspace and should be reported as such.
A non-empty superproject identifies a submodule, not worktree isolation. Treat that checkout as a normal repository for this decision.
Choose the Creation Mechanism
An explicit user or repository choice between harness-native creation and git worktree wins. Choose native creation when the requested result depends on harness-managed placement, handoff, restoration, or cleanup. Continue setup inside the workspace it returns and treat that workspace as externally managed.
Without an explicit mechanism, use git worktree and keep its directory inside the repository. Git creation does not by itself prevent a named branch from being discovered by ordinary Git and PR tooling. It may not gain harness-only lifecycle controls.
For Git creation:
- Choose a base revision and branch name from the user's request and repository conventions. Do not invent a remote update, rebase, or branch rewrite.
- Prefer an explicit project-local directory policy, then an existing
.worktrees/orworktrees/directory. Otherwise use.worktrees/at the repository root. Keep every generated path beneath that directory. Do not choose a sibling, home-directory, or global location unless the user or repository explicitly names it. - Before using a project-local directory, check the exact path with
git check-ignore. If it is not ignored, add the exact directory to the repository's local Git exclude file. Do not edit.gitignoreor relocate the worktree outside the repository merely to keep it untracked. If local exclusion is unavailable, report the blocker instead of choosing a new location. Never create a commit merely to ignore the worktree directory. - Check
git worktree list --porcelainand branch refs before creation. Reuse an existing matching worktree; never force, delete, or overwrite one. Create a new branch with:
git worktree add <path> -b <branch> <start-point>For an existing branch that is not checked out elsewhere, omit
-b.
If sandbox or filesystem policy blocks creation, report the failed mechanism. Work in place only when the user accepts losing isolation or their instructions already authorize that fallback.
Prepare and Verify
Inside the selected workspace, read project setup instructions and inspect lockfiles or tool configuration before installing dependencies. Use the repository's package manager and documented command; do not infer npm, Poetry, or another tool from a generic manifest alone.
Run the smallest project-appropriate check that establishes a baseline before implementation. Reuse an existing baseline only when its revision, relevant files, and environment match this workspace. Record the exact command and result. If the baseline fails, separate the pre-existing failure from later work and ask for direction only when proceeding would make attribution unsafe or require broader changes.
Authority and Ownership
- Detecting and reporting worktree state is read-only. Creating a branch and worktree requires an explicit request or consent.
- Worktree creation does not authorize commits, pushes, rebases, tracked config edits, dependency upgrades, or cleanup.
- Treat a native, detached-HEAD, or otherwise externally created worktree as externally managed. Do not remove it during this workflow.
- Treat a Git worktree created by this workflow as workflow-owned, but do not remove it unless a later request explicitly authorizes cleanup.
- Preserve unrelated dirty state. If it prevents a safe base selection, report the conflict instead of moving or stashing someone else's changes.
Output
Report:
- absolute workspace path;
- branch name or detached-HEAD state;
- reused, native-created, or Git-created mechanism;
- chosen start point when a workspace was created;
- setup and baseline commands actually run, with results;
- any permission failure, pre-existing test failure, or ownership caveat.
The workspace is ready only when its location and Git state are verified. Test success is reported separately and must not be implied when checks were skipped.
Gotchas
git_dir != git_commonalso occurs in submodules; keep the superproject guard.- PR discovery depends on the branch, remote, and PR provider, not on who created the worktree. Harness-managed cleanup and handoff can still require native creation.
- A branch already checked out in another worktree cannot be checked out again.
- Dependency setup may modify lockfiles or generated files; inspect status after setup and report unexpected changes.
For maintenance fixtures and the upstream adaptation record, read references/evaluation-cases.md and references/source-notes.md.
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.

