finishing-a-branch
Skill1 starsChanged 4 months agoMITView on GitHub
Takes a branch through the transition the user chooses: push, PR, integration, keep, discard, close, or reopen. Use when implementation is complete and its gates are green but the branch choice is unsettled, even without a Git request, or when the user asks to push, integrate, keep, discard, close, or reopen the branch, what to do with this branch, to merge it, to open a PR, or whether we are done here. Skip mid-development checkpoints and an unchanged state whose branch choice is already settled unless a new transition is requested.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- sarmakska/slipstreamtheir own version, first seen May 31, 2026
- c-reichert/flowstatetheir own version, first seen Apr 12, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- c-reichert/flowstate★ 9same name
- sarmakska/slipstream★ 2same name
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 repository40 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- writing-specsSkill
- clarifying-intentSkill
- dispatching-parallel-agentsSkill
- handoffSkill
- mapping-the-codebaseSkill
- prototypingSkill
- using-git-worktreesSkill
- using-sdlc-skillsSkill
- viewing-artifactsSkill
- writing-skillsSkill
- yagniSkill
- release-readinessSkill
- architecture-decisionsSkill
- coding-standardsSkill
- data-modelSkill
- migration-strategySkill
- reviewing-plansSkill
- system-architectureSkill
- ui-ux-designSkill
- writing-plansSkill
- executing-plansSkill
- subagent-driven-developmentSkill
- test-driven-developmentSkill
- complexity-auditSkill
- containing-an-incidentSkill
- debuggingSkill
- diagnosing-a-sessionSkill
- post-mortemSkill
- refactor-architectureSkill
- define-goalsSkill
- feasibility-checkSkill
- scopingSkill
- receiving-code-reviewSkill
- requesting-code-reviewSkill
- security-auditsSkill
- verification-before-completionSkill
- verification-strategySkill
- visual-ui-verificationSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 5 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 26
Run the script and keep its output.
- Very specific: line 54
Read candidate.published. true or null, or a false read from remote-tracking refs not refreshed under current network authority → separate …
- Very specific: line 65
Read references/branch-state.md before preparing the applicable transition descriptor.
- Distinctive: line 87
Never put discard on this menu.
- Distinctive: line 88
Wait for one listed entry.
- Very specific: line 95
Read references/branch-state.md before executing, and execute through it.
- Very specific: line 96
Run the gate on the exact integrated candidate *before* the base advances.
- Distinctive: line 99
Remove an owned worktree only after confirmed integration.
- Distinctive: line 126
Stop. "yes", "go ahead", "get rid of it", a numbered choice → nothing is touched.
- Very specific: line 128
Only after that exact token: rerun with the same --base.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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.
Files
Finishing a Branch
Take a candidate or named PR through one branch transition the user chooses. Green checks and "seems done" authorize no history, remote, discard, or cleanup mutation.
When to use
- Present the permitted choices even without a Git request.
- Skip ordinary mid-development checkpoints;
using-git-worktreesowns those. Skip an unchanged state with an already settled branch choice unless the user requests another transition.
Available scripts
scripts/branch-state.sh— the local git state as JSON, read-only.--helpdocuments its fields and exit codes.
Step 1: Read the state
Run the script and keep its output. Use its numbers verbatim later; never hand-count commits.
bash scripts/branch-state.sh- Identify the requested transition. Explicit keep-as-is, discard, or PR-only close/reopen → apply its identity, ownership, and authority rules below; readiness evidence is not an entry condition for those actions.
- For materialization, publication, or integration, bind the
verification-before-completionevidence and therequesting-code-reviewverdict (shallowself-reviewed: ready, or the required independent review with no blocker) to one candidate identity: the full revision when the script reportsdirty.clean: true, the digest otherwise. Bind the live remote or PR state. - Required readiness verdict missing → keep the requested action pending; offer keep-as-is or obtain the missing review under current authority.
- PR-only close or reopen → record the live PR, head and base refs, retained resources.
- List the resources this task created (branch, worktree, remote ref, PR)
from the
using-git-worktreesworkspace record. Only those may be cleaned up. A task-looking path proves nothing. - For integration, read
base.resolved.false→ resolve it before acting. A direct instruction or the project's contribution rules override the detected default. Check remote freshness yourself; the script does not fetch. Stale, moved, or ambiguous base → no integration. - Read
candidate.published.trueornull, or afalseread from remote-tracking refs not refreshed under current network authority → separate direct permission for each of squash, rebase, amend. Never force-push as repair. After any history change, rerun the script; content moved → back torequesting-code-review. - For PR creation/update, prepare the description from the contribution rules and base-bound template, with evidence obtained. Prepare other actions' applicable fields without inventing a PR.
Step 2: Present the choices
Read
references/branch-state.mdbefore preparing the applicable transition descriptor. A direct instruction or trusted receipt already covers its current targets, action and payload → record that choice and proceed to Step 3. Missing choice → offer only the state-permitted entries, then stop:Branch {{branch}} → {{base}}. Gates: {{summary}}. Review: {{verdict}}. 1. Commit and keep 2. Push the branch 3. Push and open a PR 4. Integrate locally into {{base}} 5. Keep as-is Recommendation: {{least-mutating option meeting the stated delivery intent}} — {{one sentence}}.- Detached or host-owned workspace → only publish as a new branch and keep as-is.
- Existing PR → only the transitions permitted for the PR's state and its policy. Never conflate, retarget, rewrite, delete, or duplicate a PR.
- Never put discard on this menu.
- Wait for one listed entry. Praise, constraints, partial answers, silence, "looks good", an adjacent decision → re-present the menu unchanged.
- Bind the answer to the prepared descriptor. Material target or payload change → show the changed choice; do not reuse approval for the old one.
Step 3: Execute
- Read
references/branch-state.mdbefore executing, and execute through it. - Run the gate on the exact integrated candidate before the base
advances. Failure after the advance =
integrated-regression; follow the reference's recovery. - Remove an owned worktree only after confirmed integration. Leave detached, shared, user-owned, and host-owned resources in place.
- REQUIRED SUB-SKILL: releasable or running artifact → invoke
release-readiness. Canary, deploy, publish, and distribute are its verdict, not this skill's.
Discard is a separate destructive path
Enter only on a direct request. Never offer discard because work looks unwanted.
Rerun
bash scripts/branch-state.shbefore filling the block.base.resolvedfalse → get the base from the user or project, rerun with--base, and fill nothing until it resolves. Then fill it from the output:This will permanently delete: - Branch {{name}} ({{n}} unique commits: {{list}}) - Staged {{n}}, unstaged {{n}}, untracked {{n}} changes - Ignored {{n}}: {{list}} (lost only with a removed worktree; never recoverable) - Worktree {{path}}; remote {{state}}; PR {{state}} Recovery: {{possible | not possible}} Recommendation: {{preserve unless current authority clearly calls for deletion}}. Type `discard {{candidate.id}}` to confirm.- Stop. "yes", "go ahead", "get rid of it", a numbered choice → nothing is touched.
- Only after that exact token: rerun with the same
--base. A changedcandidate.id, a non-zero exit, or nocandidate.idvoids the token. Otherwise close or delete the listed task-owned resources, and nothing else.
Gotchas
- A local-only repository has no resolvable base: its commit counts are
null, not 0, and a block filled from them hides commits. - A tip-only check, a branch's own upstream taken as its base, or stale remote-tracking refs each read pushed history as unpublished.
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.

