Skip to content
Development
Skill

/merge-prep

Pre-merge analysis and preparation. Analyzes source branch vs target branch: commit stats, conflict detection, file impact. Analysis-only v1 — outputs report + suggested commands, does not auto-merge. Use when: user says 'merge prep', 'pre-merge', 'merge analysis', or /merge-prep

From plugin
sd0x-dev-flow
194102 skills16 agents5 hooks

Claude Code

$ npx -y skills add sd0xdev/sd0x-harness --skill merge-prep --agent claude-code

SKILL.md

merge-prep.SKILL.md
name: merge-prep
description: "Pre-merge analysis and preparation. Analyzes source branch vs target branch: commit stats, conflict detection, file impact. Analysis-only v1 — outputs report + suggested commands, does not auto-merge. Use when: user says 'merge prep', 'pre-merge', 'merge analysis', or /merge-prep"
allowed-tools: Bash(git:*), Read, Grep, Glob

Merge Prep — Pre-merge Analysis and Preparation

Analyze source branch vs target branch, detect conflicts, output analysis report with suggested commands. **v1 is analysis-only** — does not execute merge/commit/push.

When NOT to Use

| Scenario | Use Instead | |----------|-------------| | Commit code (not merge) | `/smart-commit` | | Merge to main (production) | Manual PR flow | | Just view diff | `git diff <target>..<branch>` | | Rebase or squash | Manual operation |

Input

`/merge-prep <source-branch> [--target <branch>]`

  • `<source-branch>`: Branch to merge (required)
  • `--target`: Target branch (default: `{TARGET_BRANCH}` or `main`)

Workflow

sequenceDiagram
    participant C as Claude
    participant U as User
    C->>C: Step 1: Validate prerequisites
    C->>C: Step 2: Pre-merge analysis
    C->>U: Show analysis report
    U->>C: Acknowledge
    C->>C: Step 3: Conflict analysis (if any)
    C->>U: Show conflict details + resolution suggestions
    C->>C: Step 4: Generate merge commands
    C->>U: Output commands for manual execution

Step 1: Validate Prerequisites

# 1a. Verify source branch exists
git rev-parse --verify <branch>

# 1b. Verify target branch exists
git rev-parse --verify <target>

# 1c. Verify working tree is clean
git status --porcelain

| Check | Failure Action | |-------|---------------| | Branch doesn't exist | Halt, list available branches | | Target not found | Halt, suggest creating it | | Uncommitted changes | Halt, suggest `/smart-commit` first |

Step 2: Pre-merge Analysis

Run the analysis script:

bash skills/merge-prep/scripts/pre-merge-check.sh <branch> [target]

Script outputs JSON containing:

  • `merge_base`: Common ancestor
  • `source_commits`: New commits on source branch
  • `target_commits`: Commits on target that source doesn't have
  • `has_conflicts`: Whether conflicts exist
  • `conflict_files`: List of conflict files
  • `file_stats`: Affected file statistics

Display analysis report:

## Pre-merge Analysis

| Item | Value |
|------|-------|
| Source branch | feat/new-feature |
| Target branch | main |
| Common ancestor | b03ad72a |
| New commits | 12 |
| Affected files | 46 |
| Predicted conflicts | 9 files |

### Recent Commits

| Hash | Message |
|------|---------|
| abc1234 | feat: Add new API endpoint |
| def5678 | test: Add integration tests |

Step 3: Conflict Analysis (if conflicts detected)

For each conflict file, analyze commit history to determine conflict pattern:

| Pattern | Detection | Suggested Strategy | |---------|-----------|-------------------| | Iterative (v1→v3) | Both sides changed, source is superset | Take source | | Parallel modification | Different people changed different logic | Per-hunk selection | | Hotfix conflict | Target has hotfix merge, source doesn't | Take target | | Doc add/add | Both sides added same-name file | Take source |

Display resolution suggestions:

### Conflict Files

| # | File | Pattern | Suggestion | Reason |
|---|------|---------|------------|--------|
| 1 | src/xxx.ts | Iterative | Take source | v3 includes all v1 changes |
| 2 | src/yyy.ts | Parallel | Per-hunk | Two sides changed different functions |
| 3 | docs/zzz.md | add/add | Take source | Target version is outdated |

Step 4: Generate Merge Commands

Output commands for manual execution:

## Suggested Merge Commands

### Option A: Merge commit (recommended)

```bash
git checkout <target>
git pull --ff-only origin <target>
git merge <source> --no-ff
# Resolve conflicts if any
# git add <resolved-files>
# git commit
git push origin <target>

Option B: Squash merge

git checkout <target>
git pull --ff-only origin <target>
git merge --squash <source>
git commit -m "merge: Merge <source> into <target>"
git push origin <target>

### Step 5: Summary

```markdown
## Merge Summary

| Item | Value |
|------|-------|
| Source | feat/new-feature |
| Target | main |
| Commits | 12 |
| Files | 46 |
| Conflicts | 9 (resolution suggestions provided) |
| Tickets | PROJ-520, PROJ-123 |

⚠️ This is an analysis-only report. Execute the commands manually.

Multi-branch Mode

Supports `/merge-prep branch1 branch2 branch3 --target develop`:

1. Analyze each branch sequentially 2. Output combined summary 3. Suggest merge order (fewest conflicts first)

Prohibited (v1)

  • **No auto-merge**: Only output commands, never execute `git merge`
  • **No auto-push**: Never execute `git push`
  • **No auto-commit**: Never execute `git commit`
  • **No rebase**: Never suggest or execute rebase operations

References

| File | Purpose | When to Read | |------|---------|-------------| | [pre-merge-check.sh](scripts/pre-merge-check.sh) | Pre-merge analysis script | Step 2 |

Verification

  • [ ] Source branch exists and working tree is clean
  • [ ] Pre-merge analysis displayed with user acknowledgment
  • [ ] Conflicts analyzed with resolution suggestions
  • [ ] Merge commands are output-only (not executed)
  • [ ] No secrets in output, no force push suggested
Read more
@sd0xdev
Ships withsd0x-dev-flow

Language: English | 繁體中文 | 简体中文 | 日本語 | 한국어 | Español The harness layer for Claude Code. Let the model choose the path. Keep "done" verifiable. Claude has discretion inside a closed, test-pinned anchor set.

194102 skills16 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
194
Star history of sd0xdev/sd0x-dev-flow on GitHub, a chart by star-history.com

Other skills on sd0x-dev-flow.

adr

adr

Write an Architecture Decision Record (ADR) for a feature — Context / Decision / Status / Consequences / Alternatives, filed as…

agentctl-setup

agentctl-setup

Install and set up the optional agentctl mod (task scope, refusal before execution, evidence that goes stale, model-free…

architecture

architecture

Architecture design and documentation. Produces 3-architecture.md with component diagrams, data flow, integration points, and…

ask

ask

Context-aware Q&A with auto context gathering. Use when: user has a quick question about codebase, git history, rules, docs, or…

best-practices

best-practices

Industry best practices conformance audit with mandatory adversarial debate. Produces audit artifact: verdict (OK/WARN/FAIL) +…

bug-fix

bug-fix

Bug fix workflow. Use when: fixing bugs, resolving issues, regression fixes. Not for: new features (use feature-dev),…

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills12d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc13d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react2d252k
@facebook@facebookInstall Skill

Questions about merge-prep.

Which coding agents can use merge-prep?
merge-prep installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.