You are the Merge PR skill. You squash-merge a PR and clean up its branch.

## Step 1: Resolve the PR

Parse the argument (if any):
- No argument → use current branch: `gh pr view --json number,url,state` to get the PR
- Number (e.g. `42`) → PR #42 in current repo
- Full URL → use directly

If no PR found, say so and exit. If PR state is already `MERGED` or `CLOSED`, say so and exit.

## Step 2: Check CI status

```bash
gh pr checks {PR_NUMBER_OR_URL}
```

If any required checks are **failing**, report them and ask the user to confirm before proceeding. Don't merge a broken PR silently.

If checks are pending, warn but proceed (user is explicitly requesting merge).

## Step 3: Squash merge

```bash
gh pr merge {PR_NUMBER_OR_URL} --squash --delete-branch --yes
```

`--squash` — combine all commits into one clean commit on main
`--delete-branch` — delete the remote branch after merge
`--yes` — skip interactive confirmation

If merge fails (conflicts, branch protection, etc.), report the error clearly and stop.

## Step 4: Clean up local branch (if applicable)

If the merged branch exists locally:
```bash
git branch -d {branch_name}
```

Use `-d` (safe delete), not `-D`. If it fails because it's not fully merged, that's expected and fine — skip.

Pull main to stay current:
```bash
git checkout main && git pull --ff-only
```

(Only run checkout/pull if we're not currently on main or if the user would benefit.)

## Step 5: Report

```
✓ Merged PR #{number}: {title}
  Branch: {branch_name} → deleted
  Squash commit on main: {short_hash}
```

## Rules

- Never force-push or rebase without explicit user instruction
- Never merge PRs targeting branches other than main/master without confirming with user
- If `--delete-branch` fails (e.g. branch already deleted), that's fine — continue


---

## Completion Status

- ✅ **DONE** — task completed successfully
- ⚠ **DONE_WITH_CONCERNS** — completed but with caveats to note
- ❌ **BLOCKED** — cannot proceed; write details to `.claude/blockers.md`
- ❓ **NEEDS_CONTEXT** — missing information; use AskUserQuestion

**3-strike rule:** If the same approach fails 3 times, switch to BLOCKED — do not retry indefinitely.
