finishing-a-development-branch

Guides merging, pushing, or keeping a completed git branch with verified tests and worktree cleanup.

Updated Sep 11, 2026
One-click install
npx skills add https://github.com/CYRUS-pinto/pi-bot --skill finishing-a-development-branch-cyrus-pinto
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: finishing-a-development-branch
Source: https://github.com/CYRUS-pinto/pi-bot/tree/main/.agents/skills/finishing-a-development-branch
Command: npx skills add https://github.com/CYRUS-pinto/pi-bot --skill finishing-a-development-branch-cyrus-pinto

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When implementation work is done, developers face a risky moment: deciding how to integrate a feature branch without losing work, merging into the wrong base, or destroying uncommitted files in a worktree. This Skill enforces a safe, structured completion workflow. ## Core Features & Use Cases - Test-Gated Integration: Runs the full test suite first and refuses to proceed if anything fails, including re-verifying tests on the merged result. - Environment-Aware Options: Detects normal repos, named-branch worktrees, and detached HEAD states to present the correct menu: merge locally, push and create a PR, or keep the branch as-is. - Safe Worktree Cleanup: Removes only self-created worktrees under .worktrees/ or worktrees/, never force-removes worktrees containing uncommitted files, and requires typed confirmation before discarding work. - Use Case: After finishing a feature in a git worktree, use this Skill to verify tests, merge back to the base branch, clean up the worktree, and delete the feature branch without losing any uncommitted notes or plans. ## Quick Start Use the finishing-a-development-branch skill to complete my current branch now that all tests pass.

Frequently Asked Questions about finishing-a-development-branch

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

FAQPage Schema
How do I safely merge a feature branch after tests pass?

Run the full test suite first, confirm the base branch the work forked from, then check out the base, pull, and merge the feature branch. Re-run tests on the merged result before deleting the branch or cleaning up any worktree.

How do I remove a git worktree after finishing a branch?

Change directory to the main repo root, then run git worktree remove followed by git worktree prune. Only remove worktrees under .worktrees/ or worktrees/ that you created; leave externally managed workspaces in place.

What should I do when git worktree remove is refused?

A refusal means the worktree contains modified or untracked files that exist nowhere else. Never use --force on your own initiative; instead show the file list with git status --porcelain -uall and ask whether to commit, move, or delete them.

Can I create a pull request from a detached HEAD state?

Yes. Push the detached HEAD as a new named branch using git push origin HEAD:refs/heads/<new-branch>, then create the pull request against the base branch with the forge's CLI or the URL printed after pushing.

When is it safe to delete a feature branch?

Delete with git branch -d only after the merged result passes tests. Force-deletion with git branch -D should happen only when the user explicitly requests discarding the work and confirms by typing 'discard'.