Skip to main content
BuildReviewed Aug 31, 2026

Finishing a Development Branch

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.

v1.0.1New

Unsigned, install at your own risk

Unverified

This skill has no cryptographic signature attached. We can't verify the contents match what the publisher intended.

Install this skill

No account required. Pick your tool, or use the command that detects it for you.

Run in your terminal. It detects your AI tool.

npx @skills-hub-ai/cli install aegis-finishing-a-development-branch
Or get the file:
Browse all CLI commands →
Manual setup by platform

Claude Code

~/.claude/skills/aegis-finishing-a-development-branch/SKILL.md

Setup guide →
0Save

Instructions

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:

  1. merge into the recorded base locally;
  2. push and create/update a PR;
  3. keep the branch for later integration;
  4. discard the exact task-owned branch/worktree.

Push, PR, remote deletion, release, and force operations require explicit user
authorization. Discard requires a fresh, exact typed confirmation naming branch,
worktree path, and commits/delta to lose. Generic agreement is insufficient.

Step 4: Execute Without Hidden Mutation

Local merge

Verify the target checkout is safe, switch to the recorded base, merge without an implicit pull,
and rerun verification on the merged result. If integration
or verification fails, preserve both histories and stop.

Push or PR

Push only the authorized task branch and create/update the PR with summary and
fresh test evidence. PR creation does not itself prove merge and does not
require the temporary worktree to remain.

Keep branch

Retain the branch. Remove a clean task-created temporary worktree by default;
retain it only for an explicit ongoing-checkout need and report why.

Discard

After exact confirmation, remove only the named clean task-owned worktree, then
the named branch. If either differs from the confirmation, stop and ask again.

Step 5: Prove Integration Before Branch Deletion

Use evidence matching the merge strategy:

  • merge/fast-forward: prove the task tip is an ancestor of the recorded base;
  • squash/rebase: use fresh PR merge metadata plus strategy-appropriate patch
    equivalence (git cherry for rebased commits; stable patch-id or bounded
    changed-path/tree comparison for squashes), not an ancestor-only test;
  • unmerged/open PR: keep the branch unless discard was exactly confirmed.

Never delete a branch merely because a PR was opened or a similarly named
commit exists.

Step 6: Cleanup in Dependency Order

For a clean task-owned resource:

  1. move to another safe registered checkout; never remove the current working directory;
  2. remove/unregister the worktree first with git worktree remove <exact-path>;
  3. read back git worktree list --porcelain;
  4. verify the exact path no longer exists;
  5. only then delete an integrated or exactly confirmed branch;
  6. read back branch refs, HEAD, and repository status.

Do not use routine --force, global git worktree prune, wildcard deletion, or
cleanup of resources absent from the task ownership record. On Windows, Git may
unregister a worktree while its directory remains locked: re-check registration
and the exact resolved path, remove only a proven task-owned clean residual when
safe, otherwise retain it and report the lock/path. Never widen deletion scope.

Final Git Receipt

Report:

  • current branch and commit SHA/message, or the reason no commit exists;
  • Task clean: yes|no and Repository clean: yes|no independently;
  • branch/worktree created, removed, or retained, with evidence/reason;
  • integration evidence and any remaining user action.

Task clean means no uncommitted task-owned delta remains. Repository clean
means no staged, unstaged, or untracked repository state remains.

This is a local Git receipt, not authoritative completion or merge truth beyond
the evidence read back.

Integration

Called only when branch/worktree integration or explicit lifecycle handling is
in scope. Pairs with using-git-worktrees and
verification-before-completion.

This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

Browse all →

More from Aegis

View source →

More Build skills

Browse category →
senior-frontendBuild and review React, Next.js, TypeScript or Tailwind frontends: components, scaffolding, performance and bundle size. Use whenever the user wants a new component or app, a page feels slow, the bundle is too big, or asks for a frontend code review.650 installsui-design-systemUse when building a design system: tokens, component docs, responsive scales or developer handoff. Generates tokens with design_token_generator.py.550 installsfrontend-designGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.361 installssenior-backendBuild and fix backend services: REST or GraphQL APIs, auth, microservices, PostgreSQL queries, migrations and load tests. Use whenever the user's API is slow or broken, needs login or auth added, a schema change, or a new endpoint or service scaffolded.264 installsself-improving-agentCurate what the agent has learned into durable project knowledge. Reviews Claude Code auto-memory (MEMORY.md and its topic files) for learnings worth keeping, promotes proven ones into CLAUDE.md or .claude/rules/, records a correction as a lesson that persists across sessions, prunes stale or duplicate entries, and turns a recurring fix into a reusable skill. Use whenever the user asks what you have learned or saved about the project, which memories should become permanent rules, to remember a lesson or stop repeating a mistake, or to clean up, audit or check memory health.183 installsusing-superpowersUse when starting any conversation - establishes how to find and use skills, requiring skill invocation before ANY response including clarifying questions147 installs

Frequently asked questions about finishing-a-development-branch

What does the finishing-a-development-branch skill do?

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. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the finishing-a-development-branch skill?

Run `npx @skills-hub-ai/cli install aegis-finishing-a-development-branch` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/aegis-finishing-a-development-branch/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does finishing-a-development-branch work with?

finishing-a-development-branch runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the finishing-a-development-branch skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use finishing-a-development-branch after installing it?

In Claude Code, type `/aegis-finishing-a-development-branch` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the finishing-a-development-branch skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.