Safely merges pull requests to develop while validating CI status.

Install

mkdir -p .claude/skills/merge && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/18148" && unzip -o skill.zip -d .claude/skills/merge && rm skill.zip

Installs to .claude/skills/merge

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Merges an open pull request targeting `develop` after CI passes. Trigger on: "merge this", "merge the PR", "merge it", "merge PR #N", or any phrase combining "merge" with a branch or PR reference. Also called as an optional final stage from inside commit-and-pr. Accepts an optional PR number argument (e.g., `/merge 42`). Never merges to `main` — use `/merge-main` for releases.
379 charsno explicit “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Intermediate

Key capabilities

  • Find an open pull request
  • Verify the PR target is `develop`
  • Check CI status for failures or in-progress runs
  • Wait for in-progress CI to complete
  • Request explicit user confirmation for merge
  • Perform a squash merge and delete the branch

How it works

The skill finds a pull request, verifies its target branch and CI status, and then, after user confirmation, performs a squash merge and deletes the feature branch.

Inputs & outputs

You give it
A request to merge a pull request, optionally with a PR number
You get back
A merged pull request to `develop` and a report of the merge URL

When to use merge

  • Merge feature PR
  • Automate branch consolidation
  • Verify CI status before merge

About this skill

Merge Skill

Announce at start: "Running merge skill."

HARD CONSTRAINTS — READ THIS FIRST

  • Never merge to main. If the PR targets main, abort immediately and redirect the user to /merge-main.
  • Never merge when any CI check is failing. If CI has failures, stop and hand off to r-implement.
  • Always require explicit user confirmation before executing the merge.
  • Cannot write or edit .R source files or test files.

Step 1 — Find the PR

gh pr view --json number,title,baseRefName,headRefName,url,statusCheckRollup
  • If an explicit PR number was passed (e.g., /merge 42), use:
    gh pr view 42 --json number,title,baseRefName,headRefName,url,statusCheckRollup
    
  • If no PR exists for the current branch, report:

    "No open PR found for this branch. Open a PR first (e.g., with /commit-and-pr), then re-invoke /merge." Stop.

Store: prNumber, prTitle, baseRefName, prUrl, statusCheckRollup.


Step 2 — Verify target is develop

If baseRefName != "develop":

"PR #N targets {baseRefName}, not develop. This skill only merges feature branches to develop. For releases, use /merge-main."

Stop immediately.


Step 3 — Check CI status

Inspect statusCheckRollup from Step 1:

Check stateAction
All checks SUCCESSProceed to Step 4
Any check IN_PROGRESS or QUEUEDWait — see below
Any check FAILUREShow failure summary, stop — see CI failure block below
No checks (empty rollup)Warn user that CI has not run yet; ask whether to proceed or wait

Waiting for in-progress CI:

Find the run ID from the rollup (or via gh run list --branch <branch> --limit 1) and watch it:

gh run watch <run-id> --exit-status

This blocks until the run completes. If it exits non-zero, treat as FAILURE.

CI failure handoff block:

CI check failed for PR #N.

Failed check: <check-name>
Run URL: <run-url>

Invoke `/r-implement` to diagnose and fix the failure, then re-invoke
`/merge` after the fix is pushed and CI passes.

Stop.


Step 4 — Confirmation gate

Show and wait for explicit user approval:

"CI passed. PR #N ({headRefName}develop): {prTitle}

Squash-merge this PR?"

Do NOT proceed until the user says yes (or equivalent affirmative). If the user says no or asks to cancel, stop and report: "Merge cancelled."


Step 5 — Squash merge

gh pr merge <prNumber> --squash --delete-branch

If the command fails, report the error verbatim and stop.


Step 6 — Done

Report:

"Merged: {prUrl}"

Then check whether an implementation plan exists in plans/. If one is found, locate the first remaining - [ ] section and report:

"Next section: {branch-name} — {description}. Start a new session with /r-implement to continue."

If no plan is found, report done with no next-step suggestion.

When not to use it

  • When the user wants to merge to `main`
  • When any CI check is failing
  • When explicit user confirmation for merge is not provided

Limitations

  • The skill never merges to `main`
  • The skill never merges when any CI check is failing
  • The skill cannot write or edit `.R` source files or test files

How it compares

This skill automates the merge process with built-in checks for target branch and CI status, and requires explicit user approval, providing a controlled and standardized merge workflow.

Compared to similar skills

merge side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
merge (this skill)04moReviewIntermediate
github-workflow-automation112moReviewAdvanced
testing-workflow169moReviewIntermediate
github-actions-templates73moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

Search skills

Search the agent skills registry