# Merge Request Check

> Merge-request / PR review workflow: resolve a branch or MR number against an integration branch (default develop), build a unified diff, and produce a structured review using the session default model and the bundled prompt template; optional Ollama via ./review.sh when present. Use when the user says merge request check, MR review, /merge-request-check, review.sh, or wants a diff-based PR review before merge.

- Skill: `stefancgillberg/merge-request-check` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add stefancgillberg/merge-request-check`
- Raw SKILL.md: https://api.skillmd.com/api/skills/stefancgillberg/merge-request-check/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: stefancgillberg (https://skillmd.com/u/stefancgillberg)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/stefancgillberg/merge-request-check

---


# Merge request check

## Goal

Replicate a typical **MR review script** flow in **git**: **check out** the change (branch name, MR number, or merge commit), **diff against the integration branch** (default `develop`), feed the diff into the **standard review prompt** in [references/review-prompt-template.md](references/review-prompt-template.md), and produce **`code_review.md`-style output** (structured sections, patch block, test suggestions).

**Default reviewer:** the **same in-session AI model** Cursor uses for other skills (this chat/agent). Do **not** assume Ollama unless the user asks for it or you use the fallback below.

## Adapting for your repository

- **Prompt / domain:** Edit [references/review-prompt-template.md](references/review-prompt-template.md) for your language, framework, and review checklist. The bundled template targets **iOS / Swift / SwiftUI**; replace that section if your project differs.
- **Automation:** The **optional** `./review.sh` path applies only if your repo provides that script at the **repository root**. If there is no script, use **only** the in-session steps below.
- **Base branch:** Default is **`develop`**. If your team uses `main`, `trunk`, etc., follow the user or use `REVIEW_BASE` / a user-specified base and state it in the review **Assumptions** section.

## Default — in-session review (preferred)

1. **Git safety**
   - Refuse to clobber uncommitted work (`git status` clean). If not, stop and tell the user to commit, stash, or discard.
   - User supplied **branch name**, **MR number**, or **identifying string** (same resolution rules as a typical `review.sh` that supports MR grep / branch discovery).
   - `git fetch --all --prune` before resolving refs.

2. **Resolve the target** (typical script-style resolution)
   - Local branch → checkout
   - `origin/<name>` → `git checkout -b <name> origin/<name>`
   - Numeric **only** → treat as MR: `git log --merges --grep="Merge request.*<n>"` then checkout that commit; fall back to `git log --grep="<n>"` as needed
   - Further fallbacks: merge commits mentioning the string, partial `git branch -a` match, prefix match — mirror whatever your project’s `review.sh` documents, or use reasonable git discovery and explain what you did in **Assumptions**

3. **Base branch**
   - Default **`develop`** unless the user or project specifies otherwise.
   - If the project uses another integration branch, use `REVIEW_BASE` / user-specified base and state it in the review **Assumptions** section.

4. **Build the diff** (typical script-style logic)
   - If **HEAD is a merge commit**: prefer `git diff --diff-filter=MD <first-parent>..HEAD`
   - Else: `git diff --diff-filter=MD develop...HEAD` (or `BASE...HEAD`)
   - Fallbacks: `develop...<original-branch-arg>`, then `git merge-base develop HEAD`, then `develop..HEAD`
   - **Important:** `--diff-filter=MD` includes **modified and deleted only** — **new files are omitted**. For a fuller MR review, also consider `git diff develop...HEAD` (no filter) or `ACM` and mention which diff was used in **Assumptions**.

5. **Prompt and review**
   - Read [references/review-prompt-template.md](references/review-prompt-template.md), replace `<<<GIT_DIFF>>>` with the unified diff.
   - **Perform the review in this session** following that template exactly (same default model as other Cursor skills).

6. **Deliverable**
   - Same structure as required by the template (executive summary through PATCH block). Offer to write **`code_review.md`** in the repo if the user wants a saved artifact.

7. **Assumptions (template section 9 / 10)**
   - State explicitly that the review was produced by the **session default model** (in Cursor), not Ollama, unless fallback was used.

8. **After checkout**
   - Warn if on **detached HEAD** or a different branch; suggest `git checkout develop` (or the chosen base) or `git checkout -` when done.

## Fallback — `./review.sh` + Ollama

Use **only** when **`./review.sh` exists** at the repo root **and** the user **asks for Ollama** / **local model** / **`review.sh`**, or wants **exact** script outputs (`prompt.txt` + `code_review.md` from Ollama) without relying on the chat model.

From the **repository root**:

1. Same **clean working tree** precondition as above.
2. Run:

   ```bash
   ./review.sh <branch-or-mr-or-identifier>
   ```

   Optional discovery (if the script supports it):

   ```bash
   ./review.sh --list-merged
   ```

3. **Outputs** (as implemented in the script)
   - `prompt.txt` — filled prompt including diff
   - `code_review.md` — Ollama model output (ANSI stripped)

4. Model is whatever **`review.sh`** sets (`MODEL=...`); mention that when summarizing script results.

5. **Afterwards:** detached HEAD / branch switch — same reminder as in the default path.

If **`./review.sh` is missing**, do **not** invent a script; stay on the **in-session** path and say the Ollama fallback is unavailable.

## Improvements over / gaps in typical scripts (apply when sensible)

| Topic | Suggestion |
|--------|------------|
| Diff completeness | For reviews, prefer **full** `develop...HEAD` (or note MD-only omission). |
| Base branch | Support `REVIEW_BASE` or second CLI arg without hardcoding only `develop`. |
| Detached HEAD | Always warn and suggest checking out back after review. |
| Secrets | Treat diff as sensitive; do not paste into public logs without need. |
| Model | **Default:** session model — state in **Assumptions**. **Fallback:** Ollama model from `review.sh`. |

## Quality bar

- Follow the **OUTPUT REQUIREMENTS** order in the reference template (do not skip sections; use “N/A” briefly if a section does not apply).
- Respect **Mock** / **#Preview** exceptions from section 3 of the template (if still present after you customize the template).
- End with **=== PATCH START ===** … **=== PATCH END ===** when suggesting a patch.

## Canonical source for automation

If your repo maintains **`review.sh`** at the root, treat it as the source of truth for **automation** (checkout rules, heredoc). If the heredoc and `references/review-prompt-template.md` diverge, **prefer `review.sh` for the exact automation text** and update the reference file to match after intentional prompt changes.

