close-branch

Rebase, fast-forward merge, and delete feature branches in Git worktrees.

Updated Apr 10, 2026
One-click install
npx skills add https://github.com/seankao31/dotfiles --skill close-branch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: close-branch
Source: https://github.com/seankao31/dotfiles/tree/main/.claude/skills/close-branch
Command: npx skills add https://github.com/seankao31/dotfiles --skill close-branch

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill automates the project-scoped Git operations required to close a feature branch safely within a chezmoi/agent-config workflow, reducing manual steps and error-prone handoffs.

Core Features & Use Cases

  • Rebase the worktree onto the local main to absorb unpushed commits.
  • Perform a fast-forward merge into main and push, preserving linear history.
  • Detach HEAD in the worktree and delete the feature branch both locally and remotely when appropriate.
  • Use cases include closing a feature branch after review, preserving main history, and cleaning up local worktrees in monorepo-like setups.

Quick Start

Invoke the close-issue workflow to trigger the close-branch sequence for a reviewed feature branch.

Frequently Asked Questions about close-branch

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

FAQPage Schema
How do I automate git branch cleanup and fast-forward merge into main?

To automate git branch cleanup and fast-forward merge, the skill rebases a worktree onto local main, performs a fast-forward merge, pushes, and deletes the feature branch locally and remotely. This enforces deterministic steps with pre-flight checks for safe cleanup.

What is the best way to close a feature branch after review in a monorepo-like environment?

The best way to close a feature branch after review in a monorepo-like environment is to trigger an automated close-issue workflow that absorbs unpushed commits via rebase, fast-forward merges into main, and safely deletes local and remote branches.

Can I use this workflow to rebase a worktree onto local main and delete the remote branch?

Yes, you can use this workflow to rebase a worktree onto local main, push the fast-forward merge, and delete the remote branch, provided pre-flight checks pass and remote deletion is appropriate for the current state.

Does this branch closing workflow preserve linear history when merging into main?

Yes, this branch closing workflow preserves linear history by performing a fast-forward merge into main after rebasing, ensuring no merge commits are introduced while absorbing unpushed commits from the feature branch.

When should I not use an automated rebase and branch deletion workflow?

You should not use an automated rebase and branch deletion workflow if pre-flight checks fail, if remote branch deletion is inappropriate, or if your environment lacks local main tracking and worktrees required for deterministic git operations.

What pre-flight checks are needed before automating local branch deletion in git?

Pre-flight checks needed before automating local branch deletion verify that the worktree can rebase onto local main cleanly and that the branch is fully merged via fast-forward, ensuring safe detachment of HEAD and branch removal without losing work.