worktree-lifecycle
Skill3 starsChanged 3 months agoMITView on GitHub
Manage Git worktrees created or used during a Codex task. Use when an agent proposes an isolated checkout, parallel writers may need filesystem isolation, a task already owns auxiliary worktrees, or the root must integrate, preserve, or remove task-created worktrees before completion.
6 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- rafaelob/pragmatic-agent-skillstheir own version, first seen Nov 1, 2026
- nanosite-ai/nanoflowtheir own version, first seen Oct 9, 2026
- martinappberg/chimaeratheir own version, first seen Sep 28, 2026
- YoniChechik/claude-code-configtheir own version, first seen Sep 18, 2026
- ArcanEdge-AI/coding-agent-playbook-claude-codeedited, first seen Jul 8, 2026
- psw7205/skillstheir own version, first seen May 26, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 1
Wrote their own version · 5
- rafaelob/pragmatic-agent-skills★ 24same name
- nanosite-ai/nanoflow★ 15same name
- martinappberg/chimaera★ 7same name
- psw7205/skills★ 1same name
- YoniChechik/claude-code-config★ 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 repository33 other files it gives its agents.
- AGENTS.mdAGENTS.md
- aws-local-preflightSkill
- design-taste-frontendSkill
- feature-branch-lifecycleSkill
- handoffSkill
- humanizerSkill
- impeccableSkill
- legacy-path-retirementSkill
- local-ci-preflightSkill
- multi-role-repo-reviewSkill
- multi-session-coordinationSkill
- platform-documentationSkill
- production-api-integrationSkill
- production-architecture-reviewSkill
- production-code-qualitySkill
- production-database-integritySkill
- production-devops-releaseSkill
- production-documentation-onboardingSkill
- production-pass-orchestratorSkill
- production-performance-reviewSkill
- production-readiness-reportSkill
- production-reliability-observabilitySkill
- production-security-reviewSkill
- production-testing-qaSkill
- production-ux-accessibilitySkill
- reference-doc-routingSkill
- senior-code-reviewSkill
- session-cleanupSkill
- subagent-orchestrationSkill
- task-graph-orchestrationSkill
- taste-new-websiteSkill
- taste-redesign-websiteSkill
- technical-debt-auditorSkill
The file
We split this skill into the rules it gives an agent
9 rules. 0 are common, 7 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
7
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Keep worktree use finite, root-owned, and task-local.
- Distinctive: line 16
Keep the auxiliary-worktree budget at zero unless a planned writer needs real branch or filesystem isolation that cannot be handled safely …
- Very specific: line 21
Before the final response, inspect every task-created auxiliary worktree and set its disposition to removed or preserved with an exact …
- Distinctive: line 25
Create an auxiliary worktree only when all are true:
- Distinctive: line 39
Remove a task-created auxiliary worktree only after verifying all of these:
- Distinctive: line 44
no running process depends on the checkout
- Very specific: line 48
Use the supported host lifecycle for a host-managed primary workspace.
- Distinctive: line 50
If any gate fails, preserve the worktree and return its canonical path, owner, branch or detached HEAD, exact blocker, and next action.
- Distinctive: line 63
Do not claim cleanup complete until Git registration and path state are verified.
“Common” is measured: kept by at least 6 in 10 of the 6 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
Worktree Lifecycle
Keep worktree use finite, root-owned, and task-local. A subagent is not a reason to create a worktree. The normal default is the current shared workspace with an auxiliary-worktree budget of zero.
Consult references/worktrees.md for the complete decision rules and references/templates/worktree-manifest.md when a durable ledger is justified.
Workflow
- Inspect the current checkout, common Git directory, branch or detached HEAD, registered worktrees, dirty state, and known thread ownership.
- Classify the current checkout as host-managed primary, user-managed existing, or task-created auxiliary.
- Keep the auxiliary-worktree budget at zero unless a planned writer needs real branch or filesystem isolation that cannot be handled safely in the current workspace or by serialization.
- Let only the root raise the finite budget and issue a worktree permit. The root may authorize one active auxiliary without additional approval; two or more require approval for the exact count and reasons. Record the reason and manifest entry before creation.
- Reuse a compatible registered worktree before creating another. Never create one merely because a new subagent or retry exists.
- Assign each participating root or helper its exact workspace and write scope. Helpers must not create, repurpose, move, or remove worktrees; they report a need upward.
- Integrate and validate accepted work through the declared integration target.
- Before the final response, inspect every task-created auxiliary worktree and set its disposition to
removedorpreservedwith an exact blocker. Do not defer task-owned cleanup to a scheduled job.
Creation Gate
Create an auxiliary worktree only when all are true:
- the repository and common Git directory are verified
- the base ref and exact base SHA are recorded
- the path and branch are explicit and do not collide with an existing registration
- the planned write or mutable-state isolation is concrete
- reuse or serial execution is insufficient
- the finite root budget has capacity and a root permit exists
- ownership, integration target, and cleanup condition are recorded
Parallel writes to overlapping files normally serialize. Separate worktrees hide filesystem collisions but do not resolve design or merge conflicts.
Completion Gate
Remove a task-created auxiliary worktree only after verifying all of these:
- it matches the exact root permit, path, repository identity, owner, and expected HEAD
- its work is accepted and integrated, or explicitly abandoned within the task's authority
- tracked files, untracked files, submodules, and valuable ignored artifacts are clean or accounted for
- no running process depends on the checkout
- the branch or commit is recoverable through the declared integration or remote-backup path
- it is not the active checkout from which removal is attempted
Use the supported host lifecycle for a host-managed primary workspace. For a task-created auxiliary worktree, prefer non-force git worktree remove <exact-path> followed by targeted registration verification. Never use force removal, reset, clean, stash, broad recursive deletion, age alone, or a clean status alone as proof of safety.
If any gate fails, preserve the worktree and return its canonical path, owner, branch or detached HEAD, exact blocker, and next action. Preservation is a safe task-local outcome; silent abandonment is not.
Required Result
Return a compact ledger containing:
- starting registered worktrees relevant to the task
- auxiliary budget and permits issued
- worktrees created or reused
- integration evidence
- final disposition for every task-created auxiliary worktree
- any preserved path and blocker
Do not claim cleanup complete until Git registration and path state are verified.
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.

