Agent Skillsfoyzulkarim/claude-lens › finish-worktree

finish-worktree

GitHub

在PR合并且Issue关闭后,清理工作区。验证合并状态后,快进main分支,移除对应的issue嵌套worktree及本地特性分支,并提示更新计划与归档任务,确保仓库整洁。

.claude/skills/finish-worktree/SKILL.md foyzulkarim/claude-lens

Trigger Scenarios

用户要求结束、拆除或清理已合并Issue的工作区 用户提及finish、tear down或clean up lane/worktree

Install

npx skills add foyzulkarim/claude-lens --skill finish-worktree -g -y
More Options

Non-standard path

npx skills add https://github.com/foyzulkarim/claude-lens/tree/main/.claude/skills/finish-worktree -g -y

Use without installing

npx skills use foyzulkarim/claude-lens@finish-worktree

指定 Agent (Claude Code)

npx skills add foyzulkarim/claude-lens --skill finish-worktree -a claude-code -g -y

安装 repo 全部 skill

npx skills add foyzulkarim/claude-lens --all -g -y

预览 repo 内 skill

npx skills add foyzulkarim/claude-lens --list

SKILL.md

Frontmatter
{
    "name": "finish-worktree",
    "description": "After an issue's PR has squash-merged on GitHub and its issue has closed: fast-forward main, remove the issue-numbered nested worktree (.worktrees\/<issue#>), and delete the local feature branch. Use when the user says to finish, tear down, or clean up a lane or worktree for a merged issue."
}

Finish-Worktree

Teardown counterpart to /move-to-worktree. Run it in the primary checkout, on main, after you squash-and-merge the issue's PR on github.com. The script uses GitHub's PR and issue state as the authoritative merge guard; remote branch deletion is an additional safety check, not proof of merge by itself.

Run (1 bash call)

bash {base_directory}/finish-worktree.sh <issue-number>

The script:

  1. Hard-stops unless run in the clean primary checkout on main.
  2. Finds exactly one local branch {type}/<issue#>/{slug} and its matching worktree.
  3. Uses gh to verify a PR for that exact head branch is merged, its recorded head commit matches the local branch tip, and issue <issue#> is closed. It also requires the remote feature branch to be gone.
  4. git pull --ff-only on main (brings the squashed work in) + git fetch --prune (clears the stale tracking ref).
  5. git worktree remove .worktrees/<issue#>never --force: if the worktree has uncommitted work it prints the leftovers and stops.
  6. git branch -D <branch> — capital -D is deliberate: squash-merge means git can't prove the branch merged, so -d always refuses; step 3 already verified the work landed.

Non-zero exit → hard-stop, print stderr verbatim.

Report

What was removed (worktree path, branch), then the standing post-merge hygiene reminders: flip the task's checkbox in specs/claude-lens-plan.md, run /archive-issue <issue#> promptly, and commit that hygiene so the primary is clean for the next /start-task. After any merge, in-flight lanes should sync with origin/main only when they need the merged work; for an already pushed/shared lane, merge origin/main rather than rewriting its history.

You Must NOT

  • Use git worktree remove --force or otherwise discard uncommitted work — surface it and stop.
  • Delete the branch when any merge guard fails.
  • Flip plan checkboxes or archive the issue yourself unless asked — remind, don't perform.

Version History

  • 914c041 Current 2026-07-24 17:36

Same Skill Collection

.claude/skills/archive-issue/SKILL.md
.claude/skills/create-issue/SKILL.md
.claude/skills/move-to-worktree/SKILL.md
.claude/skills/release-notes/SKILL.md

Metadata

Files
0
Version
914c041
Hash
049bede2
Indexed
2026-07-24 17:36

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-27 01:30
浙ICP备14020137号-1 $Carte des visiteurs$