finish-worktree

Finalizes isolated Git worktrees via PR creation, local merge, transfer, retention, or authorized discard.

Updated May 19, 2026
One-click install
npx skills add https://github.com/wenyue/SmartKit --skill finish-worktree-wenyue
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: finish-worktree
Source: https://github.com/wenyue/SmartKit/tree/main/docs/zh-CN/skills/finish-worktree
Command: npx skills add https://github.com/wenyue/SmartKit --skill finish-worktree-wenyue

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Finishing work in an isolated Git worktree is error-prone: interrupted pushes, ambiguous PR states, dirty checkouts, and partial file transfers can silently lose work or duplicate merges. This Skill closes out a worktree through a chosen, evidence-backed outcome while protecting unrelated state and recording every operation for recovery. ## Core Features & Use Cases - Five outcome paths: keep work for later, create a pull request, merge locally via fast-forward, return changes to a checkout for review, or explicitly discard with authorized-loss accounting. - History preparation and recovery: binds accepted commits to immutable evidence, detects Already Delivered targets, and persists operation receipts so interrupted pushes, merges, or transfers resume safely instead of repeating. - State preservation guarantees: uses snapshot/compare evidence scripts and a guarded batch transfer tool to prove HEAD, index, and unrelated files stay protected. - Use Case: After finishing a feature in a linked worktree, ask the agent to publish the accepted commits as a PR; it verifies the remote, reuses any matching open PR, and reports proven results with retained recovery refs. ## Quick Start Ask the agent to finish the isolated worktree for the current task by creating a pull request from its accepted commits.

Frequently Asked Questions about finish-worktree

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely finish a Git worktree after completing a task?▼

Choose one of five outcomes: keep for later, create a pull request, merge locally, return changes for review, or explicitly discard. Each path defines readiness conditions and proof requirements so the worktree closes with evidence rather than assumptions.

How to create a pull request from a Git worktree without duplicates?▼

Search for existing PRs by repository, target, and source before creating one, and reuse a matching open PR after checking its actual source commit. Never create a replacement PR just because a previous call returned no response.

What happens if a push or merge is interrupted mid-operation?▼

Every state-changing attempt is recorded in a persistent operation receipt outside the affected worktrees. Before retrying, the recovery flow re-observes authoritative Git or host state and resumes only the unproven remainder, never blindly repeating merges or PR creation.

Can I discard a worktree with uncommitted or untracked changes?▼

Only with explicit authorization covering the exact observed losses. The discard path inventories staged, unstaged, untracked, and ignored content, matches it against granted permissions, and proves unaffected checkouts are protected before removal.

Does finishing a worktree require a clean working tree or formal review?▼

No. The keep-for-later path explicitly preserves dirty, unfinished, and unreviewed work with a named next owner. Formal review evidence is only required for publishing or integration paths, per the history preparation contract.

When should I use return-for-review instead of merging locally?▼

Use return-for-review when accepted changes should move into a target checkout's working files while preserving its HEAD and index, keeping the handoff non-integrating. Local merge is only for fast-forward delivery into an authorized target branch.