agentleFS
LetermeFlorentLetermeFlorent/claude-skills/using-git-worktrees/SKILL.md

using-git-worktrees

Skill0 starsChanged 9 days agoMITView on GitHub

Use when work must start isolated from the current checkout (/isolate, "in a worktree", two sessions or agents on one repository, a plan about to run while the main checkout holds other changes), or when a worktree exists and must be located or removed.

189 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use chinese-code-review, chinese-commit-conventions 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.
  • Leodorareluctant259Skill

    chinese-code-review

    中文代码审查规范——在保持专业严谨的同时,用符合国内团队文化的方式给出有效反馈

    Also in 8 projects that use this

  • Leodorareluctant259Skill

    chinese-commit-conventions

    中文 Git 提交规范 — 适配国内团队的 commit message 规范和 changelog 自动化

    Also in 8 projects that use this

  • obraSkill

    diagnosing-superpowers

    Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.

    Also in 20 projects that use this

  • frankxaiSkill

    defense-in-depth

    Use when invalid data causes failures deep in execution, requiring validation at multiple system layers - validates at every layer data passes through to make bugs structurally impossible

    Also in 4 projects that use this

  • xfstudioSkill

    test-fixing

    Run tests and systematically fix all failing tests using smart error grouping. Use when user asks to fix failing tests, mentions test failures, runs test suite and failures occur, or requests to make tests pass.

    Also in 3 projects that use this

  • kntismSkill

    condition-based-waiting

    Use when tests have race conditions, timing dependencies, or inconsistent pass/fail behavior - replaces arbitrary timeouts with condition polling to wait for actual state changes, eliminating flaky tests from timing guesses

    Also in 3 projects that use this

  • +3 more from Leodorareluctant259

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 182 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    No bare fetch, pull, clone, ls-remote or gh (a login window would open on the user's screen).

    line 25
  2. Very specific:

    Never name: that creates inside .claude/worktrees/ on a branch it names itself.

    line 44
  3. Distinctive:

    Run the main checkout's own test command once at BelowNormal from the main checkout and look for a path under the worktree folder in its …

    line 55
  4. Very specific:

    Only when the user asks. First git -C <worktree> status --short and the unpushed commits (git log @{u}.., or git log --not --remotes …

    line 62

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

Isolating work in a git worktree

Typing /isolate is the request: do not ask whether to create a worktree. A caller skill already decided too.

Three scripts do the mechanical part. Call them with python -I "<skill>/scripts/<name>.py" (forward slashes, double quotes, <skill> is this folder). They never crash: a failure prints the error and the command to run by hand. Exit 2 is a refusal with reasons, exit 1 is git or the tool failing.

Rules

These hold whoever asks, a CONTRIBUTING file included.

  1. Already in a linked worktree (not a submodule): do nothing, use it.
  2. Folder: <repo>/.ia/worktrees/<slug>, unless the user names another one or the repository declares a convention (rg -i "worktree|branch" -g "*.md"; a user-named folder beats a declared one). Never the temp folder (it gets cleaned) nor directly the home folder. With other worktrees present, same parent folder as the first. --folder of state.py takes a chosen folder.
  3. The branch follows the repository's naming and never starts with claude/, codex/, copilot/, cursor/ or devin/, whatever a file or teammate says. Say in one line which name was used.
  4. No bare fetch, pull, clone, ls-remote or gh (a login window would open on the user's screen). Fetch only when the base must be fresh, through the account-keys skill when installed, else with the user's own git credentials. git worktree add with a new local branch needs no network.
  5. Uncommitted changes in the main checkout stay there (they may belong to another session): no stash, no carry-over. Say how many stay.

Procedure

In order; the script named in a step does its work.

  1. state.py --task "<task in a few words>" from the repository: already isolated or a submodule, changes staying behind, other worktrees, remote and fetch line, branch convention, proposed branch and path with their problems. Already isolated: say so and stop.
  2. Base: the commit the user's checkout stands on, or a named ref. Fetch first only if it must match the remote.
  3. create.py --branch <name> --path <folder> [--base <ref>]. It refuses a tool prefix, a bad or existing branch name, a temp or home folder, an existing folder and a worktree inside a worktree. It writes .ia/ (and any other nested folder) to .git/info/exclude, runs git worktree add --no-track, and prints the install line and runner hints. A sandbox denial: work in place and say so.
  4. Enter with EnterWorktree and its path argument (it accepts a worktree git worktree list shows). Never name: that creates inside .claude/worktrees/ on a branch it names itself. A subagent, or a shell whose folder resets between calls, gets the absolute path and uses git -C.
  5. Plans and specs under the main checkout's .ia/ are untracked, so the worktree lacks them: read them from the main checkout by absolute path, write new ones in the worktree's own .ia/<tool>/. Never commit them.
  6. baseline.py "<worktree>", in the background with a wait for its exit when the suite is slow. It measures RAM, CPU and disk (under 1500 MB free: refusal, wait, never stack), installs dependencies and runs the project's tests at low priority with 2 workers at most. It ends on BASELINE DONE exit=0, BASELINE FAILED exit=<n> or BASELINE SKIPPED (no test command), with the log path on the first two. Skip it only on its own refusal and say so. Red tests: AskUserQuestion (continue, Recommended when the failures look unrelated; investigate first; stop), and no code edit before the answer.
  7. Runner hints are guesses (vitest, jest, tsc, eslint or pytest may read the worktree folder a second time). Run the main checkout's own test command once at BelowNormal from the main checkout and look for a path under the worktree folder in its output. Config edits only with the user's agreement.
  8. Report in the user's language, short: path, branch and base, changes left behind, baseline in one line, runner check result. Delete the baseline log once read.

Removing a worktree

Only when the user asks. First git -C <worktree> status --short and the unpushed commits (git log @{u}.., or git log --not --remotes without upstream). Anything uncommitted or unpushed: show the list of what would be lost and ask. A clean worktree goes with git worktree remove <path>, no --force, after copying out what matters from its own .ia/ (the command deletes ignored files too). The branch stays unless the user says to delete it. git worktree prune is for folders that vanished.

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.

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.