agentleFS
SantiagoVqzSantiagoVqz/claude-skills/skills/support/worktree/SKILL.md

worktree

Skill2 starsChanged 10 days agoMITView on GitHub

Make, provision or remove the linked worktree for a branch, with its databases. Use before code work starts on a branch, before you add a migration, and to tear a worktree down after its merge.

  • Reads credentials

59 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

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

  • 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

  • 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

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 47 edited versions we read keep these.

  • 1

    Distinctive

    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
  1. Very specific:

    Locate: Read git worktree list --porcelain.

    line 24
  2. Distinctive:

    Run this from the primary checkout after the branch is merged into the trunk.

    line 35

“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

A linked worktree gives a branch its own folder and databases. /build uses one when the primary checkout is busy or the plan has a migration. This skill reads git facts only, so a worktree made by this skill, by git worktree add or by another tool resolves the same way.

Branches

BranchMade fromDev database
fix/<n>-<slug>the trunkits own fork

/build and /diagnose make fix/ branches.

Each worktree also has its own test database. scripts/provision.sh applies these rules.

The trunk is the branch that PRs merge into: the default branch from git symbolic-ref refs/remotes/origin/HEAD, or develop when the repo has both main and develop. When origin/HEAD is missing, use gh repo view --json defaultBranchRef. Do not run git remote set-head, because it changes the repo config.

Make

  1. Locate. Read git worktree list --porcelain. When you know only the issue number, match any <type>/<n>- branch in it and in git branch -a before you make a new one. Take the case that matches:
    • A worktree has the branch: use its path, and go on to steps 2 to 4.
    • No worktree has it: git fetch origin, then git worktree add -b <branch> <primary>/.claude/worktrees/<branch with / as -> <base>. <primary> is the path on the first worktree line of git worktree list --porcelain. A relative path resolves from the current directory, so a session in another worktree puts the new worktree inside it. Use origin/<trunk> as the base. When the branch is only on the remote, run git branch --track <branch> origin/<branch> first. Leave out -b when the branch exists.
    • The primary checkout has the branch: stop and say so. A branch is checked out in one place only.
  2. Enter. EnterWorktree on the worktree path. Only EnterWorktree puts the guard on the session, so never enter with cd. After this, the harness refuses commands that it cannot prove stay in the worktree. This covers every shell command, not only git. Run one plain command per call, from the worktree root, on paths in the worktree. For a subfolder, use a flag such as pnpm --dir or uv --directory, because a cd stays in effect for the rest of the session. Change a file with the Edit tool, and make a new file with the Write tool. Quote each argument that holds *, [ or ]. The guard refuses only some other forms, such as a && chain, $(...) or a heredoc, so a command that ran is no proof that its form is safe. Pass a commit message with one -m flag per paragraph. A message file in the worktree can get committed.
  3. Provision. When scripts/provision.sh exists, run it in the worktree. When it fails, show the end of its output and stop. When it does not exist and the repo has gitignored .env files, a lockfile or a database URL, the worktree is not ready. Copy no .env file by hand. Tell the user to run /setup-skills, and stop.

Completion: the session is in the worktree, and the end of the provision.sh output names the expected dev and test databases, or the repo needs no provisioning. Otherwise the report says blocked: run /setup-skills.

Remove

Run this from the primary checkout after the branch is merged into the trunk.

  1. Call EnterWorktree with the worktree path, and skip the call when the session is already there. Run scripts/provision.sh drop. The script drops the test database and the dev fork. Then call ExitWorktree with keep to go back to the primary checkout. When the drop fails, show the end of its output and stop. When the user drops the databases by hand, list the databases to confirm that each is gone, and remove any container that the failed drop created.
  2. git worktree remove <path>. When it refuses because of uncommitted or untracked files, stop and show them. Keep the files: no --force. The exception is an xcuserdata/ folder, which holds only Xcode's window state: delete it, and remove the worktree again.
  3. git branch -D <branch>.
  4. git worktree prune, for the records of worktrees whose folder is gone.
  5. In a repo with a .xcodeproj or a .xcworkspace, delete each folder of ~/Library/Developer/Xcode/DerivedData that belongs to the worktree, because Xcode keeps one for each path. Read its path with plutil -extract WorkspacePath raw <folder>/info.plist.

Completion: git worktree list does not show the path, the branch is gone, and no DerivedData folder names the path.

Report

<path> · <branch> · made | found | removed · dev <db> · test <db>

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.