xiaohongshu
xiaohongshu
git-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 cleanup
Full skill instructions
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 git-finishing-a-development-branch skill to complete this work."
Check for unstaged/uncommitted changes:
git status --porcelain
If dirty (has unstaged/uncommitted changes):
# Stage all changes
git add .
# Create final commit
git commit -m "feat: final changes before merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>"
If clean: Continue to Step 2.
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 3.
If tests pass: Continue to Step 3.
# 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?"
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.
# Switch to base branch (typically feature branch)
git checkout {{base-branch}}
# Pull latest
git pull
# Merge worktree branch (regular merge, NOT squash)
git merge {{worktree-branch}}
# Verify tests on merged result
{{test-command}}
# If tests pass
git branch -d {{worktree-branch}}
Note: This is a regular merge (NOT squash) because you're merging worktree → feature branch. Use merging-feature-branches-to-main skill later to squash merge feature branch → main after human review.
Then: Cleanup worktree (Step 6)
# Push branch
git push -u origin {{feature-branch}}
# Create PR
gh pr create --title "{{title}}" --body "$(cat <<'EOF'
## Summary
{{summary-bullets}}
## Test Plan
- [ ] {{test-steps}}
EOF
)"
Then: Cleanup worktree (Step 6)
Report: "Keeping branch {{branch-name}}. Worktree preserved at {{worktree-path}}."
Don't cleanup worktree.
Confirm first:
This will permanently delete:
- Branch {{branch-name}}
- All commits: {{commit-list}}
- Worktree at {{worktree-path}}
Type 'discard' to confirm.
Wait for exact confirmation.
If confirmed:
git checkout {{base-branch}}
git branch -d {{feature-branch}}
If deletion fails (branch not merged):
❌ Branch {{feature-branch}} is not fully merged.
Use 'git branch -D {{feature-branch}}' to force delete if you're certain.
Confirm force delete? (yes/no)
Then: Cleanup worktree (Step 6)
For Options 1, 2, 4:
Check if in worktree:
git worktree list | grep $(git branch --show-current)
If yes, try to remove:
git worktree remove {{worktree-path}}
If removal fails due to dirty state:
Report error and stop. NEVER use --force to delete dirty worktrees.
❌ Cannot remove worktree - contains uncommitted changes
Worktree path: {{path}}
Branch: {{branch-name}}
This indicates uncommitted work was not properly saved.
Please investigate manually before removing.
For Option 3: Keep worktree.
| Option | Merge | Push | Keep Worktree | Cleanup Branch |
|---|---|---|---|---|
| 1. Merge locally | ✓ | - | - | ✓ |
| 2. Create PR | - | ✓ | ✓ | - |
| 3. Keep as-is | - | - | ✓ | - |
| 4. Discard | - | - | - | ✓ (safe delete, confirm if force needed) |
Never:
Always:
Called by:
Pairs with:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience