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

worktree

Skill2 starsChanged 2 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.

59 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use worktree-merge, resolve-conflicts 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.
  • leessjuSkill

    worktree-merge

    Squash-merge the current worktree branch into the main branch (or a specified target). Analyzes git history and source code to craft a comprehensive commit message.

    Also in 3 projects that use this

  • ralphkraussSkill

    resolve-conflicts

    Resolve git merge conflicts or re-apply changes from a stale branch onto current main. Use when user says "resolve conflicts", "merge conflicts", "rebase branch", "branch is behind", "re-apply changes", "port branch", or a branch is too far behind main to merge cleanly.

    Also in 5 projects that use this

  • SentrySkill

    e2e

    Run E2E tests for Sentry JavaScript SDK test applications

    Also in 5 projects that use this

  • hdcolaSkill

    pr-comments

    Fetch unresolved review comments from a GitHub PR or mark comments as resolved. Use this when managing PR review feedback, checking pending comments, or marking review threads as resolved. Supports GitHub URLs or explicit owner/repo/PR-number from anywhere, or PR number auto-detection from within a git repository.

    Also in 3 projects that use this

  • Google CloudSkill

    contributing

    Guides the developer workflow for contributing to Race Condition. Use when setting up pre-commit hooks, running tests before a PR, understanding code style requirements, or preparing a contribution.

    Also in 3 projects that use this

  • 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

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 47 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 47 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.