|
| 1 | +--- |
| 2 | +name: adr-review |
| 3 | +description: Review a pull/merge request's new code against the connect-widget Architecture Decision Records (ADRs). Use when asked to "ADR review", "review this PR against the ADRs", "check ADR compliance", or before approving a PR/MR in the connect-widget (GitHub) or the sibling GitLab repo that follows the same standards. Reviews styling (CSS Modules / MUI), testing (Vitest/MSW/Cypress), folder structure (screaming architecture), PR size, and undocumented architecture choices. |
| 4 | +--- |
| 5 | + |
| 6 | +# ADR Review |
| 7 | + |
| 8 | +Review the **new code** in a pull request (GitHub) or merge request (GitLab) against |
| 9 | +the connect-widget Architecture Decision Records and report any violations. |
| 10 | + |
| 11 | +The connect-widget ADRs are the single **canonical** source of truth. Two repos are |
| 12 | +expected to follow them: `connect-widget` (GitHub) and a sibling GitLab repo. This |
| 13 | +skill can review either — it always evaluates against the connect-widget ADRs. |
| 14 | + |
| 15 | +## Scope: what to review |
| 16 | + |
| 17 | +Review **only the code the PR adds or changes** (the diff), not the whole repo. ADR |
| 18 | +0002 states that a PR is judged on whether its *new* code adheres to the ADRs; you |
| 19 | +are not auditing pre-existing code except where the PR modifies it. When a PR edits a |
| 20 | +line that was already non-conforming, note that conforming it would be ideal but is |
| 21 | +not blocking unless the PR is making that area worse. |
| 22 | + |
| 23 | +## Step 1 — Load the canonical ADRs (always do this first) |
| 24 | + |
| 25 | +The ADRs evolve, so read them live rather than relying on this skill's summary. Load |
| 26 | +them from the connect-widget repo, trying these sources in order until one works: |
| 27 | + |
| 28 | +1. If `architectureDecisionRecords/` exists in the current working directory (you are |
| 29 | + in the connect-widget repo), read every `*.md` file in it. |
| 30 | +2. If the env var `CONNECT_WIDGET_ADR_PATH` is set, read the `*.md` files there. |
| 31 | +3. If a local connect-widget checkout is known, read its `architectureDecisionRecords/`. |
| 32 | +4. Fall back to fetching them from GitHub (works from any repo, e.g. the GitLab one): |
| 33 | + ```bash |
| 34 | + gh api repos/mxenabled/connect-widget/contents/architectureDecisionRecords \ |
| 35 | + --jq '.[] | select(.name|endswith(".md")) | .name' \ |
| 36 | + | while read -r f; do |
| 37 | + echo "===== $f ====="; |
| 38 | + gh api "repos/mxenabled/connect-widget/contents/architectureDecisionRecords/$f" \ |
| 39 | + --jq '.content' | base64 --decode; |
| 40 | + done |
| 41 | + ``` |
| 42 | + |
| 43 | +Read `reference/adr-checklist.md` (next to this file) for the distilled, checkable |
| 44 | +rules. The live ADR files win if they ever disagree with the checklist — if you spot |
| 45 | +drift, mention it. |
| 46 | + |
| 47 | +## Step 2 — Determine the target and get the diff |
| 48 | + |
| 49 | +Detect the platform from the git remote (`git remote -v`): `github.com` → GitHub, |
| 50 | +`gitlab` in the host → GitLab. |
| 51 | + |
| 52 | +Figure out what the user wants reviewed, in this priority: |
| 53 | + |
| 54 | +- **Explicit PR/MR number or URL** in the request → fetch that. |
| 55 | + - GitHub: `gh pr diff <number>` and `gh pr view <number> --json title,body,files,baseRefName,additions,deletions` |
| 56 | + - GitLab (if `glab` is installed): `glab mr diff <number>` and `glab mr view <number>` |
| 57 | + - GitLab (no `glab`): tell the user glab isn't installed and fall back to the local |
| 58 | + diff below, or ask them to check out the MR branch. |
| 59 | +- **A branch/PR is open for the current branch** → `gh pr view --json ...` + `gh pr diff`. |
| 60 | +- **Otherwise review the current branch** against its base: |
| 61 | + ```bash |
| 62 | + base=$(gh pr view --json baseRefName -q .baseRefName 2>/dev/null \ |
| 63 | + || git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null | sed 's@^origin/@@' \ |
| 64 | + || echo master) |
| 65 | + git fetch -q origin "$base" 2>/dev/null || true |
| 66 | + git diff "origin/$base...HEAD" --stat |
| 67 | + git diff "origin/$base...HEAD" |
| 68 | + ``` |
| 69 | + |
| 70 | +Also gather the list of changed files (`--name-status`) and the added-lines only |
| 71 | +(`git diff ... --unified=0`) so you can cite precise `file:line` locations. |
| 72 | + |
| 73 | +If you cannot obtain a diff, stop and tell the user what's missing (e.g. wrong repo, |
| 74 | +private MR needing glab auth) rather than reviewing nothing. |
| 75 | + |
| 76 | +## Step 3 — Review the diff against each ADR |
| 77 | + |
| 78 | +Go through the checklist in `reference/adr-checklist.md`. For each added/changed hunk, |
| 79 | +check every applicable ADR. Only flag things you can point to in the diff. Prefer |
| 80 | +being specific and actionable over exhaustive nitpicking. |
| 81 | + |
| 82 | +Assign each finding a severity: |
| 83 | +- **Blocking** — clearly violates an ADR's decision (would fail review per ADR 0002). |
| 84 | +- **Should fix** — likely violation or strongly discouraged pattern; confirm intent. |
| 85 | +- **Consider** — judgment call, style, or a heads-up (e.g. PR getting large). |
| 86 | + |
| 87 | +For anything ambiguous (folder-structure judgment calls, "is this new code or a hotfix"), |
| 88 | +say why it's ambiguous rather than asserting a violation. |
| 89 | + |
| 90 | +## Step 4 — Report the findings in chat |
| 91 | + |
| 92 | +Print a structured report. Do **not** post to the PR/MR unless the user later asks. |
| 93 | + |
| 94 | +Format: |
| 95 | + |
| 96 | +``` |
| 97 | +# ADR Review — <PR title / branch> (<N files, +X/-Y>) |
| 98 | +
|
| 99 | +**Verdict:** <Conforms ✅ | Changes needed ⚠️ | Blocking issues ❌> |
| 100 | +
|
| 101 | +## Blocking |
| 102 | +- **[ADR 0001 Styling]** `src/Foo/Foo.tsx:42` — Uses `sx` prop for styling. |
| 103 | + → Move to a CSS Module; `sx`/`xs` are only allowed for breakpoint-specific code. |
| 104 | +
|
| 105 | +## Should fix |
| 106 | +- ... |
| 107 | +
|
| 108 | +## Consider |
| 109 | +- ... |
| 110 | +
|
| 111 | +## Notes |
| 112 | +- <ADR drift, hotfix exceptions, or "no test file added for new component", etc.> |
| 113 | +``` |
| 114 | + |
| 115 | +If everything conforms, say so plainly and list what you checked so the user has |
| 116 | +confidence the review was real. If nothing in the diff is in scope for a given ADR |
| 117 | +(e.g. no styling changes), note that you checked and it didn't apply. |
| 118 | + |
| 119 | +## Notes & exceptions |
| 120 | + |
| 121 | +- **Hotfix exception (ADR 0002):** urgent production hotfixes may bypass the ADRs but |
| 122 | + must be followed by a conforming PR. If the PR looks like a hotfix, flag violations |
| 123 | + as "acceptable only if this is an urgent hotfix — file a follow-up ticket." |
| 124 | +- **Legacy code:** the repo is mid-migration (e.g. `@kyper/*` → MXUI). Editing legacy |
| 125 | + files doesn't require rewriting them, but new code must conform. |
| 126 | +- Keep the review grounded in the *diff* — never invent violations you can't cite. |
0 commit comments