finishing-a-development-branch
Skill8 starsChanged 7 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
123 other projects use a version of this, 76 of them edited.
Adopted by
Most recently taken up by
- andreymudri/fleetmatestheir own version, first seen Oct 5, 2026
- LayneChai/superpowers-dshtheir own version, first seen Oct 3, 2026
- HanksChen0110/skillstheir own version, first seen Oct 3, 2026
- JameMy0001/antigravity-skills-hubtheir own version, first seen Oct 2, 2026
- lsy041015/orchestraedited, first seen Oct 2, 2026
- Wenaixi/dsh-superpowertheir own version, first seen Oct 1, 2026
Used with
Projects with it also use diagnosing-superpowers, testing-anti-patterns 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.
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 6 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 5 projects that use this
MorningStar0709Skillchinese-git-workflow
Configure Git for domestic platforms and manage branching strategies suitable for Chinese teams. Use when the user asks to configure remotes, set up SSH, or manage Git workflows for Gitee, Coding, Jihu GitLab, or CNB, including requests like "配置国内 Git", "设置 Gitee 远程仓库", "推荐适合小团队的 Git 流程".
Also in 4 projects that use this
shibit-netSkillchinese-code-review
中文 review 沟通参考——话术模板、分级标注(必须修复/建议修改/仅供参考)、国内团队常见反模式应对。仅在用户显式 /chinese-code-review 时调用,不要根据上下文自动触发。
Also in 3 projects that use this
shibit-netSkillchinese-commit-conventions
中文 commit 与 changelog 配置参考——Conventional Commits 中文适配、commitlint/husky/commitizen 中文模板、conventional-changelog 中文配置。仅在用户显式 /chinese-commit-conventions 时调用,不要根据上下文自动触发。
Also in 3 projects that use this
MorningStar0709Skillworkflow-runner
Run an agency-orchestrator style YAML workflow inside the current Trae conversation by simulating or coordinating multiple roles. Use when the user provides a `.yaml` or `.yml` workflow, asks for multi-role collaboration, says things like “用多个角色一起评审这个 PRD”“多角色协作”“先生成工作流再执行”“让产品经理、架构师、QA 一起看一下”, or wants roles such as product manager, architect, reviewer, or QA to work together. Supports layered execution, role prompting, variable interpolation, document-backed inputs, and parallel steps only when the current environment has a clear subagent mapping. Do not use for ordinary implementation plans, simple code changes, or tasks already covered by `writing-plans`, `executing-plans`, `subagent-driven-development`, or single-purpose review/debug skills.
Also in 4 projects that use this
- +1 more from shibit-net
Other versions123 projects use a version of this.
Word for word · 0
None found.
Edited · 76
- coco-research/coco★ 43719% same
- Ibrahim-3d/orchestrator-supaconductor★ 38016% same
- totvs/engpro-advpl-tlpp-skills★ 13824% same
- Houseofmvps/ultraship★ 12324% same
- coctostan/pi-superpowers★ 7023% same
- roman01la/skills-agents★ 4824% same
- LeoKemp223/ai-light★ 4214% same
- myths-labs/muse★ 3524% same
- VoDaiLocz/kilo-kit-mcp★ 2724% same
- CodingCossack/agent-skills-library★ 1910% same
66 more not listed
Wrote their own version · 47
- obra/superpowers★ 314ksame name
- jnMetaCode/superpowers-zh★ 8.3ksame name
- openai/plugins★ 7.3ksame name
- microsoft/FluidFramework★ 4.9ksame name
- GanyuanRan/Aegis★ 1.3ksame name
- LayneChai/superpowers-dsh★ 102same name
- shibit-net/xuanji-community★ 93same name
- withzombies/hyperpowers★ 80same name
- roundpilot/superpowers-antigravity★ 70same name
- The-AIOS/aios★ 69same name
37 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 repository128 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
- 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
- experimental-self-promptingSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
10 rules. 0 are common, 4 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 114 edited versions we read keep these.
4
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 201
Run tools/branch-flow-preflight.sh <current-branch> <base-branch> to validate the (source, target) pair against the canonical flow and …
- Very specific: line 203
Create the PR: gh pr create --fill (--fill pre-fills title/body from commits.
- Distinctive: line 242
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 114 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 Option 2. - 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
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?Step 4: Execute Choice
Capture the worktree state before any option below cd's away — see references/worktree-cleanup.md for the exact commands and why order matters.
Option 1 (Merge locally): Checkout base → pull → merge → verify tests on result → delete branch → cleanup worktree (using $WORKTREE_PATH).
Option 2 (Push and create PR):
- Run
tools/branch-flow-preflight.sh <current-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. - Push the 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.- Cleanup the worktree per Step 5: Cleanup Worktree below.
Option 3 (Keep as-is): Report status. Keep worktree.
Option 4 (Discard): Confirm first (require typed "discard"). Then delete branch and cleanup worktree (using $WORKTREE_PATH).
Step 5: Cleanup Worktree
For Options 1, 2, 4 — using the values captured in Step 4, per references/worktree-cleanup.md. For Option 3 — keep worktree, skip this step.
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 4 structured options |
| Auto-cleanup worktree for Option 3 | Only cleanup for Options 1, 2, and 4 |
| Deleting work without confirmation | Require typed "discard" for Option 4 |
| 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 Option 2 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 Option 2
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.

