finishing-a-development-branch
Skill8 starsChanged 6 months agoMITView on GitHub
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work. Mandates autonomous code review (Step 0) before presenting options. Guides completion of development work by presenting structured options for merge, PR, or cleanup.
- Commits and pushes
187 other projects use a version of this, 97 of them edited.
Adopted by
Most recently taken up by
- DemonDamon/AgenticXedited, first seen Nov 9, 2026
- chrysogonus/power-agentstheir own version, first seen Nov 8, 2026
- roundpilot/superpowers-antigravitytheir own version, first seen Nov 8, 2026
- REPOZY/superpowers-optimizedtheir own version, first seen Nov 8, 2026
- lingyired/status-triotheir own version, first seen Nov 8, 2026
- lhbsaa/apex-unifiededited, first seen Nov 8, 2026
Used with
Projects with it also use chinese-code-review, chinese-commit-conventions and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Leodorareluctant259Skillchinese-code-review
中文代码审查规范——在保持专业严谨的同时,用符合国内团队文化的方式给出有效反馈
Also in 8 projects that use this
Leodorareluctant259Skillchinese-commit-conventions
中文 Git 提交规范 — 适配国内团队的 commit message 规范和 changelog 自动化
Also in 8 projects that use this
obraSkilldiagnosing-superpowers
Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.
Also in 20 projects that use this
kntismSkillcondition-based-waiting
Use when tests have race conditions, timing dependencies, or inconsistent pass/fail behavior - replaces arbitrary timeouts with condition polling to wait for actual state changes, eliminating flaky tests from timing guesses
Also in 3 projects that use this
MicrosoftSkilltesting-anti-patterns
Use when writing or changing tests, adding mocks, or tempted to add test-only methods to production code - prevents testing mock behavior, production pollution with test-only methods, and mocking without understanding dependencies
Also in 4 projects that use this
MicrosoftSkillroot-cause-tracing
Use when errors occur deep in execution and you need to trace back to find the original trigger - systematically traces bugs backward through call stack, adding instrumentation when needed, to identify source of invalid data or incorrect behavior
Also in 5 projects that use this
- +3 more from Leodorareluctant259
Other versions187 projects use a version of this.
Word for word · 0
None found.
Edited · 97
- farm-fe/farm★ 5.6k12% same
- DemonDamon/AgenticX★ 1k19% same
- coco-research/coco★ 79714% same
- koaning/wigglystuff★ 45513% same
- derHaken/SuperAntigravity★ 43920% same
- Ibrahim-3d/conductor-orchestrator-superpowers★ 38113% same
- Ibrahim-3d/orchestrator-supaconductor★ 37813% same
- totvs/engpro-advpl-tlpp-skills★ 16619% same
- haojing8312/WorkClaw★ 14119% same
- ARounder-183/HiFiShifter★ 9319% same
87 more not listed
Wrote their own version · 90
- obra/superpowers★ 314ksame name
- jnMetaCode/superpowers-zh★ 8.4ksame name
- openai/plugins★ 7.8ksame name
- microsoft/FluidFramework★ 4.9ksame name
- lingyired/status-trio★ 1.8ksame name
- GanyuanRan/Aegis★ 1.4ksame name
- pcvelz/superpowers★ 1.3ksame name
- LayneChai/superpowers-dsh★ 150same name
- REPOZY/superpowers-optimized★ 146same name
- The-AIOS/aios★ 105same name
80 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository129 other files it gives its agents.
- AGENTS.mdAGENTS.md
- guidance/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- guidance/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- blast-radius-checkSkill
- brainstormingSkill
- branch-flow-gateSkill
- branch-sync-gateSkill
- codebase-reconSkill
- codeowners-drift-auditSkill
- code-review-batterySkill
- cognitive-complexity-refactoringSkill
- debateSkill
- debug-conductorSkill
- dispatching-parallel-agentsSkill
- domain-buildSkill
- evidence-adjudicatorSkill
- executing-plansSkill
- external-cli-auditSkill
- feature-developmentSkill
- field-rename-verificationSkill
- git-branch-conventionsSkill
- gitlab-cliSkill
- hotfix-charterSkill
- implementation-trackerSkill
- incident-revert-reviewSkill
- infra-config-investigatorSkill
- investigation-stateSkill
- kernel-splitSkill
- llm-behavior-investigatorSkill
- llm-skill-reviewSkill
- merge-authorization-gateSkill
- micro-harsh-reviewSkill
- output-verificationSkill
- pre-commit-gateSkill
- progressive-code-review-gateSkill
- progressive-harsh-reviewSkill
- providing-code-reviewSkill
- pr-triage-gateSkill
- push-authorization-gateSkill
- receiving-code-reviewSkill
- reproduction-experiment-investigatorSkill
- requesting-code-reviewSkill
- requirements-validation-pmSkill
- requirements-validationSkill
- scope-tripwireSkill
- session-handoffSkill
- skills-hierarchy-tuningSkill
- sp-bughuntSkill
- state-consistency-investigatorSkill
- subagent-driven-developmentSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- timeline-trace-investigatorSkill
- token-estimationSkill
- unified-commit-gateSkill
- using-git-worktreesSkill
- using-superpowersSkill
- verification-before-completionSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
11 rules. 0 are common, 5 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 173 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 103
If you skip this step and present work as "ready" to the human, you have violated the gate.
- Distinctive: line 116
If tests fail: Stop. Show failures. Do not proceed to Step 1.5.
- Distinctive: line 133
If git log errors rather than producing empty output, the remote ref does not exist — run git ls-remote origin to inspect the remote's …
- Very specific: line 142
Check for rebase in progress: git rebase --show-current-patch 2>/dev/null && echo REBASE_IN_PROGRESS || echo CLEAN.
- Very specific: line 145
If rebase produced conflicts: resolve them, git add <files>, git rebase --continue, then follow unified-commit-gate § Post-Conflict Trap …
- Very specific: line 153
Prefer the branch's own tracking upstream, then this repo's actual workflow base (dev), then main/master as later fallbacks -- falling back …
- Very specific: line 176
If any candidate returns a SHA, use that branch as the base.
- Very specific: line 202
Run tools/branch-flow-preflight.sh <branch> <base-branch> to validate the (source, target) pair against the canonical flow and write …
- Very specific: line 204
Create the PR: gh pr create --fill (--fill pre-fills title/body from commits.
- Distinctive: line 207
Keep the worktree: review fixes land there.
- Distinctive: line 243
issue-verify: Verify an issue identifier before citing it in a branch, commit, or PR
“Common” is measured: kept by at least 6 in 10 of the 173 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Wrong skill? Quick pre-commit check →
unified-commit-gate. Presenting results mid-work →verification-before-completion. Reviewing someone's PR →providing-code-review.
Finishing a Development Branch
When to Use
Invoke when development work on a branch is complete and ready to review, commit, or ship.
Overview
Guide completion of development work by presenting clear options and handling chosen workflow.
Core principle: Autonomous code review → Verify tests → Present options → Execute choice → Clean up.
Announce at start: "I'm using the finishing-a-development-branch skill to complete this work."
The Process
🔴 Step 0: Autonomous Code Review (NON-NEGOTIABLE)
Before verifying tests, before presenting options — check the sentinel, then run battery if needed.
First, run the code-review-battery Phase 0 sentinel check:
SENTINEL="$(git rev-parse --show-toplevel 2>/dev/null || echo .)/.code-review-cleared"
cat "$SENTINEL" 2>/dev/null || echo "NO CLEARANCE"
echo "HEAD: $(git rev-parse HEAD 2>/dev/null)"
git diff --quiet && git diff --cached --quiet && echo "WORKTREE_CLEAN" || echo "WORKTREE_DIRTY"Then, regardless of sentinel state, enumerate which .md files were changed via the canonical helper, then split the result into PHR-eligible vs. llm-skill-review-owned (skills/*.md, .ai-guidance/*.md, and any AGENTS.md-family file — AGENTS.md/CLAUDE.md/GEMINI.md/CODEX.md/COPILOT.md/AGENT.md, at any path depth; see tools/md-files-changed.sh's LLM_OWNED_REGEX for the single source of truth on this boundary — owned exclusively by llm-skill-review, not PHR):
# Exit 0 → files listed on stdout; exit 1 → no PHR-relevant files; exit 2 → NO_BASE_FOUND.
MD_HITS="$(tools/md-files-changed.sh)"; MD_STATUS=$?
case $MD_STATUS in
0)
LLM_OWNED_MD=$(tools/md-files-changed.sh --files "$MD_HITS" --llm-owned 2>/dev/null || true)
DESIGN_MD=$(tools/md-files-changed.sh --files "$MD_HITS" --exclude-llm-owned 2>/dev/null || true)
[[ -n "$DESIGN_MD" ]] && echo ">>> PHR REQUIRED for: $DESIGN_MD"
[[ -n "$LLM_OWNED_MD" ]] && echo ">>> LLM-SKILL-REVIEW REQUIRED for: $LLM_OWNED_MD"
;;
1) echo "NO_MD_FILES_CHANGED" ;;
2) echo "NO_BASE_FOUND — cannot determine diff scope; review the full branch manually" ;;
esacThe helper is the single source of truth for the PHR-trigger regex, the exclusions (README.md, CHANGELOG.md), and the PHR-vs-llm-skill-review ownership split (--llm-owned / --exclude-llm-owned); tools/run-battery.sh consumes the same script. If exit code is 2 (NO_BASE_FOUND), treat both gates as required by default and review the full branch manually.
| Result | Action |
Valid sentinel for HEAD AND WORKTREE_CLEAN AND md-file check → NO_MD_FILES_CHANGED | Battery evidence confirmed. Proceed directly to Step 1. |
Valid sentinel for HEAD AND WORKTREE_CLEAN AND md-file check lists design (PHR-owned) files | Battery passed. Also invoke PHR (/sp-phr) on the listed files before Step 1 — see below. |
Valid sentinel for HEAD AND WORKTREE_CLEAN AND md-file check lists llm-skill-review-owned files | Battery passed (PHR-owned portion only, if any). Invoke llm-skill-review on the listed files instead of PHR — it supersedes, not supplements, PHR for that file class. |
| Any other result | Dispatch code-review-battery (via sub-agent-code-reviewer). Fix all Critical and Important findings. Re-dispatch if fixes were made. Only proceed when the battery verdict is PASS or PASS_WITH_NITS. Then re-run the md-file check above and apply the rows above (PHR for design files, llm-skill-review for llm-owned files). |
PHR is mandatory when the md-file check lists any non-llm-owned .md files. llm-skill-review-owned files (skills/*.md, .ai-guidance/*.md, AGENTS.md-family) require llm-skill-review instead — never both for the same file. A push touching both file classes (e.g. a docs/architecture.md change alongside a skills/x/skill.md change) still needs both sentinels, one per file class.
Scope (PHR-owned, i.e. the --exclude-llm-owned subset): any .md file under docs/, plus repo-root .md files whose names start with an uppercase letter (e.g., DESIGN.md, ARCHITECTURE.md) that are NOT one of the AGENTS.md-family basenames. Excludes: CHANGELOG.md, README.md (excluded by the post-grep grep -vE filter, not by the main regex — the main regex matches them), and everything llm-skill-review owns (skills/*.md, .ai-guidance/*.md, AGENTS.md-family — routed to llm-skill-review instead, per the split above).
The battery runs automated linting and tests — it does NOT run PHR or llm-skill-review. Invoke progressive-harsh-review (/sp-phr) for design .md files, or llm-skill-review for skills/*.md, .ai-guidance/*.md, or AGENTS.md-family files, before proceeding to Step 1. A passing battery sentinel is NOT a substitute for either.
Why separate?
run-battery.shcallsharsh-review.sh(a shell linter), not the multi-persona PHR/llm-skill-review skills. Those are AI judgment gates; the battery is an automated script gate. Both an AI judgment gate (PHR or llm-skill-review, whichever applies) and the battery are required for design/skill changes — but never both AI gates for the same file.
If you skip this step and present work as "ready" to the human, you have violated the gate.
Why this step exists: See the 2026-04-02 incident in verification-before-completion Incident History.
Step 1: Verify Tests
After Step 0 passes, verify tests pass:
# Run project's test suite
npm test / cargo test / pytest / go test ./...If tests fail: Stop. Show failures. Do not proceed to Step 1.5.
If tests pass: Continue to Step 1.5.
Step 1.5: Verify Branch Base — HARD STOP
Before presenting options, verify the branch is not behind origin/main.
Assumption: This step assumes
origin/mainis the integration branch. If the branch targets a different base (feature branch, release branch), setBASE_REFto the correct remote ref (e.g.,origin/dev,origin/release-X). Use the sameBASE_REFin the recovery rebase below. If the repo uses a fork model with separateorigin/upstreamremotes, substitute accordingly.
BASE_REF="origin/main" # ← substitute if branch targets a different remote
FORCE_PUSH_REQUIRED=false # default; overridden in recovery steps if a rebase occurs
git fetch origin || { echo "FETCH FAILED — cannot verify branch base. Do not proceed."; false; }
git log --oneline "HEAD..${BASE_REF}"If git log errors rather than producing empty output, the remote ref does not exist — run git ls-remote origin to inspect the remote's branch list before proceeding.
| Result | Action |
| Empty output | Branch is current. Proceed to Step 2. |
| Any commits listed | HARD STOP — (do not open or update any PR until recovery completes) — see recovery steps below. |
Recovery when branch is behind origin/main (track attempt number using ATTEMPT_FILE="$(git rev-parse --git-common-dir)/rebase-attempt-count"; read with cat "$ATTEMPT_FILE" 2>/dev/null || echo 0; if absent this is attempt 1; write echo 1 > "$ATTEMPT_FILE" or echo 2 > "$ATTEMPT_FILE"; using --git-common-dir works in worktrees):
- Check for rebase in progress:
git rebase --show-current-patch 2>/dev/null && echo REBASE_IN_PROGRESS || echo CLEAN. IfREBASE_IN_PROGRESS, ask human to confirm abort before runninggit rebase --abort. - Capture stash state:
git status --short. If uncommitted changes exist, rungit stash push -m "pre-rebase WIP" && STASHED=true || { echo "STASH FAILED — manual intervention required."; STASHED=false; return 1; }. If clean, noteSTASHED=false— do not rungit stash poplater. - Detect force-push requirement:
git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null && echo FORCE_PUSH_REQUIRED=true || echo FORCE_PUSH_REQUIRED=false. Then rebase:git rebase "${BASE_REF:-origin/main}". IfFORCE_PUSH_REQUIRED=true, push will need--force-with-lease; confirm with human at Step 4 "Push and create PR". - If rebase produced conflicts: resolve them,
git add <files>,git rebase --continue, then followunified-commit-gate § Post-Conflict Trap(typecheck → lint → test). If no conflicts: proceed to step 5. - Restore stash (only if
STASHED=trueand rebase complete):git stash pop. If conflicts, resolve then re-run typecheck → lint → test. - Re-run Step 0 (rebase rewrites HEAD, sentinel stale), re-run Step 1 (tests), then re-run Step 1.5. If clean, run
rm -f "$ATTEMPT_FILE". If this was attempt 2 and Step 1.5 still shows commits: escalate to human — do not run a third rebase.
Why this step exists: A prior production incident occurred when a branch was cut before a revert landed on main. No branch-base check was run before pushing. Conflicts appeared only in the remote MR diff, requiring multi-session destructive rebasing and a lost typecheck that left a broken build in CI.
Step 2: Determine Base Branch
Prefer the branch's own tracking upstream, then this repo's actual workflow
base (dev), then main/master as later fallbacks -- falling
back straight to main first (as an earlier version of this step did) picks
a base that can be many commits behind dev on repos where dev is the
real integration branch, producing a wrong "what changed" diff. The exact
candidate order below is a verbatim match of tools/md-files-changed.sh's
resolve_base(), which this repo's own PHR-eligibility check already
relies on for the identical problem (see also
tools/lib/pre-push-diff-range.sh's resolve_push_base_ref(), a related
but remote-qualified superset used by the pre-push hook itself).
tracking="$(git rev-parse --abbrev-ref '@{upstream}' 2>/dev/null || true)"
for candidate in "$tracking" origin/dev dev origin/main main origin/master master; do
[[ -n "$candidate" ]] || continue
git rev-parse --verify "$candidate" >/dev/null 2>&1 || continue
if merge_base=$(git merge-base HEAD "$candidate" 2>/dev/null); then
echo "$merge_base"
break
fi
doneIf any candidate returns a SHA, use that branch as the base. If all fail, the branch has no recognizable integration ancestor — surface this explicitly: "Could not determine base branch automatically (no tracking/dev/main/master ancestor found). What branch did this work split from?"
Step 3: Present Options
Capture the worktree state first — see references/worktree-cleanup.md for the exact commands and why order matters. A detached HEAD (git branch --show-current empty) in a linked worktree is an externally managed workspace. Present exactly one menu, as written:
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?Detached HEAD: say "You're on a detached HEAD (externally managed workspace)" and offer only the PR and keep-as-is options, numbered 1-2 — no merge, the host owns the workspace. Discarding is never a menu item; it exists only when the user explicitly asks to throw the work away (see Discard on request). Wait for their answer.
Step 4: Execute Choice
Handlers are keyed by the option's label, not its number (the detached menu numbers differently).
Merge locally: move to the main repo root (linked worktree: git -C "$GIT_COMMON/.." rev-parse --show-toplevel; normal checkout or submodule: stay in the current toplevel) → checkout base → pull → merge → run tests on the result (fail: stop, keep branch and worktree, report) → clean up the worktree (Step 5) → delete the merged branch.
Push and create PR:
- Run
tools/branch-flow-preflight.sh <branch> <base-branch>to validate the (source, target) pair against the canonical flow and write.branch-flow-cleared. The pre-push hook reads this sentinel and refuses pushes to dev/main without it. On a detached HEAD,<branch>is a new name you propose (per git-branch-conventions). - Push the branch (detached HEAD:
git push -u origin HEAD:refs/heads/<branch>).unified-commit-gate(push mode) fires before push. - Create the PR:
gh pr create --fill(--fillpre-fills title/body from commits; override with--title/--body). If the work has an issue identifier (per git-branch-conventions' "Before Naming the Branch"), the title should include it, matching branch/commit. - GitHub auto-links AND auto-closes an issue if the PR body contains
Fixes #123orCloses #123and the PR merges into the repo's default branch (not just any branch) — confirm that's actually intended before using that phrasing; a plain reference (#123) links without closing. If citing an issue, verify it resolves viaissue-verifyfirst — never construct the reference from memory. gh pr edithas a body-replacement footgun when adding a link after the fact — seeexternal-cli-audit's CLI Default Hazards table.- Keep the worktree: review fixes land there.
Keep as-is: Report status. Keep worktree.
Discard on request (only after an explicit request): list the branch, its commits (git log --oneline <base>..HEAD), and the worktree path; require the typed word "discard". Then move to the main repo root, clean up the worktree (Step 5), and force-delete the branch.
Step 5: Cleanup Worktree
For merge-locally and a confirmed discard — using the values captured in Step 3, per references/worktree-cleanup.md. PR and keep-as-is preserve the worktree.
Anti-Patterns
| Wrong | Right |
| Presenting options without completing Step 0 | Review first, options second |
| Skipping test verification because review passed | Review ≠ tests. Both required. |
| Open-ended "What should I do next?" | Present exactly the structured menu for this state |
| Listing "Discard" in the menu, or cleaning up after a PR | Discard only on explicit request; clean up only after merge or confirmed discard |
| Deleting work without confirmation | Require the typed word "discard" |
| Citing an issue reference in a PR body without verifying it resolves | Verify via issue-verify before citing; never build the reference from memory |
Red Flags
- Presenting work as "ready" without completing Step 0
- Proceeding with failing tests
- Force-pushing without explicit request
- Merging without verifying tests on result
--force-removing a worktree that refused removal — seereferences/worktree-cleanup.md
Companion Skills
- code-review-battery: The review engine Step 0 dispatches
- progressive-code-review-gate: Verdict mapping and dispatch procedure
- verification-before-completion: Fires before this skill (completion-gate order 2)
- unified-commit-gate (push mode): Fires when "Push and create PR" triggers a push; § Post-Conflict Trap mandates typecheck after rebase/stash-pop conflicts
- subagent-driven-development: Calls this skill after all tasks complete
- issue-verify: Verify an issue identifier before citing it in a branch, commit, or PR
- external-cli-audit: CLI default hazards (e.g.
gh pr edit's body-replacement behavior) referenced from "Push and create PR"
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
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.

