close-github-worktree-done

Closes GitHub issues and removes local git worktrees and branches after merge.

2.5k|524|Updated May 29, 2019
One-click install
npx skills add https://github.com/TencentBlueKing/bk-ci --skill close-github-worktree-done
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: close-github-worktree-done
Source: https://github.com/TencentBlueKing/bk-ci/tree/main/ai/skills/close-github-worktree-done
Command: npx skills add https://github.com/TencentBlueKing/bk-ci --skill close-github-worktree-done

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

After a feature branch is merged, developers often leave behind stale git worktrees, local branches, and open GitHub issues. This Skill automates the cleanup workflow for the bk-ci repository: it optionally closes the linked GitHub Issue, removes the local worktree directory, and deletes the local branch, all with safety confirmations.

Core Features & Use Cases

  • Issue Resolution from Branch Name: Parses the GitHub issue number from branch naming conventions like bug-12994 or feat-tenant-3-11524, checks its state via the GitHub MCP server, and closes it only after user confirmation.
  • Safe Worktree Removal: Verifies the target worktree exists, checks for uncommitted changes, syncs local master with origin, and confirms merge status before removing anything.
  • Guarded Branch Deletion: Deletes the local branch with git branch -d, requiring explicit user consent before any force-delete, and never touches remote branches.
  • Use Case: After merging PR for branch bug-12994 into bk-ci master, invoke this Skill to close issue #12994, remove the worktree, and delete the local branch in one guided flow.

Quick Start

Close the worktree and finish the requirement for branch bug-12994, including closing its linked GitHub issue.

Frequently Asked Questions about close-github-worktree-done

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

FAQPage Schema
How do I remove a git worktree and delete its local branch?

Run git worktree remove with the target path from the main repository root, then delete the branch with git branch -d. This Skill automates both steps after verifying the branch is merged into master and the worktree has no uncommitted changes.

How do I close a GitHub issue linked to a branch after merging?

Parse the issue number from the branch name's last numeric segment, then update the issue state to closed via the GitHub API. This Skill uses the user-github MCP server's issue_read and issue_write tools, and only closes the issue after explicit user confirmation.

Why must this cleanup run on the master branch?

The workflow requires master because it fetches and merges origin/master to verify the target branch is fully merged before deletion. Running elsewhere risks deleting unmerged work, so the Skill aborts if the current branch is not master.

What happens if the branch has not been merged into master?

The Skill checks git branch --merged master after syncing with origin. If the target branch is unmerged, it warns that local commits would become unreachable and asks for explicit confirmation before proceeding, or aborts if the user cancels.

Does removing a worktree delete the remote branch?

No. This workflow never deletes remote branches and never runs git push --delete. It only removes the local worktree directory and the local branch, leaving the remote branch on origin untouched.

What if the branch name does not contain an issue number?

If the last dash-separated segment of the branch name is not numeric, the Skill cannot resolve a GitHub issue. It then asks the user whether to skip the issue-closing step and proceed with worktree and branch removal only.