# Finish Development Branch

Decide how to merge, keep or discard a branch once its work is complete.

- Repository: https://github.com/obra/superpowers (310584 stars)
- Category: Git and review
- License: MIT
- Last updated: 2026-10-29
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add obra/superpowers --skill finishing-a-development-branch -g -a claude-code -y`
Codex: `npx skills add obra/superpowers --skill finishing-a-development-branch -g -a codex -y`
Cursor: `npx skills add obra/superpowers --skill finishing-a-development-branch -g -a cursor -y`
Gemini CLI: `npx skills add obra/superpowers --skill finishing-a-development-branch -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add obra/superpowers`

## Description

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Finishing a Development Branch

## Overview

**Core principle:** Verify tests → Detect environment → Present options → Execute choice → Clean up.

**Announce at start:** "I'm using the finishing-a-development-branch skill to complete this work."

## Step 1: Verify Tests

Run the project's full test suite (`npm test` / `cargo test` / `pytest` / `go test ./...`).

**If tests fail**, report the failures and stop, the menu comes after a green suite:

```
Tests failing (<N> failures). Must fix before completing:

[Show failures]
```

**If tests pass:** continue to Step 2.

## Step 2: Detect Environment

```bash
GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
# Capture now, while still inside the workspace, Step 5 changes directory
# before cleanup (Step 6) needs this value
WORKTREE_PATH=$(git rev-parse --show-toplevel)
```

This determines which menu to show and how cleanup works:

| State | Menu | Cleanup |
|-------|------|---------|
| `GIT_DIR == GIT_COMMON` (normal repo) | Standard 3 options | No worktree to clean up |
| `GIT_DIR != GIT_COMMON`, named branch | Standard 3 options | Provenance-based (see Step 6) |
| `GIT_DIR != GIT_COMMON`, detached HEAD | Reduced 2 options (no merge) | Externally managed, leave in place |

## Step 3: Determine Base Branch

The base branch is whatever this work forked from, usually named in the
plan, the conversation, or the branch's upstream. If it is not already
known, ask: "This branch split from <your best guess> - is that correct?"
Confirm before merging: merging into the wrong base is expensive to undo.

## Step 4: Present Options

**Normal repo and named-branch worktree, present exactly these 3 options:**

```
Implementation complete. What would you like to do?

1. Merge back to <base-branch> locally
2. Push and create a Pull Request
3. Keep the branch as-is (I'll handle it later)

Which option?
```

The rest: https://github.com/obra/superpowers/blob/HEAD/skills/finishing-a-development-branch/SKILL.md
