Merge request check — Python
Goal
Replicate an MR review script flow in git for a Python codebase: resolve the
change (branch name, MR number, or merge commit), diff against the integration branch
(default main), verify the branch (run its tests + ruff), feed the diff into the
Python review prompt in references/review-prompt-template.md,
and produce code_review.md-style output (structured sections, prioritized findings, test
suggestions).
This is the Python sibling of the merge-request-check skill. The Swift one targets
iOS/SwiftUI and defaults to develop; this one targets Python and defaults to main.
Default reviewer: the same in-session AI model the editor uses for other skills (this
chat/agent). Do not assume Ollama.
This skill is report-only. Produce the review; never modify the working tree beyond the
checkout needed to run tests. If the user wants the mechanical findings applied, offer it as a
follow-up (or point them at /code-review --fix) — do not edit as part of the review.
Adapting for your repository
- Prompt / domain: Edit references/review-prompt-template.md
for project-specific rules. It encodes the Humanit house ruleset (Clean Architecture, Clean
Code, DDD/ordlista, TDD guardrail tests, CI gates). If a project's
CLAUDE.md adds rules,
fold them in.
- Base branch: Default
main. If the project uses develop/trunk, follow the user or
REVIEW_BASE and state it in Assumptions.
- No
review.sh assumption: stay on the in-session path; there is no Ollama fallback here.
Default — in-session review
Git safety
- Require a clean tree (
git status). If dirty, stop and tell the user to commit, stash, or
discard — do not clobber uncommitted work.
git fetch --all --prune before resolving refs.
- Record the starting branch so you can restore it afterward.
Resolve the target
- Local branch → checkout.
origin/<name> → git checkout -b <name> origin/<name>.
- Numeric only → treat as MR:
git log --merges --grep="Merge request.*<n>", checkout that
commit; fall back to git log --grep="<n>".
- Further fallbacks: merge commits mentioning the string, partial
git branch -a match,
prefix match — explain what you did in Assumptions.
Base branch — default main unless the user/project says otherwise; state it in
Assumptions.
Build the diff — prefer the full diff so new files are included:
git diff <base>...<branch> (three-dot: changes on the branch since it diverged).
- If HEAD is a merge commit, prefer
git diff --diff-filter=MD <first-parent>..HEAD.
- Note which diff form was used in Assumptions. Avoid
--diff-filter=MD alone for a
full review — it omits new files (a new module + its new test would both vanish).
Verify the branch (bake this in — do not skip)
- Check out the branch (tree is clean per step 1).
- Run the affected tests, then the suite:
pytest -q -m "not integration" (exclude live/DB
integration markers). Also run the changed files' tests explicitly.
- Run the lint gate:
ruff check <changed .py files>.
- Report the actual results (pass counts, any failures) in the review — a green suite is what
lets a phase gate / user story be called "Ready for test" or "Done".
Prompt and review
- Read references/review-prompt-template.md, replace
<<<GIT_DIFF>>> with the unified diff, and, for a real sanity check, read the full
changed source files on the branch — not just the hunks.
- Perform the review in this session following that template exactly.
Deliverable — the template's structure (executive summary through action list). Offer to
write code_review.md in the repo if the user wants a saved artifact.
Assumptions section — state base branch, which diff form was used, that the review was
produced by the session default model, and the test/lint results.
After checkout — restore the starting branch (git checkout -), warn on detached HEAD,
and confirm the tree is clean.
Quality bar
- Follow the template's OUTPUT REQUIREMENTS order; use "N/A" briefly for a section that
does not apply.
- Ground findings in the project's own
CLAUDE.md where relevant (dependency approval scope,
guardrail tests, ordlista/ubiquitous language, CI gates) — cite the rule, not a generic
preference.
- Respect the Mock / fixture exceptions in section 3 of the template.
- Never invent functions/types without labeling
[ASSUMED].
- Report-only: end without a patch block unless the user explicitly asks for one.
Improvements over typical scripts (apply when sensible)
| Topic |
Suggestion |
| Diff completeness |
Prefer full base...branch so new modules + their tests are included. |
| Verification |
Always run pytest -m "not integration" + ruff and report results. |
| Base branch |
Support REVIEW_BASE / a user-specified base; do not hardcode only main. |
| Sanity check |
Read whole changed files on the branch, not only diff hunks. |
| Safety |
Clean-tree precondition; restore the starting branch when done. |
| Secrets |
Treat the diff as sensitive; never paste secrets into logs or output. |
1---2name: merge-request-check-python3description: Merge-request / PR review workflow for Python projects (Humanit house ruleset: Clean Architecture, DDD, TDD, CI gates). Resolve a branch or MR number against an integration branch (default main), build a unified diff, run the branch's tests + ruff, and produce a structured review using the session default model and the bundled Python prompt template. Use when the user says merge request check, MR review, /merge-request-check, or wants a diff-based PR review before merge on a Python repo. For iOS/Swift repos use merge-request-check instead.4---56# Merge request check — Python78## Goal910Replicate an **MR review script** flow in **git** for a **Python** codebase: **resolve** the11change (branch name, MR number, or merge commit), **diff against the integration branch**12(default `main`), **verify** the branch (run its tests + `ruff`), feed the diff into the13**Python review prompt** in [references/review-prompt-template.md](references/review-prompt-template.md),14and produce **`code_review.md`-style output** (structured sections, prioritized findings, test15suggestions).1617This is the Python sibling of the `merge-request-check` skill. The Swift one targets18iOS/SwiftUI and defaults to `develop`; this one targets Python and defaults to `main`.1920**Default reviewer:** the **same in-session AI model** the editor uses for other skills (this21chat/agent). Do **not** assume Ollama.2223**This skill is report-only.** Produce the review; never modify the working tree beyond the24checkout needed to run tests. If the user wants the mechanical findings applied, offer it as a25follow-up (or point them at `/code-review --fix`) — do not edit as part of the review.2627## Adapting for your repository2829- **Prompt / domain:** Edit [references/review-prompt-template.md](references/review-prompt-template.md)30 for project-specific rules. It encodes the Humanit house ruleset (Clean Architecture, Clean31 Code, DDD/ordlista, TDD guardrail tests, CI gates). If a project's `CLAUDE.md` adds rules,32 fold them in.33- **Base branch:** Default `main`. If the project uses `develop`/`trunk`, follow the user or34 `REVIEW_BASE` and state it in **Assumptions**.35- **No `review.sh` assumption:** stay on the in-session path; there is no Ollama fallback here.3637## Default — in-session review38391. **Git safety**40 - Require a clean tree (`git status`). If dirty, stop and tell the user to commit, stash, or41 discard — do not clobber uncommitted work.42 - `git fetch --all --prune` before resolving refs.43 - Record the starting branch so you can restore it afterward.44452. **Resolve the target**46 - Local branch → checkout.47 - `origin/<name>` → `git checkout -b <name> origin/<name>`.48 - Numeric only → treat as MR: `git log --merges --grep="Merge request.*<n>"`, checkout that49 commit; fall back to `git log --grep="<n>"`.50 - Further fallbacks: merge commits mentioning the string, partial `git branch -a` match,51 prefix match — explain what you did in **Assumptions**.52533. **Base branch** — default `main` unless the user/project says otherwise; state it in54 **Assumptions**.55564. **Build the diff** — prefer the **full** diff so new files are included:57 - `git diff <base>...<branch>` (three-dot: changes on the branch since it diverged).58 - If HEAD is a merge commit, prefer `git diff --diff-filter=MD <first-parent>..HEAD`.59 - Note which diff form was used in **Assumptions**. Avoid `--diff-filter=MD` alone for a60 full review — it omits new files (a new module + its new test would both vanish).61625. **Verify the branch (bake this in — do not skip)**63 - Check out the branch (tree is clean per step 1).64 - Run the affected tests, then the suite: `pytest -q -m "not integration"` (exclude live/DB65 integration markers). Also run the changed files' tests explicitly.66 - Run the lint gate: `ruff check <changed .py files>`.67 - Report the actual results (pass counts, any failures) in the review — a green suite is what68 lets a phase gate / user story be called "Ready for test" or "Done".69706. **Prompt and review**71 - Read [references/review-prompt-template.md](references/review-prompt-template.md), replace72 `<<<GIT_DIFF>>>` with the unified diff, and, for a real sanity check, **read the full73 changed source files on the branch** — not just the hunks.74 - Perform the review in this session following that template exactly.75767. **Deliverable** — the template's structure (executive summary through action list). Offer to77 write `code_review.md` in the repo if the user wants a saved artifact.78798. **Assumptions section** — state base branch, which diff form was used, that the review was80 produced by the session default model, and the test/lint results.81829. **After checkout** — restore the starting branch (`git checkout -`), warn on detached HEAD,83 and confirm the tree is clean.8485## Quality bar8687- Follow the template's **OUTPUT REQUIREMENTS** order; use "N/A" briefly for a section that88 does not apply.89- Ground findings in the project's own `CLAUDE.md` where relevant (dependency approval scope,90 guardrail tests, ordlista/ubiquitous language, CI gates) — cite the rule, not a generic91 preference.92- Respect the **Mock / fixture** exceptions in section 3 of the template.93- Never invent functions/types without labeling `[ASSUMED]`.94- Report-only: end without a patch block unless the user explicitly asks for one.9596## Improvements over typical scripts (apply when sensible)9798| Topic | Suggestion |99|-------|------------|100| Diff completeness | Prefer full `base...branch` so new modules + their tests are included. |101| Verification | Always run `pytest -m "not integration"` + `ruff` and report results. |102| Base branch | Support `REVIEW_BASE` / a user-specified base; do not hardcode only `main`. |103| Sanity check | Read whole changed files on the branch, not only diff hunks. |104| Safety | Clean-tree precondition; restore the starting branch when done. |105| Secrets | Treat the diff as sensitive; never paste secrets into logs or output. |