branch-workflow
/branch-workflow
Clean branch completion workflow — PR creation, merge strategy, and cleanup. Use this skill when implementation is complete and it's time to ship — after Phase 3 human gate passes. Also use when the user says "create a PR", "merge this", "ship it", "finish this branch", or asks about merge strategy.
- Author
- bdfinst ↗
- Repository
- agentic-dev-team ↗
- Licence
- MIT
- Last repository change
- 14.10.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 14.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Clean branch completion workflow — PR creation, merge strategy, and cleanup. Use this skill when implementation is complete and it's time to ship — after Phase 3 human gate passes. Also use when the user says "create a PR", "merge this", "ship it", "finish this branch", or asks about merge strategy.
Triggers from the description
Original author description
Clean branch completion workflow — PR creation, merge strategy, and cleanup. Use this skill when implementation is complete and it's time to ship — after Phase 3 human gate passes. Also use when the user says "create a PR", "merge this", "ship it", "finish this branch", or asks about merge strategy.
How it works
- Overview
- Constraints
- Workflow
- Integration
- Output
SKILL.md preview
---
name: branch-workflow
description: Clean branch completion workflow — PR creation, merge strategy, and cleanup. Use this skill when implementation is complete and it's time to ship — after Phase 3 human gate passes. Also use when the user says "create a PR", "merge this", "ship it", "finish this branch", or asks about merge strategy.
role: worker
user-invocable: true
---
# Branch Workflow
Role: worker. This command performs PR creation, merge, and branch cleanup
directly via git/gh commands.
## Overview
The three-phase workflow ends at the Phase 3 human gate. This skill formalizes what happens after approval: PR creation, merge decision, and branch cleanup. Without this, branches linger and merge conflicts accumulate.
## Constraints
- Do not push to main/master directly — always use a PR
- Do not force-push unless the human explicitly requests it
- Do not delete branches that have unmerged work
- Do not merge without a passing CI check (if CI is configured)
- Do not switch branches (checkout, worktree enter) without first checking working-tree state and confirming with the human if dirty
## Workflow
### 1. Pre-PR Checklist
Before creating the PR, verify:
- [ ] All tests pass (fresh run, not cached)
- [ ] `/code-review` passed or warnings are documented
- [ ] Documentation is current (tech-writer verified in Phase 3)
- [ ] Branch is rebased on latest main (resolve conflicts if needed)
### 2. Create the PR
- Title: concise, under 70 characters, describes the change
- Body: Summary (what and why), test plan, link to design doc if one exists
- Labels: add relevant labels (bug, feature, refactor, docs)
- Reviewers: assign based on who should review (human decides)
### 3. Present Options
After confirming the base branch, present exactly four choices. If this session entered a worktree via `EnterWorktree` for this branch, each option's cleanup step is performed with the paired `ExitWorktree` call below — never raw `git worktree remove`. If no worktree was entered via `EnterWorktree` (branch-workflow can also run directly in the primary checkout), the `ExitWorktree` steps are a no-op — skip them.
1. **Merge locally** — Integrate feature branch into base, run tests on merged result, delete feature branch, then call `ExitWorktree(action="remove")`
2. **Push and create PR** — Push branch and create pull request via `gh pr create`. Once the PR is opened, call `ExitWorktree(action="keep")` so the worktree persists on disk while the session's CWD bookkeeping is closed
3. **Keep as-is** — Preserve branch and worktree for later handling; call `ExitWorktree(action="keep")` immediately after the option is confirmed — do not leave the worktree silently "entered" for the rest of the session
4. **Discard** — Permanently delete branch and all commits. **Requires the human to type "discard" to confirm.** Never discard without typed confirmation. After confirmation, call `ExitWorktree(action="remove", discard_changes=true)`
### 3a. Pre-Switch Verification (Option 1 only)
Before performing the checkout/merge that Option 1 ("Merge locally") requires, verify the working tree is safe to switch:
1. Run a working-tree status check (`git status --short`, or the worktree-tool equivalent) covering the feature branch's tree. This surfaces both tracked changes (modified/staged) and untracked files — not just tracked ones.
2. Show the result to the human.
3. If the tree is clean, proceed with the switch.
4. If the tree is **not** clean (any modified, staged, or untracked files), stop. Do not switch branches silently. Require the human to explicitly say how to proceed — commit, stash, or abort — before running the checkout. This follows the same explicit-confirmation pattern as Option 4's typed "discard," not a bare warning that can be clicked through.
5. Re-check that the target/base branch still matches what was confirmed in step 3's "After confirming the base branch..." — this does not re-ask for that confirmation, only verifies it hasn't drifted since.
This step applies only to the branch/worktree switch Option 1 performs. It does not replace or duplicate the Pre-PR Checklist's "Branch is rebased on latest main" item (§1) — that is a rebase-currency check performed earlier, not a dirty-tree check performed at the moment of switching. It also does not modify Post-Merge Verification & Cleanup (§5), which handles branch/worktree deletion after the merge, not the switch before it.
### 4. Merge Strategy (for options 1 and 2)
| Situation | Strategy | Why |
| ----------- | ---------- | ----- |
| Single logical change, clean history | Squash merge | One commit tells the story |
| Multiple logical changes that should stay separate | Merge commit | Preserves the history of each change |
| Long-lived branch with many commits | Squash merge | Reduces noise in main history |
| Experimental/spike work | Squash merge | The journey doesn't matter, only the result |
Default: **squash merge** unless the human specifies otherwise.
### 5. Post-Merge Verification & Cleanup
- Run tests on the merged result — **do not skip this**. Broken code must never reach base branches.
- Delete the feature branch (remote and local) — only for options 1 and 4
- If a worktree was entered via `EnterWorktree` for this branch, call `ExitWorktree(action="remove")` for options 1 and 4 (never raw `git worktree remove`); options 2 and 3 use `ExitWorktree(action="keep")` as described in Section 3. If no worktree was entered via `EnterWorktree`, this step is a no-op.
- After removal, verify no orphaned worktree or branch remains — e.g. `git worktree list` and `git branch` should show nothing for the deleted branch
## Integration
- Triggered after Phase 3 human gate approval
- PR creation follows the git commit conventions in the project
## Output
A merged PR with clean branch history, closed issues, and deleted feature branch.
Versions
The database has no other skills named branch-workflow.
Database snapshot: 13.11.2026 · package version 58fc2f6094fb (SHA-256 digest of the entire package)
Downloads in the last 30 days: 4 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100finishing-a-development-branch
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup - 86ship
Take a change from a branch to merged and cleaned up - open or update a pull request and see it through review, self-review the branch, merge, clean up after. Use when asked to open or update a PR, review your own branch, merge, or clean up after a task. - 100ywc-finish-branch
(ywc) Use when delivering one completed feature branch to the base branch: PR-ready, CI wait, bot review polling, merge, post-merge verification, task bookkeeping, and local branch cleanup. Triggers: "finish branch", "deliver branch", "ywc-finish-branch", "merge feature branch",… - 90branch-completion
Guides completion of development work by verifying tests, presenting merge/PR/keep/discard options, and executing cleanup. Use this skill when implementation is complete and tests pass, when wrapping up a feature branch, or when deciding how to land or discard work. Do not use… - 90merge
Merge the current feature branch into main and (optionally) clean up the branch and worktree. Prefers fast-forward (--ff-only) for linear history; falls back to a merge commit (--no-ff) when the branch has diverged or the user wants the merge commit preserved. Interactive… - 100ship-it
Code commit, PR creation, merge, and issue closure workflow via GitHub CLI (gh). Triggers after a goal (GitHub Issue) implementation is complete — commit code, push branch, create PR, merge, then close the issue. Use when the user says "提交代码", "commit and merge", "创建PR", "合入",…