# Finishing A Development Branch

Use when verified work needs integration or cleanup of an existing task-created...

- Repository: https://github.com/GanyuanRan/Aegis (1408 stars)
- Category: Git and review
- License: MIT
- Last updated: 2026-10-25
- Runs scripts: no, instructions only

## Install

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

## Description

Use when verified work needs integration or cleanup of an existing task-created branch/worktree, or the user explicitly requests merge, PR, or branch lifecycle handling.

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

# Finishing a Development Branch

## Overview

Integration choice and checkout lifetime are separate. Verify first, mutate only
task-owned resources, then prove what was removed or retained.

**Core principle:** fresh evidence -> authorized integration -> ownership-aware
cleanup -> Git/path readback.

**Announce at start:** explain which branch/worktree lifecycle is being closed.

## Step 1: Environment and Ownership Detection

Read the task's `TaskStartSnapshot` and current repository state. Record:

- root, `HEAD`, branch/detached state, upstream divergence, and active Git ops;
- staged/unstaged/untracked paths and the task-owned delta;
- `git worktree list --porcelain`;
- branch/worktree creator, task ownership, base branch, and cleanup trigger.

Stop on conflicts, unexplained detached state, failed verification, dirty/untracked state in
a cleanup target, or unknown ownership. Do not infer the base from the names
`main` or `master`; use task records, repository authority, or explicit user
direction. Never auto-stash, reset, clean, pull, rebase, amend, force-push, or
bypass hooks.

For a trusted host-managed detached checkout, follow the repository's approved
managed-workspace contract: verify host binding, default cwd, root, and HEAD;
then use its scoped local-commit and native handoff path. Report detached HEAD
in the receipt. This exception does not authorize automatic deletion of the
detached checkout or bypass unknown ownership/binding.

If no task-created branch/worktree exists and integration was not requested,
skip this workflow: report the local task commit plus `Task clean` and
`Repository clean`; do not invent merge/PR ceremony.

## Step 2: Fresh Verification

Run the smallest current-authority test set that proves the completed task. If
it fails, preserve all work and return to diagnosis. Do not present the branch
as ready.

## Step 3: Choose the Authorized Outcome

When a task branch actually needs disposition, present only applicable choices:

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