Merge Branch Safely

VerifiedSafe

This skill automates safely merging a feature branch into its configured base branch by committing changes, rebasing onto the base branch (handling conflicts), and merging with a notification. It prevents accidental merges into main/master and avoids force pushes, making branch integration safer for developers.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude Code
#git#merge#rebase#branch-management#commit

Recommended for

Automated summary

Commits, rebases, and merges a feature branch into its configured base branch while preventing merges into main or master.

Strengths

  • Prevents accidental merges into main/master
  • Uses conventional commits with co-author
  • Handles conflict resolution by preserving both branches' changes
  • Configurable base branch per feature branch

Limitations

  • Only works with a configured base branch via git config
  • Does not fetch from remote before rebase
  • If conflict resolution is too complex, asks for guidance
When to use it

Use when you want to integrate a feature branch into its base branch with a clean history and without risking main.

When not to use it

Do not use if you need to merge into main/master or if the base branch requires remote updates before rebase.

Security analysis

Safe
Quality score92/100

Only uses git operations within the current repository, with explicit safeguards against merging into main/master and force pushing. No dangerous commands or data exfiltration.

No concerns found

How this analysis is made

Examples

Merge current branch into its base
Merge my current branch into its configured base branch.
Commit and merge feature branch
Commit staged changes and merge this feature branch into its base.
Integrate branch with conflict handling
Please run the merge skill to integrate the current branch into its base, resolving any conflicts.

name: merge description: Commit, rebase, and merge the current branch into its base branch (never main). disable-model-invocation: true allowed-tools: Read, Bash, Glob, Grep

Safety Rules

CRITICAL — these rules must NEVER be violated:

  • NEVER merge into main or master. If the resolved base branch is main or master, stop immediately and inform the user.
  • NEVER force push. Do not use --force, --force-with-lease, or -f with git push.

Step 1: Verify Branch

git branch --show-current

If the current branch is main or master, STOP and tell the user they must be on a feature branch.

Step 2: Commit

If there are staged changes, commit them.

  1. Run git log --format="%s" -n 20 to detect the repo's commit convention and match it.
  2. If no clear convention exists, default to conventional commits with a scope, e.g. feat(auth): add login endpoint.
  3. Always include a co-author trailer:
    Co-Authored-By: Claude <noreply@anthropic.com>
    
  4. Skip if nothing is staged.

Step 3: Determine Base Branch

git config --local --get "branch.$(git branch --show-current).workmux-base" 2>/dev/null

If no base branch is configured, STOP and tell the user no base branch is set. Do NOT default to main.

If the base branch is main or master, STOP and tell the user: "Refusing to merge into main/master. Set a different base branch or use /pr instead."

Step 4: Rebase

Rebase onto the local base branch (do NOT fetch from origin first):

git rebase <base-branch>

IMPORTANT: Do NOT run git fetch. Do NOT rebase onto origin/<branch>. Only rebase onto the local branch name.

If conflicts occur:

  • BEFORE resolving any conflict, understand what changes were made to each conflicting file in the base branch
  • For each conflicting file, run git log -p -n 3 <base-branch> -- <file> to see recent changes
  • Preserve BOTH the base branch changes AND our branch's changes
  • After resolving each conflict, stage the file and continue with git rebase --continue
  • If a conflict is too complex or unclear, ask for guidance

Step 5: Merge

Run: workmux merge --rebase --notification

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/merge-branch-safely-mm8o528k/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/merge-branch-safely-mm8o528k' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/merge-branch-safely-mm8o528k/download' --output '.skill-downloads/merge-branch-safely-mm8o528k/SKILL.md.part' && mv '.skill-downloads/merge-branch-safely-mm8o528k/SKILL.md.part' '.skill-downloads/merge-branch-safely-mm8o528k/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Read, Bash, Glob, Grep

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/merge-branch-safely-mm8o528k/SKILL.md' && test -s '.skill-downloads/merge-branch-safely-mm8o528k/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/merge' && cp -R '.skill-downloads/merge-branch-safely-mm8o528k' '.claude/skills/merge'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/merge-branch-safely-mm8o528k'

openskills read 'merge-branch-safely-mm8o528k'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/merge-branch-safely-mm8o528k/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills