{"id":"34b811af-3f1f-48ad-a09f-0be4772bdd29","shortId":"aZshUe","kind":"skill","title":"finishing-a-development-branch","tagline":"Git branch completion workflow. Use when implementation is complete, tests pass, and a feature branch needs to be integrated via merge, pull request, or cleanup.","description":"# Finishing a Development Branch\n\n## The Process\n\n### Step 1: Verify Tests\n\nDetermine test runner from project structure:\n- `package.json` → `npm test` or `yarn test`\n- `Cargo.toml` → `cargo test`\n- `pyproject.toml` / `setup.py` → `pytest`\n- `go.mod` → `go test ./...`\n- `Makefile` with `test` target → `make test`\n\nRun tests. If any fail, report `⊘ BLOCKED:TESTS` with failure count and stop. Do not proceed to Step 2.\n\n### Step 2: Determine Base Branch\n\nFind the branch this feature diverged from:\n\n```bash\n# Check which branch has the closest merge-base\nfor candidate in main master develop; do\n  if git rev-parse --verify \"$candidate\" >/dev/null 2>&1; then\n    MERGE_BASE=$(git merge-base HEAD \"$candidate\" 2>/dev/null)\n    if [ -n \"$MERGE_BASE\" ]; then\n      echo \"Candidate: $candidate (merge-base: $MERGE_BASE)\"\n    fi\n  fi\ndone\n```\n\nSelect the candidate with the most recent merge-base (closest ancestor). If multiple branches share the same merge-base or detection is ambiguous, ask: \"This branch could target `main` or `develop`. Which should it merge into?\"\n\n**Store the result** - subsequent steps reference `<base-branch>` meaning this determined value.\n\n### Step 3: Present Options\n\nPresent exactly these 4 options:\n\n```\nImplementation complete. What would you like to do?\n\n1. Merge back to <base-branch> locally\n2. Push and create a Pull Request\n3. Keep the branch as-is (I'll handle it later)\n4. Discard this work\n\nWhich option?\n```\n\n### Step 4: Execute Choice\n\n#### Option 1: Merge Locally\n\n```bash\ngit checkout <base-branch>\ngit pull\ngit merge <feature-branch>\n```\n\n**If merge conflicts:**\n```\n⊘ BLOCKED:CONFLICTS\n\nMerge conflicts in:\n- <conflicted files>\n\nCannot auto-resolve. User must:\n1. Resolve conflicts manually\n2. Run tests\n3. Re-run this workflow\n```\nStop. Do not proceed.\n\n**If merge succeeds:**\n```bash\n# Verify tests on merged result\n<test command>\n\n# If tests pass, delete feature branch\ngit branch -d <feature-branch>\n```\n\nThen: Cleanup worktree (Step 5). Report `✓ MERGED`.\n\n#### Option 2: Push and Create PR\n\n**Verify `gh` CLI is available:**\n```bash\nif ! command -v gh &>/dev/null; then\n  echo \"gh CLI not installed. Install from https://cli.github.com/ or push manually and create PR via web.\"\n  exit 1\nfi\ngh auth status || echo \"gh not authenticated. Run: gh auth login\"\n```\n\nExtract title from first commit on branch (original intent):\n\n```bash\nMERGE_BASE=$(git merge-base HEAD <base-branch>)\nTITLE=$(git log --reverse --format=%s \"$MERGE_BASE\"..HEAD | head -1)\ngit push -u origin <feature-branch>\ngh pr create --title \"$TITLE\" --body \"$(cat <<'EOF'\n## Summary\n<2-3 bullets of what changed>\n\n## Test Plan\n- [ ] <verification steps>\nEOF\n)\"\n```\n\nReport `✓ PR_CREATED` with PR URL. **Keep worktree intact** for continued work during review.\n\n#### Option 3: Keep As-Is\n\nReport `✓ PRESERVED` with branch name and worktree path.\n\n**Do not cleanup worktree.**\n\n#### Option 4: Discard\n\n**Confirm first:**\n```\nThis will permanently delete:\n- Branch <name>\n- All commits: <commit-list>\n- Worktree at <path>\n\nType 'discard' to confirm.\n```\n\nWait for exact confirmation. If not received, abort.\n\nIf confirmed:\n```bash\ngit checkout <base-branch>\ngit branch -D <feature-branch>\n```\n\nThen: Cleanup worktree (Step 5). Report `✓ DISCARDED`.\n\n### Step 5: Cleanup Worktree\n\n**For Options 1 and 4 only:**\n\n```bash\n# Check if currently in a worktree (not main repo)\nif [ \"$(git rev-parse --git-common-dir)\" != \"$(git rev-parse --git-dir)\" ]; then\n  # Get worktree root (handles invocation from subdirectory)\n  WORKTREE_ROOT=$(git rev-parse --show-toplevel)\n  cd \"$(git rev-parse --git-common-dir)/..\"\n  git worktree remove \"$WORKTREE_ROOT\"\nfi\n```\n\n**For Options 2 and 3:** Keep worktree intact.\n\n## Quick Reference\n\n| Option | Merge | Push | Keep Worktree | Cleanup Branch |\n|--------|-------|------|---------------|----------------|\n| 1. Merge locally | ✓ | - | - | ✓ |\n| 2. Create PR | - | ✓ | ✓ | - |\n| 3. Keep as-is | - | - | ✓ | - |\n| 4. Discard | - | - | - | ✓ (force) |\n\n## Terminal States\n\nOn completion, report exactly one:\n\n| State | Output | Meaning |\n|-------|--------|---------|\n| `✓ MERGED` | Branch merged to `<base>`, worktree cleaned | Option 1 success |\n| `✓ PR_CREATED` | PR #N at URL | Option 2 success |\n| `✓ PRESERVED` | Branch kept at path | Option 3 success |\n| `✓ DISCARDED` | Branch deleted, worktree cleaned | Option 4 success |\n| `⊘ BLOCKED:TESTS` | N test failures | Cannot proceed |\n| `⊘ BLOCKED:CONFLICTS` | Merge conflict in files | Cannot proceed |\n\n## Guardrails\n\n**Blocking conditions (stop immediately):**\n- Tests failing → `⊘ BLOCKED:TESTS`\n- Merge conflicts → `⊘ BLOCKED:CONFLICTS`\n\n**Mandatory confirmations:**\n- Option 4 (Discard): Require typed \"discard\" confirmation\n\n**Cleanup rules:**\n- Options 1, 4: Clean up worktree and branch\n- Options 2, 3: Preserve worktree\n\n**Never:**\n- Proceed with failing tests\n- Merge without verifying tests on result\n- Delete work without typed confirmation\n- Force-push without explicit request\n\n## Integration\n\n**Called by:**\n- **subagent-driven-development** (Step 7) - After all tasks complete\n- **executing-plans** (Step 5) - After all batches complete\n\n**Pairs with:**\n- **using-git-worktrees** - Cleans up worktree created by that skill","tags":["finishing","development","branch","agent","skills","library","codingcossack","agent-framework","agent-skills","agent-system","agent-workflow","agentic-workflow"],"capabilities":["skill","source-codingcossack","skill-finishing-a-development-branch","topic-agent-framework","topic-agent-skills","topic-agent-system","topic-agent-workflow","topic-agentic-workflow","topic-ai-agents","topic-anthropic","topic-claude","topic-claude-code","topic-claude-skills","topic-claude-skills-hub","topic-claude-skills-libary"],"categories":["agent-skills-library"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/CodingCossack/agent-skills-library/finishing-a-development-branch","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add CodingCossack/agent-skills-library","source_repo":"https://github.com/CodingCossack/agent-skills-library","install_from":"skills.sh"}},"qualityScore":"0.458","qualityRationale":"deterministic score 0.46 from registry signals: · indexed on github topic:agent-skills · 17 github stars · SKILL.md body (5,234 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-23T07:01:19.270Z","embedding":null,"createdAt":"2026-04-18T23:06:36.708Z","updatedAt":"2026-04-23T07:01:19.270Z","lastSeenAt":"2026-04-23T07:01:19.270Z","tsv":"'-1':394 '-3':409 '/dev/null':123,136,335 '1':38,125,218,253,277,354,496,575,606,673 '2':86,88,124,135,223,281,320,408,560,578,615,681 '3':202,230,284,432,562,581,623,682 '4':208,242,249,450,498,586,631,664,674 '5':316,487,491,724 '7':715 'abort':474 'ambigu':177 'ancestor':164 'as-i':234,434,583 'ask':178 'auth':357,365 'authent':362 'auto':273 'auto-resolv':272 'avail':329 'back':220 'base':90,108,128,132,140,147,149,162,173,378,382,391 'bash':99,256,297,330,376,477,500 'batch':727 'block':74,266,633,640,649,655,659 'bodi':404 'branch':5,7,20,34,91,94,102,167,180,233,308,310,373,440,458,481,574,600,618,626,679 'bullet':410 'call':708 'candid':110,122,134,143,144,155 'cannot':271,638,646 'cargo':54 'cargo.toml':53 'cat':405 'cd':543 'chang':413 'check':100,501 'checkout':258,479 'choic':251 'clean':604,629,675,735 'cleanup':30,313,447,484,492,573,670 'cli':327,339 'cli.github.com':344 'closest':105,163 'command':332 'commit':371,460 'common':517,550 'complet':8,14,211,592,719,728 'condit':650 'confirm':452,466,470,476,662,669,700 'conflict':265,267,269,279,641,643,658,660 'continu':427 'could':181 'count':78 'creat':226,323,349,401,419,579,609,738 'current':503 'd':311,482 'delet':306,457,627,696 'detect':175 'determin':41,89,199 'develop':4,33,114,185,713 'dir':518,525,551 'discard':243,451,464,489,587,625,665,668 'diverg':97 'done':152 'driven':712 'echo':142,337,359 'eof':406,416 'exact':206,469,594 'execut':250,721 'executing-plan':720 'exit':353 'explicit':705 'extract':367 'fail':72,654,688 'failur':77,637 'featur':19,96,307 'fi':150,151,355,557 'file':645 'find':92 'finish':2,31 'finishing-a-development-branch':1 'first':370,453 'forc':588,702 'force-push':701 'format':388 'get':527 'gh':326,334,338,356,360,364,399 'git':6,117,129,257,259,261,309,379,385,395,478,480,511,516,519,524,536,544,549,552,733 'git-common-dir':515,548 'git-dir':523 'go':60 'go.mod':59 'guardrail':648 'handl':239,530 'head':133,383,392,393 'immedi':652 'implement':12,210 'instal':341,342 'intact':425,565 'integr':24,707 'intent':375 'invoc':531 'keep':231,423,433,563,571,582 'kept':619 'later':241 'like':215 'll':238 'local':222,255,577 'log':386 'login':366 'main':112,183,508 'make':66 'makefil':62 'mandatori':661 'manual':280,347 'master':113 'mean':197,598 'merg':26,107,127,131,139,146,148,161,172,189,219,254,262,264,268,295,301,318,377,381,390,569,576,599,601,642,657,690 'merge-bas':106,130,145,160,171,380 'multipl':166 'must':276 'n':138,611,635 'name':441 'need':21 'never':685 'npm':48 'one':595 'option':204,209,247,252,319,431,449,495,559,568,605,614,622,630,663,672,680 'origin':374,398 'output':597 'package.json':47 'pair':729 'pars':120,514,522,539,547 'pass':16,305 'path':444,621 'perman':456 'plan':415,722 'pr':324,350,400,418,421,580,608,610 'present':203,205 'preserv':438,617,683 'proceed':83,293,639,647,686 'process':36 'project':45 'pull':27,228,260 'push':224,321,346,396,570,703 'pyproject.toml':56 'pytest':58 'quick':566 're':286 're-run':285 'receiv':473 'recent':159 'refer':196,567 'remov':554 'repo':509 'report':73,317,417,437,488,593 'request':28,229,706 'requir':666 'resolv':274,278 'result':193,302,695 'rev':119,513,521,538,546 'rev-pars':118,512,520,537,545 'revers':387 'review':430 'root':529,535,556 'rule':671 'run':68,282,287,363 'runner':43 'select':153 'setup.py':57 'share':168 'show':541 'show-toplevel':540 'skill':741 'skill-finishing-a-development-branch' 'source-codingcossack' 'state':590,596 'status':358 'step':37,85,87,195,201,248,315,486,490,714,723 'stop':80,290,651 'store':191 'structur':46 'subag':711 'subagent-driven-develop':710 'subdirectori':533 'subsequ':194 'succeed':296 'success':607,616,624,632 'summari':407 'target':65,182 'task':718 'termin':589 'test':15,40,42,49,52,55,61,64,67,69,75,283,299,304,414,634,636,653,656,689,693 'titl':368,384,402,403 'topic-agent-framework' 'topic-agent-skills' 'topic-agent-system' 'topic-agent-workflow' 'topic-agentic-workflow' 'topic-ai-agents' 'topic-anthropic' 'topic-claude' 'topic-claude-code' 'topic-claude-skills' 'topic-claude-skills-hub' 'topic-claude-skills-libary' 'toplevel':542 'type':463,667,699 'u':397 'url':422,613 'use':10,732 'user':275 'using-git-worktre':731 'v':333 'valu':200 'verifi':39,121,298,325,692 'via':25,351 'wait':467 'web':352 'without':691,698,704 'work':245,428,697 'workflow':9,289 'worktre':314,424,443,448,461,485,493,506,528,534,553,555,564,572,603,628,677,684,734,737 'would':213 'yarn':51","prices":[{"id":"48b78f5d-5538-4cd3-9a46-31c7b8b7fe7d","listingId":"34b811af-3f1f-48ad-a09f-0be4772bdd29","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"CodingCossack","category":"agent-skills-library","install_from":"skills.sh"},"createdAt":"2026-04-18T23:06:36.708Z"}],"sources":[{"listingId":"34b811af-3f1f-48ad-a09f-0be4772bdd29","source":"github","sourceId":"CodingCossack/agent-skills-library/finishing-a-development-branch","sourceUrl":"https://github.com/CodingCossack/agent-skills-library/tree/main/skills/finishing-a-development-branch","isPrimary":false,"firstSeenAt":"2026-04-18T23:06:36.708Z","lastSeenAt":"2026-04-23T07:01:19.270Z"}],"details":{"listingId":"34b811af-3f1f-48ad-a09f-0be4772bdd29","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"CodingCossack","slug":"finishing-a-development-branch","github":{"repo":"CodingCossack/agent-skills-library","stars":17,"topics":["agent-framework","agent-skills","agent-system","agent-workflow","agentic-workflow","ai-agents","anthropic","claude","claude-code","claude-skills","claude-skills-hub","claude-skills-libary","code-review","codex","context-engineering","debugging","developer-workflow"],"license":null,"html_url":"https://github.com/CodingCossack/agent-skills-library","pushed_at":"2026-01-03T20:02:38Z","description":"Coding agent skills library for programming workflows | Claude Skills, Codex Skills | Forked from obra/superpower","skill_md_sha":"02d7e157580daf229bcd3e6370159f792bccd9df","skill_md_path":"skills/finishing-a-development-branch/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/CodingCossack/agent-skills-library/tree/main/skills/finishing-a-development-branch"},"layout":"multi","source":"github","category":"agent-skills-library","frontmatter":{"name":"finishing-a-development-branch","description":"Git branch completion workflow. Use when implementation is complete, tests pass, and a feature branch needs to be integrated via merge, pull request, or cleanup."},"skills_sh_url":"https://skills.sh/CodingCossack/agent-skills-library/finishing-a-development-branch"},"updatedAt":"2026-04-23T07:01:19.270Z"}}