| name | feature-merge |
| description | Merge feature branches into main using squash commits with comprehensive commit messages. Use this skill when the user requests to merge, ship, or integrate a feature branch into the main branch. The skill analyzes all commits in the feature branch to understand the full scope of changes, then creates a single squashed commit with a proper conventional commit message that summarizes the entire feature. |
Feature Merge
Overview
Merge feature branches into main using a squash merge strategy. Analyze all commits in the feature branch to understand the complete scope of changes, then create a single comprehensive commit message following the project's Conventional Commits format. After merging, clean up the feature branch from both local and remote repositories.
When to Use This Skill
Use this skill when:
- The user requests to merge a feature branch into
main - The user asks to "ship" or "integrate" their current branch
- A feature branch is complete and ready to be merged with a clean history
- Multiple commits need to be consolidated into a single logical change
Workflow
Step 1: Validate Preconditions
Before beginning the merge process, verify the following:
- Confirm current branch: Use
git branch --show-currentto identify the feature branch - Check main branch existence: Verify
mainbranch exists (if not, check formaster) - Ensure clean working directory: Run
git statusto confirm no uncommitted changes - Verify branch divergence: Ensure the feature branch has diverged from
mainwith commits to merge
If any preconditions fail, inform the user and stop the process.
Step 2: Analyze the Feature Branch
Gather comprehensive information about all changes in the feature branch:
- Review commit history: Run
git log main..HEAD --onelineto see all commits that will be merged - Examine full diff: Run
git diff main...HEADto understand the complete scope of changes - Review individual commits: Run
git log main..HEAD(without--oneline) to see detailed commit messages
The commits serve as reference material ONLY to understand what was done. Do not incorporate the existing commit messages directly into the squash commit.
Step 3: Determine the Commit Type
Based on the changes analyzed, determine the appropriate Conventional Commit type:
- feat: For new features or significant new functionality
- fix: For bug fixes
- refactor: For code restructuring without functional changes
- perf: For performance improvements
- docs: For documentation-only changes
- test: For test additions or updates
- chore: For maintenance tasks (dependencies, build scripts, etc.)
If the branch contains multiple types of changes, use the primary type that best represents the overall purpose of the branch.
Step 4: Craft the Squash Commit Message
Create a comprehensive commit message that:
- Follows Conventional Commits format:
<type>: <description> - Summarizes the complete feature: Describes what the branch accomplishes as a whole
- Focuses on the "why" and "what": Explains the purpose and outcome, not implementation details
- Uses present tense: "Add feature" not "Added feature"
- Is concise but complete: One clear sentence for the subject line
For complex features, optionally include a body that provides additional context:
feat: Add automated release workflow
Implement GitHub Actions workflow with GoReleaser for automated
binary builds and release creation. Supports semantic versioning
and changelog generation from conventional commits.
Load the commit conventions from references/commit_conventions.md to ensure proper formatting.
Step 5: Execute the Merge
Perform the squash merge with the crafted commit message:
- Switch to main branch:
git checkout main - Update main:
git pull origin mainto ensure local main is current - Perform squash merge:
git merge --squash <feature-branch> - Create the commit:
git commit -m "<commit-message>"
Use a HEREDOC for multi-line commit messages to ensure proper formatting:
git commit -m "$(cat <<'EOF'
<type>: <description>
<optional body>
EOF
)"
Step 6: Clean Up the Feature Branch
After successful merge, remove the feature branch:
- Delete local branch:
git branch -d <feature-branch> - Delete remote branch:
git push origin --delete <feature-branch>
If the remote branch doesn't exist (already deleted or never pushed), the delete command will fail gracefully - this is expected and acceptable.
Step 7: Confirm Completion
Inform the user of the successful merge:
- Summarize what was done: "Merged feature branch
<name>intomain" - Display the commit message: Show the final commit message used
- Remind about pushing: "The merge is on local
main. Push when ready withgit push origin main" - Confirm cleanup: Note that the feature branch has been deleted
Error Handling
Merge Conflicts
If git merge --squash results in conflicts:
- Display the conflicting files
- Inform the user they need to resolve conflicts manually
- Provide guidance: "After resolving conflicts, run
git add .thengit commit" - Do not proceed with automatic commit creation
Branch Already Merged
If the feature branch has no commits ahead of main:
- Inform the user the branch is already merged or has no changes
- Ask if they want to delete the branch anyway
- Do not attempt the merge
Uncommitted Changes
If git status shows uncommitted changes:
- Display the uncommitted changes
- Ask the user to either commit or stash changes first
- Do not proceed with the merge
References
references/commit_conventions.md: Detailed commit message format and examples