Claude-skill-registry feature-merge
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.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/feature-merge" ~/.claude/skills/majiayu000-claude-skill-registry-feature-merge && rm -rf "$T"
skills/data/feature-merge/SKILL.mdFeature 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
to identify the feature branchgit branch --show-current - Check main branch existence: Verify
branch exists (if not, check formain
)master - Ensure clean working directory: Run
to confirm no uncommitted changesgit status - Verify branch divergence: Ensure the feature branch has diverged from
with commits to mergemain
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
to see all commits that will be mergedgit log main..HEAD --oneline - Examine full diff: Run
to understand the complete scope of changesgit diff main...HEAD - Review individual commits: Run
(withoutgit log main..HEAD
) to see detailed commit messages--oneline
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:
to ensure local main is currentgit pull origin main - 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
into<name>
"main - Display the commit message: Show the final commit message used
- Remind about pushing: "The merge is on local
. Push when ready withmain
"git 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
thengit add .
"git 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
: Detailed commit message format and examplesreferences/commit_conventions.md