Skip to content
Skills Library
Programming · Automation

git-worktree-finish

/git-worktree-finish

Use when the user asks to finish, land, or merge back a feature worktree created with /git-worktree.

Repository
skills ↗
Licence
MIT
Last repository change
03.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 03.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use when the user asks to finish, land, or merge back a feature worktree created with /git-worktree.

Original author description

Use when the user asks to finish, land, or merge back a feature worktree created with /git-worktree.

How it works

  1. Core Constraints
  2. Workflow
Original SKILL.md headings · 125 lines, 1,022 words
SKILL.md preview
---
name: git-worktree-finish
description: Use when the user asks to finish, land, or merge back a feature worktree created with /git-worktree.
---

# Git Worktree Finish

Land the agent's own feature worktree (see `/git-worktree` for the layout) on
the default branch and then remove it. Removal is the last step and happens
only when verification proves every commit and file of value is already on the
default branch. When in doubt, keep the worktree and report why.

## Core Constraints

**Never lose work.** Never run `git worktree remove --force`,
`git branch -D`, `git reset --hard`, `git clean`, `git stash`, `git checkout`,
or `git restore`. Never delete `.git` lock files
or another agent's files.

**Never rewrite history.** Integrate with regular `git merge` only. Do not
rebase, amend, squash, reword, absorb, cherry-pick to replace commits, or
force-push. A merge commit in the feature branch is the expected way to pick up
the default branch.

**Never disturb other work.** Outside the agent's own worktree, the only
allowed mutations are the commit in step 3, the fast-forward merge in step 7,
and the artifact cleanup in step 10. Do not touch other feature worktrees.

**Stay local.** Do not push. Pushing needs the user's explicit approval.

## Workflow

1. **Identify.** Confirm the current directory is a feature worktree, not the
   main checkout, and note its path and `feature/<name>` branch. Find the main
   checkout and default branch with `git worktree list` (the first entry and
   its branch). If the current directory is the main checkout, stop: there is
   no worktree to finish.
2. **Commit the worktree's pending work** with `/git-commit`, including its
   Spec Sync Gate. Skip this when the worktree is clean.
3. **Settle the main checkout.** If the main checkout has pending changes,
   commit them there with `/git-commit`, but skip its Spec Sync Gate and
   run no checks. Do not message the
   agents working there about it. If a commit is already in progress, wait
   for it.
4. **Merge the default branch into the feature branch**, inside the feature
   worktree:

   ```bash
   git merge --no-edit <default-branch>
   ```

   This keeps conflict resolution inside the agent's own worktree, away from
   the main checkout.
5. **Resolve conflicts properly.** For each conflicted file, read both sides
   and the merge base (`git diff`, `git log --merge -p <path>`) and produce a
   result that keeps the intent of both. Do not resolve by blindly taking
   "ours" or "theirs", and do not drop the other side's changes to make the
   merge pass. Settle technical decisions that do not need the user's input
   with `/decide`. Stop and ask the user when a resolution changes product
   behavior, discards either side's work, or is otherwise genuinely theirs to
   decide; leave the merge in progress in the feature worktree and report. Once
   resolved, stage the files and finish with `git commit --no-edit`.
6. **Validate the merged result** in the feature worktree with `/checks`.
   Fix failures caused by the merge at their root cause, commit the fixes, and
   repeat until checks pass. If a failure is not caused by this work, report it
   instead of landing on top of it unknowingly.
7. **Land with a fast-forward** in the main checkout:

   ```bash
   git -C <main-checkout> merge --ff-only feature/<name>
   ```

   The feature branch already contains the default branch, so this only moves
   the default branch forward. If it refuses because the default branch moved,
   repeat from step 3. If it refuses because pending files in the main checkout
   would be overwritten, repeat from step 3 rather than forcing it.
