agentleFS
christopherarterchristopherarter/superpowers-reasonix/skills/superpowers-finishing-a-development-branch/SKILL.md

superpowers-finishing-a-development-branch

Skill101 starsChanged 31 days agoMITView on GitHub

Branch finished, tests green? Load first to merge, PR, or clean up.

  • Commits and pushes

1 other project uses a version of this, 1 of them edited.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Core principle: Verify tests → detect environment → present options → execute choice → clean up.

    line 12
  2. Distinctive:

    Don't add explanation: Keep options concise.

    line 79
  3. Very specific:

    After merge succeeds: cleanup worktree (Step 6), then git branch -d <feature-branch>.

    line 94
  4. Very specific:

    Always: verify tests before options.

    line 181

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Finishing a Development Branch

Overview

Present clear options. Handle chosen workflow.

Core principle: Verify tests → detect environment → present options → execute choice → clean up.

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

The Process

Step 1: Verify Tests

Verify tests pass before options (use superpowers-verification-before-completion):

npm test / cargo test / pytest / go test ./...

Tests fail: report failures. Cannot merge/PR until they pass. Stop. Tests pass: continue.

Step 2: Detect Environment

Capture all three up front, before any later step changes directory — WORKTREE_PATH must reflect where you are now, not after Step 5 has cd'd to the main repo root:

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)
WORKTREE_PATH=$(git rev-parse --show-toplevel)
StateMenuCleanup
GIT_DIR == GIT_COMMON (normal repo)Standard 4 optionsNo worktree to clean up
GIT_DIR != GIT_COMMON, named branchStandard 4 optionsProvenance-based (Step 6)
GIT_DIR != GIT_COMMON, detached HEADReduced 3 options (no merge)No cleanup (externally managed)

Step 3: Determine Base Branch

git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null

Or ask: "Branch split from main — correct?"

Step 4: Present Options

Normal repo or named-branch worktree — present exactly these 4 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)
4. Discard this work

Which option?

Detached HEAD — present exactly these 3 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)
3. Discard this work

Which option?

Don't add explanation. Keep options concise.

Step 5: Execute Choice

Option 1: Merge Locally

MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel)
cd "$MAIN_ROOT"
git checkout <base-branch>
git pull
git merge <feature-branch>
<test command>   # Verify tests on merged result

After merge succeeds: cleanup worktree (Step 6), then git branch -d <feature-branch>.

Option 2: Push and Create PR

git push -u origin <feature-branch>
gh pr create --title "<title>" --body "$(cat <<'EOF'
## Summary
<2-3 bullets of what changed>

## Test Plan
- [ ] <verification steps>
EOF
)"

Do NOT clean up the worktree — needed alive for PR feedback.

Option 3: Keep As-Is

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

Option 4: Discard

Confirm first — require typed discard:

This will permanently delete:
- Branch <name>
- All commits: <commit-list>
- Worktree at <path>

Type 'discard' to confirm.

Confirmed: cd to main repo root, cleanup worktree (Step 6), then git branch -D <feature-branch>.

Step 6: Cleanup Workspace

Runs for Options 1 and 4 only. Options 2 and 3 preserve worktree.

Reuse the GIT_DIR, GIT_COMMON, and WORKTREE_PATH captured in Step 2 — do NOT recompute them here. Step 5 (Options 1 and 4) has already cd'd to the main repo root, so a fresh git rev-parse --show-toplevel would return the main repo, not the worktree, and remove the wrong path. Removal must run from outside the worktree.

If GIT_DIR == GIT_COMMON: normal repo, nothing to clean up.

If WORKTREE_PATH under .worktrees/, worktrees/, or ~/.config/reasonix/worktrees/: we created it — we own cleanup:

git worktree remove "$WORKTREE_PATH"
git worktree prune

If removal is refused (contains modified or untracked files): worktree holds files that exist nowhere else — uncommitted plans, notes, scratch work. Never --force on your own initiative. Show the user what's at stake and ask:

git -C "$WORKTREE_PATH" status --porcelain -uall
Worktree removal refused — these files were never committed:

<file list>

1. Commit them to <branch> before cleanup
2. Move them into <main repo root>
3. Delete them (unrecoverable)

Which?

Carry out the choice, then remove the worktree.

Otherwise: harness owns workspace. Do NOT remove it. Workspace-exit tool available? Use it. Else leave in place.

Quick Reference

OptionMergePushKeep WorktreeCleanup Branch
1. Merge locallyyes--yes
2. Create PR-yesyes-
3. Keep as-is--yes-
4. Discard---yes (force)

Red Flags

Never: proceed on failing tests; merge without verifying tests on result; delete work without typed confirmation; force-push without explicit request; remove worktree before merge confirmed; clean up worktrees you didn't create; git worktree remove from inside the worktree; treat a removal-refused error as "just add --force" — it means files exist only there, so show the user and ask.

Always: verify tests before options; detect environment before menu; present exactly 4 options (3 detached HEAD); typed confirmation for Option 4; clean up worktree for Options 1 & 4 only; cd to main repo root before removal; git worktree prune after.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.