agentleFS
enderyildirimenderyildirim/claude-skills/skills/worktree/SKILL.md

worktree

Skill1 starsChanged 8 months agoMITView on GitHub

Isolate parallel, independent tasks in separate git worktrees so they never overwrite each other — each task gets its own working directory and branch. Use when juggling multiple unrelated changes at once, or when the user says 'work on this in parallel', 'spin up a worktree', 'isolate this task'. Usage: /worktree [create <task> | list | remove <task> | clean]

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

  • nicolasestremSkill

    cleanup

    Clean up code, remove dead code, and optimize project structure

    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

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 3 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 35 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this when you have multiple unrelated changes in flight (feature A, bugfix B, experiment C) and they must stay isolated.

    line 11
  2. Distinctive:

    Create the worktree on a fresh branch off the up-to-date base:

    line 28
  3. Very specific:

    If the branch already exists, drop -b and check it out instead.

    line 33
  4. Very specific:

    Run git worktree list and present each worktree with its branch and a one-line status (clean / N uncommitted files via git -C <path> status …

    line 37
  5. Very specific:

    Check the worktree is clean (git -C <path> status --short).

    line 40
  6. Very specific:

    Run git worktree prune to clear stale administrative entries (worktrees whose directories were deleted manually), then list the survivors.

    line 45
  7. Very specific:

    Never overwrite uncommitted work: Before any remove or --force, surface dirty state and get a decision.

    line 53
  8. Distinctive:

    One task = one branch = one worktree: Don't reuse a branch across worktrees.

    line 55

“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 — Isolate Parallel Tasks

Git worktrees let one repository have multiple working directories checked out at once, each on its own branch. This is the clean way to work on several independent tasks in parallel: changes in one never touch another, no stashing, no branch-switching churn, no half-finished edits bleeding across tasks.

Use this when you have multiple unrelated changes in flight (feature A, bugfix B, experiment C) and they must stay isolated.

Conventions

  • Location: worktrees live in a sibling directory ../<repo>-worktrees/<task-slug> — outside the main checkout so they never nest inside it, never get caught by its .gitignore, and never confuse tooling.
  • Branch per task: each worktree is on its own branch named <task-slug>, created off the repo's base branch (read it from CLAUDE.md; fall back to the default branch from git symbolic-ref refs/remotes/origin/HEAD).
  • Task slug: short kebab-case derived from the task (e.g. "fix login redirect" → fix-login-redirect).
  • One branch, one worktree: git refuses to check out the same branch in two worktrees — lean on that as the anti-overwrite guarantee.

Process

First read the target project's CLAUDE.md for the base/PR branch convention. Then dispatch on the argument:

create <task> (default action)

  1. Resolve the repo root: git rev-parse --show-toplevel and its name.
  2. Resolve the base branch (CLAUDE.md convention → else git remote show origin default).
  3. Slugify <task> → <task-slug>.
  4. Create the worktree on a fresh branch off the up-to-date base:
    git fetch origin <base> --quiet
    git worktree add ../<repo>-worktrees/<task-slug> -b <task-slug> origin/<base>
    If the branch already exists, drop -b and check it out instead.
  5. Report the absolute path and tell the user how to enter it: cd <path> — and that they can open a separate Claude Code session there so each task has its own isolated context.

list

Run git worktree list and present each worktree with its branch and a one-line status (clean / N uncommitted files via git -C <path> status --short). Flag any whose branch is already merged into base as safe to remove.

remove <task>

  1. Check the worktree is clean (git -C <path> status --short). If dirty, stop and warn — show the uncommitted changes, ask whether to commit, stash, or discard before removing. Never silently throw away work.
  2. git worktree remove ../<repo>-worktrees/<task-slug> (add --force only after explicit user confirmation).
  3. Offer to delete the branch if it's fully merged: git branch -d <task-slug>.

clean

Run git worktree prune to clear stale administrative entries (worktrees whose directories were deleted manually), then list the survivors. Identify merged-branch worktrees and offer to remove them in a batch after confirmation.

Parallel agents

For parallel work driven by Claude itself rather than separate human sessions, the Agent tool's isolation: "worktree" option runs each subagent in its own throwaway worktree — same isolation guarantee, auto-cleaned. Mention this when the user wants Claude to fan out edits across tasks concurrently rather than manage long-lived worktrees by hand.

Rules

  • Never overwrite uncommitted work. Before any remove or --force, surface dirty state and get a decision. This is the whole point of the skill.
  • Keep worktrees outside the main checkout — always the sibling ../<repo>-worktrees/ dir, never a subdir of the repo.
  • One task = one branch = one worktree. Don't reuse a branch across worktrees; don't pile unrelated changes into one worktree.
  • Branch off an up-to-date base — fetch before creating so parallel tasks don't diverge from a stale point.
  • Be project-agnostic — detect repo name, root, and base branch dynamically; never hardcode paths.
  • Show before destroying — list what will be removed and confirm before deleting worktrees or branches.

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.