agentleFS
sabirmgdsabirmgd/terminal-first-goal-loop/skills/worktree/SKILL.md

worktree

Skill2 starsChanged 3 months agoMITView on GitHub

Create or reuse an isolated worktree for one mutating task, protect dirty or shared checkouts, and hand off safe cleanup requirements. Use before any non-trivial code change that may run in parallel with other work.

40 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use coverage, backlog and 9 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.
  • PydanticSkill

    coverage

    Fetch coverage diff from Codecov for the current branch or a specific PR. Shows uncovered lines, patch coverage, and overall coverage change.

    Also in 3 projects that use this

  • vertz-devSkill

    backlog

    Manages deferred/blocked work items as GitHub Issues with labels and blocker tracking

    Also in 3 projects that use this

  • johnlindquistSkill

    diagram

    Maintain and synchronize Unified Impact Diagrams following Diagram Driven Development (DDD) methodology. Create, update, and manage diagrams that connect user value to technical implementation.

    Also in 4 projects that use this

  • SentrySkill

    e2e

    Run E2E tests for Sentry JavaScript SDK test applications

    Also in 3 projects that use this

  • MongoDBSkill

    jira

    Use this skill for any Jira operation in the DOCSP project — creating, viewing, searching, updating, transitioning, commenting on, or linking tickets. Also handles follow-up ticket creation to manage scope creep. TRIGGER when: user mentions a DOCSP-XXXXX ticket number or any Jira ticket URL; user asks to view, open, check, update, transition, close, comment on, link, or search tickets; user references \"the ticket\", \"the Jira\", or \"open a ticket\". SKIP: GitHub issues; non-Jira platforms; questions unrelated to ticket operations.

    Also in 3 projects that use this

  • Microsoft AzureSkill

    validate

    Run the full CI validation workflow locally before submitting a PR. Use this as a final check to ensure all Azure DevOps CI pipeline steps will pass.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

10 rules. 0 are common, 10 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 35 edited versions we read keep these.

  • 10

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before creating or reusing a worktree, check:

    line 23
  2. Distinctive:

    Never start mutable work in a dirty shared checkout.

    line 33
  3. Distinctive:

    Never reuse main, master, or another shared base checkout for task edits.

    line 34
  4. Distinctive:

    If the canonical base checkout is dirty, find another clean checkout that owns the same base branch and fast-forward that one instead.

    line 35
  5. Distinctive:

    If no clean base exists, stop and report that the task needs a clean base before code changes begin.

    line 37
  6. Distinctive:

    Do not guess branch ownership from folder names alone.

    line 39
  7. Distinctive:

    Create one task branch from that base.

    line 46
  8. Distinctive:

    Create one worktree for that branch.

    line 47
  9. Distinctive:

    Verify that the new worktree is clean before implementation starts.

    line 49
  10. Distinctive:

    no other active task claims the same mutable surface

    line 60

“Common” is measured: kept by at least 6 in 10 of the 35 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Worktree

This skill protects the repo from the easiest parallel-work failure: two mutating threads touching the same checkout.

What This Skill Guarantees

Each mutable task gets:

  • one exact base
  • one branch
  • one worktree
  • one ownership record
  • one cleanup handoff

Preflight

Before creating or reusing a worktree, check:

  1. git status --short
  2. git worktree list --porcelain
  3. the branch that currently owns the intended base
  4. whether the main or default checkout is dirty
  5. whether another active task already owns the target branch or worktree

Rules

  1. Never start mutable work in a dirty shared checkout.
  2. Never reuse main, master, or another shared base checkout for task edits.
  3. If the canonical base checkout is dirty, find another clean checkout that owns the same base branch and fast-forward that one instead.
  4. If no clean base exists, stop and report that the task needs a clean base before code changes begin.
  5. Do not guess branch ownership from folder names alone. Check git state.

Workflow

  1. Resolve the exact base branch for the task.
  2. Find a clean checkout that owns that base.
  3. Fast-forward the clean base checkout.
  4. Create one task branch from that base.
  5. Create one worktree for that branch.
  6. Record the worktree path, branch name, base SHA, and owner task label.
  7. Verify that the new worktree is clean before implementation starts.
  8. Hand off the cleanup requirements.

Verification

A new worktree is ready only when all of these are true:

  • the base SHA is known
  • the branch points at that base
  • the worktree is attached to that branch
  • git status --short is clean inside the worktree
  • no other active task claims the same mutable surface

Cleanup Handoff

This skill does not remove the worktree automatically. It hands cleanup to cleanup, with these checks attached:

  • was the branch merged or intentionally preserved?
  • is the worktree still dirty?
  • does any slot, browser session, or loop still depend on it?

Output Contract

WORKTREE | task=<label> | branch=<name> | path=<path>
BASE | branch=<base-branch> | sha=<base-sha>
OWNER | status=<new|reused> | mutable_surface=<summary>
READY | yes|no
CLEANUP HANDOFF | cleanup

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.