Loading...
Loading...
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.
npx skill4agent add izyanrajwani/agent-skills-library finishing-a-development-branchpackage.jsonnpm testyarn testCargo.tomlcargo testpyproject.tomlsetup.pypytestgo.modgo test ./...Makefiletestmake test⊘ BLOCKED:TESTS# Check which branch has the closest merge-base
for candidate in main master develop; do
if git rev-parse --verify "$candidate" >/dev/null 2>&1; then
MERGE_BASE=$(git merge-base HEAD "$candidate" 2>/dev/null)
if [ -n "$MERGE_BASE" ]; then
echo "Candidate: $candidate (merge-base: $MERGE_BASE)"
fi
fi
donemaindevelop<base-branch>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?git checkout <base-branch>
git pull
git merge <feature-branch>⊘ BLOCKED:CONFLICTS
Merge conflicts in:
- <conflicted files>
Cannot auto-resolve. User must:
1. Resolve conflicts manually
2. Run tests
3. Re-run this workflow# Verify tests on merged result
<test command>
# If tests pass, delete feature branch
git branch -d <feature-branch>✓ MERGEDghif ! command -v gh &>/dev/null; then
echo "gh CLI not installed. Install from https://cli.github.com/ or push manually and create PR via web."
exit 1
fi
gh auth status || echo "gh not authenticated. Run: gh auth login"MERGE_BASE=$(git merge-base HEAD <base-branch>)
TITLE=$(git log --reverse --format=%s "$MERGE_BASE"..HEAD | head -1)
git push -u origin <feature-branch>
gh pr create --title "$TITLE" --body "$(cat <<'EOF'
## Summary
<2-3 bullets of what changed>
## Test Plan
- [ ] <verification steps>
EOF
)"✓ PR_CREATED✓ PRESERVEDThis will permanently delete:
- Branch <name>
- All commits: <commit-list>
- Worktree at <path>
Type 'discard' to confirm.git checkout <base-branch>
git branch -D <feature-branch>✓ DISCARDED# Check if currently in a worktree (not main repo)
if [ "$(git rev-parse --git-common-dir)" != "$(git rev-parse --git-dir)" ]; then
# Get worktree root (handles invocation from subdirectory)
WORKTREE_ROOT=$(git rev-parse --show-toplevel)
cd "$(git rev-parse --git-common-dir)/.."
git worktree remove "$WORKTREE_ROOT"
fi| Option | Merge | Push | Keep Worktree | Cleanup Branch |
|---|---|---|---|---|
| 1. Merge locally | ✓ | - | - | ✓ |
| 2. Create PR | - | ✓ | ✓ | - |
| 3. Keep as-is | - | - | ✓ | - |
| 4. Discard | - | - | - | ✓ (force) |
| State | Output | Meaning |
|---|---|---|
| Branch merged to | Option 1 success |
| PR #N at URL | Option 2 success |
| Branch kept at path | Option 3 success |
| Branch deleted, worktree cleaned | Option 4 success |
| N test failures | Cannot proceed |
| Merge conflict in files | Cannot proceed |
⊘ BLOCKED:TESTS⊘ BLOCKED:CONFLICTS