8. **Verify nothing can be lost.** All of these must hold before removal:
   - `git merge-base --is-ancestor feature/<name> <default-branch>` succeeds;
   - `git -C <worktree> status --porcelain` is empty, so no tracked changes or
     untracked files remain;
   - `git -C <worktree> status --porcelain --ignored` lists only regenerable
     output such as build directories, caches, `.direnv/`, and dependency
     directories; any ignored file that is not obviously regenerable (notes,
     `.env` files, `.debug/` traces, local data) blocks removal until the user
     decides;
   - no merge, rebase, cherry-pick, or bisect is in progress in the worktree;
   - `git -C <worktree> stash list` shows no stash created on this branch.

   If any check fails, keep the worktree and branch and report what is left.
9. **Remove the worktree** from the main checkout, never from inside the
   worktree being removed:

   ```bash
   git -C <main-checkout> worktree remove <worktree-path>
   git -C <main-checkout> branch -d feature/<name>
   ```

   Both commands refuse to discard unmerged or modified work; if either refuses,
   stop and report instead of forcing it. Move this agent's working directory
   to the main checkout afterwards.
10. **Free the worktree's build output.** Removing the worktree already deletes
    the ignored output inside it, such as `target/`, `node_modules/`, and
    `.direnv/`; note its size with `du -sh` before step 9 for the report.
    Then look for regenerable output kept outside the worktree that belonged
    only to it, for example a `CARGO_TARGET_DIR` or other build directory
    redirected to a per-worktree path, devenv or direnv state keyed by the
    worktree path, or `result` links in the main checkout that point into the
    removed worktree. Delete an item only when all of these hold:
    - its path or a recorded key names the removed worktree path or
      `feature/<name>`, so no other checkout or worktree can be using it;
    - it is regenerable build or cache output, not notes, traces, `.env`
      files, or local data;
    - it is not a symlink to elsewhere that the delete would follow (delete
      the link itself, never its target).

    Delete with `rm -rf -- <exact-path>` on each resolved, absolute path; never
    use globs or variables that could expand to a parent or shared directory.
    Leave shared caches alone (sccache, `~/.cargo`, `~/.cache/go-build`,
    package manager stores, other projects' caches), and do not run
    `nix-collect-garbage` or `nix store gc`, which reach beyond
    this worktree; Nix drops GC roots whose links were removed with the
    worktree on its next collection. When unsure whether an item belongs only
    to this worktree, keep it and list it in the report. Skip this step when
    the worktree was kept.
11. **Report** the merge and landing commits, any conflicts and how they were
    resolved, the check results, whether the worktree was removed, the build
    output freed and its approximate size, anything left for the user to
    delete, and that the default branch was not pushed.
Files in this package (2)
  • SKILL.md 7 KB
  • agents/openai.yaml 1 KB

Versions

The database has no other skills named git-worktree-finish.

Database snapshot: 13.11.2026 · package version 104ac6758162 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90worktrees:finish
    Use when completing work in a worktree. Handles PR creation or direct merge, worktree removal, and branch cleanup. Invoke with "/worktrees:finish" or when user mentions "finish worktree", "clean up worktree", "merge worktree", "done with worktree", or "complete worktree work".
  • 80vc:merge-worktree
    Merge a git worktree branch back into the main Flowser checkout and clean up the worktree. Use when the user asks to merge, archive, or clean up a completed worktree.
  • 100speclink-worktree-merge
    Use when a worktree change is committed and ready to land — merges the branch back into the main branch, then cleans the worktree up.
  • 95worktree
    Isolate work in a git worktree. Activates when the user needs branch isolation before executing a plan, wants a clean environment for a feature, is ready to finish work in an existing worktree, or wants to reclaim worktrees that accumulated and are now polluting filesystem-level measurement.
  • 100finish-work-on-local-worktree
    This skill should be used when the user says "finish worktree", "close out worktree", "merge and close milestone", "finish this worktree", "done with worktree", "wrap up worktree", or when a worktree branch is complete and needs to be merged into main AND related documentation…
  • 100worktree
    Create, inspect, and safely remove git worktrees for repos under the workspace root (WORKSPACE_ROOT, default ~/git), enforcing the worktree-first policy and the no-stale-worktree guarantee. Use whenever you are about to make a change that will be committed, when the user says…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.