Skip to content
Back to skills

Finishing A Development Branch

ASecurity

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

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 2, 2026
ai-agentsbashgit

Works with

  • cli

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned October 2, 2026

npx -y skills add lsy041015/orchestra --skill finishing-a-development-branch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Finishing A Development Branch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Finishing A Development Branch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lsy041015-finishing-a-development-branch/badge)](https://www.skillsdirectory.com/skills/lsy041015-finishing-a-development-branch)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: finishing-a-development-branch
description: Use when implementation is complete, all tests pass, and you need to decide how to integrate the work
---

# 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

Apply **orchestra:verification-before-completion** to the
state you are about to integrate. Inspect matching evidence for the project's
required checks, including its full suite when required. Run only missing,
invalidated, or still-unverified checks.

**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:** check for uncommitted work, then continue to Step 2.

Workers may leave reviewed changes uncommitted; Codex workers cannot commit
at all. Run `git status --porcelain`. If it lists reviewed task changes, show
them and ask whether to commit them to the feature branch before choosing an
option. Merging or pushing a branch leaves uncommitted work behind.

## 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 (then remove this worktree and branch)
2. Push and create a Pull Request
3. Keep the branch as-is (I'll handle it later)

Which option?
```

**Detached HEAD — present exactly these 2 options:**

```
Implementation complete. You're on a detached HEAD (externally managed workspace).

1. Push as new branch and create a Pull Request
2. Keep as-is (I'll handle it later)

Which option?
```

Present the menu exactly as written — concise, with every option coming
from the list above. Discarding the work happens only in response to your
human partner explicitly asking for it (see `modules/discard.md`). Wait for their answer; the integration decision
is theirs.

## Step 5: Execute Choice

Read only the module for the chosen option. Option 2 and 3 are below.

| Choice | Read |
|---|---|
| Option 1: Merge locally | `modules/merge-locally.md`, then run Step 6 |
| Discard (explicit request only) | `modules/discard.md`, then run Step 6 |

### Option 2: Push and Create PR

```bash
git push -u origin <feature-branch>
# From a detached HEAD, name the new branch on the remote:
# git push origin HEAD:refs/heads/<new-branch>
```

Then create the pull/merge request against <base-branch> with the forge's
tooling — its CLI if one is available, or the creation URL most forges
print when you push — following the repo's PR template and conventions if
present, and report the URL to your human partner.

A rejected push means the remote moved: investigate, and force-push only when
your human partner explicitly asks for it.

Keep the worktree — your human partner iterates on PR feedback there.

### Option 3: Keep As-Is

Report: "Keeping branch <name>. Worktree preserved at <path>."

## Step 6: Cleanup Workspace

Runs for Option 1 and confirmed discards only; Options 2 and 3 always preserve
the worktree. Read `modules/cleanup-workspace.md` and follow it.

Files in this skill

  • SKILL.md4.3 KB
  • agents/openai.yaml149 B
  • modules/cleanup-workspace.md3.7 KB
  • modules/discard.md685 B
  • modules/merge-locally.md1.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…