agentleFS
harshanandakharshanandak/forge-legacy/skills/worktree/SKILL.md

worktree

Skill4 starsChanged 48 days agoMITView on GitHub

Forge's worktree lifecycle. `forge worktree create <slug>` makes an isolated checkout under `.worktrees/`, creates its branch (feat/<slug>), links a kernel issue (`--issue`), and installs dependencies — all in one step; `forge worktree list`/`remove <slug>` manage them; `forge clean` removes worktrees whose branches already merged (squash-aware) and fast-forwards the default branch. Use when the user says "work on this in an isolated branch/worktree", "spin up a worktree", "parallel work on another PR or issue", "clean up merged worktrees", or "why did my worktree miss its dependencies". Footgun it prevents: raw `git worktree add` only creates a branch — it skips the issue link and dep install — so always use `forge worktree create`; and `forge clean` is cwd-scoped, run it from the primary repo root, never inside a worktree. NOT for opening/pushing a PR or the branch (ship), NOT for planning a feature (plan), NOT the stages that create a worktree as one step — this is the worktree lifecycle itself.

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

  • 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

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

  • 0

    Common

    Most of the 47 edited versions we read keep these.

  • 0

    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:

    cwd-scoped: Run it from the primary repo root, never from inside a .worktrees/<slug> checkout.

    line 83

“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

Forge worktrees give a task its own isolated checkout so concurrent work never collides on HEAD or a shared branch. Use forge worktree, not raw git worktree add — the Forge command does the extra setup that a bare branch add skips.

Worktree lifecycle

When to use

  • "Work on this in an isolated branch / worktree", "spin up a worktree for this".
  • Parallel work: a second PR or issue you want to develop without disturbing the current checkout.
  • "Clean up the merged worktrees" — reclaim worktrees whose branches already landed.
  • Diagnosing "why did my new worktree miss its dependencies / node_modules".

This skill is the worktree lifecycle itself. The plan/ship stages may create a worktree as one internal step, but managing worktrees directly — create, list, remove, clean — is this skill.

Create

forge worktree create <slug>

Creates the worktree at .worktrees/<slug> and, in one step:

  • creates its branch (default feat/<slug>),
  • links a kernel issue to the worktree when --issue <id> is given (records issue → worktree),
  • installs dependencies with the repo's detected package manager (bun/pnpm/yarn/npm).

Flags:

FlagPurpose
--branch <name>Custom branch name (default feat/<slug>).
--base <ref>Base ref the new branch forks from (default the repo default branch, e.g. origin/main).
--issue <id>Kernel issue id to link this worktree to.
--work-folder <path>Repo-relative work-folder this issue owns (drops a .forge-issue marker).

The kernel issue store lives in the git common dir that every worktree shares, so a new worktree already sees the same kernel — no per-worktree issue-store bootstrap is needed.

The footgun this skill prevents

Never use raw git worktree add for Forge work. It only creates a branch + checkout — it does not link the kernel issue and does not install dependencies. A worktree made that way is why deps end up missing. Always use forge worktree create.

List / remove

forge worktree list              # read the worktree registry from the kernel
forge worktree remove <slug>     # git worktree remove for that slug

Clean merged worktrees

forge clean                      # remove worktrees whose branches merged; FF the default branch
forge clean --dry-run            # show what would be removed, change nothing

forge clean is squash-aware — it detects branches that merged via squash, not just fast-forward merges. Removing a merged worktree also closes the kernel issue the branch was linked to, citing the merge as evidence.

Two things it will never touch, because closing an issue is irreversible (done is terminal):

  • A branch with no commits of its own. A freshly created worktree points at a default-branch commit, which git alone reads as "merged". That is unstarted work — it is kept, and its issue stays open.
  • A worktree it skipped. Uncommitted changes hold a worktree back, and a held-back worktree never has its issue closed.

forge clean footguns

  • cwd-scoped. Run it from the primary repo root, never from inside a .worktrees/<slug> checkout. There is no default-branch guard, so a bare run from the wrong place can remove a clean checkout.
  • Fast-forward the local default branch first so squash-merge detection sees the merged state.
  • Windows long paths. node_modules inside a worktree can exceed the Windows path limit; if git worktree remove --force de-registers the worktree but the directory lingers, delete it with a PowerShell extended-path (\\?\) remove.

Adjacent skills

  • Opening or pushing a PR / the branch → ship.
  • Planning a feature (which may create a worktree as a step) → plan.
  • Watching an open PR toward merge → shepherd.
  • Everyday issue create/update/close → issue-basics.

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.