Finishing a development branch
Skill GoCodeAlone/autonomous-dev-kit/skills/finishing-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 cleanupFrom its SKILL.md
npx -y skills add GoCodeAlone/autonomous-dev-kit --skill finishing-a-development-branchAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
13.7 KB, as published. Nobody here has run it
Condensed format: load
autodev:condensed-pipeline-writingto expand shorthand.
Finishing a Development Branch
Overview
Guide completion of development work by presenting clear options and handling chosen workflow.
Core principle: Verify tests → Present options → Execute choice → Clean up.
Announce at start: "I'm using the finishing-a-development-branch skill to complete this work."
Autonomous Mode
When running in the autonomous pipeline (invoked from subagent-driven-development in autonomous mode):
- Verify tests pass — same as manual mode, abort if failing
- Run Step 1d (Scope Completeness Check) — see below. This is a mandatory gate in autonomous mode. The agent MUST NOT silently collapse N planned PRs into 1, nor declare success on a partial scope. If Step 1d surfaces a failure, the autonomous pipeline halts and asks the user.
- Run Step 1e (Doc-Reconciliation Check) — conditional on the diff containing a design/reference doc or example artifact. See below.
- Skip option presentation — go directly to PR creation
- For every PR row in the manifest's PR Grouping table, create one PR. The manifest is the contract. If the table has 3 rows, the autonomous run produces 3 PRs, each pointing at the branch named in the row. Do NOT collapse rows — collapsing is the exact failure mode
skills/scope-lock/SKILL.mddefends against. Per-PR steps:feature_branch="<feature-branch>" feature_name="<feature-name>" # Validate that branch and feature names contain only safe characters case "$feature_branch" in (*[!A-Za-z0-9._/-]*|'') echo "Error: invalid feature branch name: $feature_branch" >&2 exit 1 ;; esac case "$feature_name" in (*[!A-Za-z0-9 ._/-]*|'') echo "Error: invalid feature name: $feature_name" >&2 exit 1 ;; esac git push -u origin "$feature_branch" gh pr create --title "$feature_name" --body "$(cat <<'EOF' ## Summary <generated from plan tasks and their completion status> ## Design See: docs/plans/YYYY-MM-DD-<topic>-design.md ## Implementation Plan See: docs/plans/YYYY-MM-DD-<feature>.md ## Scope Manifest <copy the **PR Count**, **Tasks**, **Status** lines + this PR's row from the PR Grouping table> ## Changes <per-task summary of what was implemented> Generated by the implementing agent. EOF )" - Invoke pr-monitoring — spawn a background monitor for all PRs created in this session; prefer a single agent covering all PRs to avoid GitHub API rate limits, but one agent per PR is acceptable if the PRs are on unrelated codebases or a previous shared monitor was rate-limited
- Report PR URLs — output every PR link for the user (one per row in the manifest's PR Grouping table)
Do NOT:
- Present the 4-option menu in autonomous mode
- Ask for user confirmation
- Wait for user input
The Process
Step 1: Verify Tests
Before presenting options, verify tests pass:
# Run project's test suite
npm test / cargo test / pytest / go test ./...
If tests fail:
Tests failing (<N> failures). Must fix before completing:
[Show failures]
Cannot proceed with merge/PR until tests pass.
Stop. Don't proceed to Step 2.
If tests pass: Continue to Step 1b.
Step 1b: Runtime Launch Validation (conditional)
Trigger: the diff includes any of:
- Build configuration (Dockerfile, build script, CI build steps)
- Deployment configuration (compose, Kubernetes manifests, deployment workflows)
- Version pins on runtime, libraries, or build/launch-affecting tooling (images, CI build tools, language runtimes) — excludes dev-only tooling such as linters and formatters
- Application-startup configuration (config files read at boot)
- Database migrations
- Plugin / extension loading paths
If triggered: invoke skills/runtime-launch-validation/SKILL.md. Build and launch the artifact under production-equivalent conditions, run the failure-signature scrape, capture the transcript, paste it into the PR body.
Before pasting any transcript or command into a PR body, redact secret values.
Never include a live token, API key, cookie, password, or bearer credential in
PR metadata. Replace inline secret assignments with placeholders such as
GITHUB_TOKEN=<redacted> or with the secret name only, for example
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}.
If NOT triggered (pure logic refactor, doc-only, test-only): skip this step.
The launch transcript is required in the PR body when this step triggers. Without it, the PR is not ready for merge — even if all unit tests pass.
Demonstration artifacts: if the change ships any demo/example/showcase/quickstart artifact (in this diff or the PR body), autodev:demonstration-fidelity applies — confirm the demo executes the real artifact (no reimplementation, hard-coded output, or different-language fake) before merge.
Step 1c: Version-Skew Audit (conditional)
Trigger: the diff updates a non-dev-only version pin (any "version: vX.Y.Z", "image: foo:vX.Y.Z", or <package>@vX.Y.Z) — excludes dev-only tooling pins (linters, formatters) where skew is generally benign.
Action:
- Grep the repo for related pins (other versions of the same component, sibling tooling, components in the same release group).
- For each related pin, compare lag.
- If lag is >2 minor versions, flag in PR body:
Version skew detected: pinned [email protected] while related [email protected] (4 minor versions ahead). Compatibility verified via: <link or note>. - Resolve before merging — bump the lagging pin, OR state explicitly why the skew is intentional and safe.
If NOT triggered: skip this step and continue to Step 1d.
Step 1d: Scope Completeness Check (mandatory)
Trigger: always. This step is the gate that prevents the agent from declaring victory on a partial-scope solution.
Action:
- Identify the plan:
docs/plans/YYYY-MM-DD-<feature>.md. If there is no plan indocs/plans/for this branch (manual/ad-hoc work), skip this step. - Run
bash tests/plan-scope-check.sh --plan <plan-path> --verify-lock <plan-path>. The script verifies the manifest is well-formed and the locked hash still matches. - For every
### Task N:heading in the plan body, verify that a commit on the feature branch implements that task. Use the task's**Files:**block (Create:/Modify:/Test:) to map files to the task;git log --oneline <base>..HEAD -- <file>should show at least one commit per task. - Compute the actual PR count for autonomous mode: count distinct branches in the manifest's PR Grouping
Branchcolumn that have commits ahead of base. This must equal**PR Count:**in the manifest.
On any failure of Step 1d:
- Missing tasks: stop. Do NOT create any PR. Report exactly which task(s) have no implementing commits, and ask the user one of:
Tasks <list> have no implementing commits on this branch. Options:
- Implement the missing tasks (preferred).
- Approve a scope amendment — I will invoke
recording-decisionsto write an ADR, backport the design if needed, update the manifest, then re-runalignment-checkagainst the amended design+plan. - Abort the PR creation; keep the branch as-is for inspection.
Which option?
- PR count mismatch (autonomous mode): if the manifest expects N PRs but the branch layout produced fewer, the agent must split the branch via
git rebase --ontoper the manifest's grouping table — NOT collapse the manifest. Collapsing N planned PRs into 1 is exactly the failure modescope-lockexists to prevent. - Locked-hash mismatch: the manifest has been edited after the lock. Surface the diff and stop. The user must either revert the edit or go through the amendment path (
recording-decisions+ re-run alignment-check).
Do not proceed past Step 1d on any failure without explicit user direction. There is no "demo mode" — see the anti-patterns in skills/scope-lock/SKILL.md. Continue to Step 1e.
Step 1e: Doc-Reconciliation Check
Trigger: the PR's diff commits a design doc, reference/standards doc, or example artifact that describes the feature's behavior. Skip for code-only / test-only diffs. (A doc with no corresponding docs/plans/ design/plan trivially passes clean.)
For each such committed doc/example, verify:
- (a) Scope (forward-ref, #71): every behavior/identifier it describes is in this PR's manifest scope, OR explicitly labeled
Planned (PR #N)/Planned — later PR. Unlabeled forward references = finding → label them or move the prose to the later PR. - (b) Identifier drift (#72): concrete identifiers (config keys, flags, env vars, command invocations, DDL/code snippets, format strings) match the identifiers the code on this branch actually uses + the repo's naming convention. Mismatch = finding → reconcile the doc to the built code.
This is a checklist gate (read the diff, grep identifiers), not an automated scanner. On a finding in autonomous mode, fix the doc in-branch before PR (in-scope doc edit, no manifest change). Distinct from scope-lock's assumption-backport (which is for disproved assumptions) — this is routine accuracy reconciliation.
Accountability token: emit one line into the PR body — Doc-reconciliation: clean or Doc-reconciliation: N item(s) fixed — <summary> — so pr-monitoring, the human reviewer, and post-merge-retrospective (Step 5 missed-activation row) can confirm the gate ran without a script.
Continue to Step 2.
Step 1f: PR Body Secret Hygiene
Trigger: always before PR creation or PR body update.
Action:
- Inspect the complete PR body text before sending it to GitHub.
- Reject any live secret literal, including GitHub token prefixes such as
ghp_,gho_,ghu_,ghs_,ghr_,github_pat_, bearer tokens, cookies, orNAME=<secret-value>command examples. - Rewrite verification commands to show placeholders or secret names, not
values:
GITHUB_TOKEN=<redacted> wfctl plugin ci -quiet. - If a secret was already published in a PR body/comment, redact the metadata, tell the operator it must be revoked, and record the incident in the final status.
Do not proceed to PR creation until the body is clean.
Step 2: Determine Base Branch
# Try common base branches
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null
Or ask: "This branch split from main - is that correct?"
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?
Don't add explanation - keep options concise.
Step 4: Execute Choice
Option 1: Merge Locally
# Switch to base branch
git checkout <base-branch>
# Pull latest
git pull
# Merge feature branch
git merge <feature-branch>
# Verify tests on merged result
<test command>
# If tests pass
git branch -d <feature-branch>
Then: Cleanup worktree (Step 5)
Option 2: Push and Create PR
# Push branch
git push -u origin <feature-branch>
# Create PR
gh pr create --title "<title>" --body "$(cat <<'EOF'
## Summary
<2-3 bullets of what changed>
## Test Plan
- [ ] <verification steps>
EOF
)"
Then: Cleanup worktree (Step 5)
Option 3: Keep As-Is
Report: "Keeping branch <name>. Worktree preserved at <path>."
Don't cleanup worktree.
Option 4: Discard
Confirm first:
This will permanently delete:
- Branch <name>
- All commits: <commit-list>
- Worktree at <path>
Type 'discard' to confirm.
Wait for exact confirmation.
If confirmed:
git checkout <base-branch>
git branch -D <feature-branch>
Then: Cleanup worktree (Step 5)
Step 5: Cleanup Worktree
For Options 1, 2, 4:
Check if in worktree:
git worktree list | grep $(git branch --show-current)
If yes:
git worktree remove <worktree-path>
For Option 3: Keep worktree.
Quick Reference
| Option | Merge | Push | Keep Worktree | Cleanup Branch |
|---|---|---|---|---|
| 1. Merge locally | ✓ | - | - | ✓ |
| 2. Create PR | - | ✓ | ✓ | - |
| 3. Keep as-is | - | - | ✓ | - |
| 4. Discard | - | - | - | ✓ (force) |
Common Mistakes
Skipping test verification
- Problem: Merge broken code, create failing PR
- Fix: Always verify tests before offering options
Open-ended questions
- Problem: "What should I do next?" → ambiguous
- Fix: Present exactly 4 structured options
Automatic worktree cleanup
- Problem: Remove worktree when might need it (Option 2, 3)
- Fix: Only cleanup for Options 1 and 4
No confirmation for discard
- Problem: Accidentally delete work
- Fix: Require typed "discard" confirmation
Red Flags
Never:
- Proceed with failing tests
- Merge without verifying tests on result
- Delete work without confirmation
- Force-push without explicit request
Always:
- Verify tests before offering options
- Present exactly 4 options
- Get typed confirmation for Option 4
- Clean up worktree for Options 1 & 4 only
Integration
Called by:
- subagent-driven-development (Step 7) - After all tasks complete
- executing-plans (Step 5) - After all batches complete
Calls (autonomous mode):
- autodev:pr-monitoring - After PR creation, monitors CI and reviews
Pairs with:
- using-git-worktrees - Cleans up worktree created by that skill