---
name: finish-a-feature-branch
description: "Closes out a feature branch safely: confirm tests and base, then choose to merge locally, open a pull request or keep the branch, with no force push. Use when a feature branch is finished and needs to be merged, turned into a pull request or parked safely. Do not use for fixing failing tests or writing the pull request description text. Related topics: coding, devops."
---

# Finish a Feature Branch

Closes out a feature branch safely: confirm tests and base, then choose to merge locally, open a pull request or keep the branch, with no force push.

## When to use

Use this skill when a feature branch is finished and needs to be merged, turned into a pull request or parked safely. Do not use it for fixing failing tests or writing the pull request description text.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Run the test command and stop with a failure report if anything fails.
3. Confirm the base branch from where the branch diverged and check that the working tree is clean.
4. Show the commit list and diff summary that would land so the choice is informed.
5. Carry out the chosen ending within the team workflow, re-running tests after any local merge.
6. State the final result and ask before any step that cannot be undone, never force pushing.

## Inputs

- **Branch name** (free text, e.g. "The feature branch")
- **Base branch** (free text, e.g. "Where it should land")
- **Test command** (free text, e.g. "Command that runs the suite")
- **Team workflow** (choose one: Pull request required, Direct merge allowed, Not sure)
- **Preferred ending** (choose one: Merge locally, Open a pull request, Keep the branch for now)
- **Delete branch after** (choose one: Yes, No)

## Output

A short report of the test result, commits that land, the ending chosen and the exact commands run, with any follow-up left for the user.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### Finish a Feature Branch

Help me wrap up this feature branch.

- Branch name: {{Branch name}}
- Base branch: {{Base branch}}
- Test command: {{Test command}}
- Team workflow: {{Team workflow}}
- Preferred ending: {{Preferred ending}}
- Delete branch after: {{Delete branch after}}

First run the test command and stop if anything fails; report the failures and do not continue. Then confirm the base branch is right by looking at where the branch diverged, and check the working tree is clean. Show the commit list and diff summary that will land. Follow the preferred ending, adjusted for the team workflow: merging locally means updating the base, merging without rewriting shared history, re-running the tests on the result, and only then pushing; a pull request means pushing the branch and preparing the title and description; keeping means leaving it untouched with a note of what remains. Never force push, never rewrite commits that others may have pulled, and ask before any step that cannot be undone.

## Pitfalls

- Merging into the wrong base because the branch was cut from a stale copy.
- Force pushing to tidy history after teammates have already pulled the branch.
- Merging locally and pushing without re-running the tests on the merged result.
