# Code Review Github

> Use when perform code review for GitHub pull requests and post

- **Type:** Skill
- **Install:** `agentstack add skill-pekral-cursor-rules-code-review-github`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [pekral](https://agentstack.voostack.com/s/pekral)
- **Installs:** 0
- **Category:** [Developer Tools](https://agentstack.voostack.com/c/developer-tools)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [pekral](https://github.com/pekral)
- **Source:** https://github.com/pekral/cursor-rules/tree/master/skills/code-review-github
- **Website:** https://pekral.cz

## Install

```sh
agentstack add skill-pekral-cursor-rules-code-review-github
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Code Review (GitHub)

## Purpose
Run a full code review for GitHub pull requests and publish findings directly to the PR.

---

## Constraints
- Apply @rules/git/general.mdc
- Apply @rules/reports/general.mdc. The **technical CR PR comment** this skill posts on the GitHub PR (Status / Counts / Findings / Refactoring / Coverage / Summary) stays in canonical English per the rule's *Exception — technical CR findings on the GitHub PR*. The **non-technical mirror** delegated to `@skills/pr-summary/SKILL.md` for every `closingIssues[]` linked GitHub issue follows the language of the source assignment. Never mix languages inside the same comment; never use bilingual *Kritické (Critical)* style parentheses.
- **Read-only skill** — never modify code, never stage / commit / push changes, and never run any git write operation (`git add`, `git commit`, `git push`, `git reset`, `git checkout -- …`, etc.). Checking out the relevant branch and `git pull` to read the latest code are **required** (the mandatory Branch checkout gate below); mutating the working tree or pushing to the remote is not. Publishing is limited to PR / linked-issue comments via `gh`.
- Output findings only (no praise)

---

## Execution

### 1. Load Context
- Load PR context by running `skills/code-review-github/scripts/load-issue.sh ` — the single deterministic entry point. Never call `gh issue view`, `gh pr view`, or `gh api /repos/.../issues/...` directly. Read PR header, description, comments, commits, files, reviews, status checks, and `closingIssues` off the resulting JSON document.
- For a single ready-to-read context brief — the issue/PR plus its body, comments, changed files, commits, reviews, CI checks, recursively-loaded linked issues/PRs, and an inventory of external URLs, rendered as Markdown — run `skills/code-review-github/scripts/gather-issue-context.sh ` instead of hand-assembling the JSON. To read only the comments as a structured array, use `skills/code-review-github/scripts/parse-comments.sh `. Both build on `load-issue.sh`, so the same exit codes and MCP fallback apply. Attachment content and the inventoried URLs are not fetched by the scripts — read them with your own tools when a finding depends on them.
- Load each linked issue (from `closingIssues[]`) the same way — pass its number or URL to the same script.
- If the script is unavailable (missing tool, exit code 2/3) fall back to the GitHub MCP server. Always prefer the MCP fallback for data the script cannot cover: review-thread / line-anchored comments, per-commit check runs, and binary attachment contents.
- If multiple PRs exist for one issue, review each independently
- **Branch checkout gate (mandatory, always).** Before running any review step, check out the PR branch (`headRefName` from the loaded JSON) and pull the latest commits — `git fetch origin`, `git checkout `, `git pull` — so the review always runs against the **actual current codebase on disk (the checked-out working tree)**, never against the `gh` remote diff in isolation. Confirm local `HEAD` equals the PR head SHA from the loaded context. If the checkout fails (missing ref, detached `HEAD`, or local changes that would be overwritten), **stop and report it** instead of reviewing from the diff. Every sub-review then reads the checked-out files.

#### Issue Context Analysis
Before reviewing code, load and analyze the full linked issue:

1. Fetch the complete GitHub issue via `skills/code-review-github/scripts/load-issue.sh ` — description, all comments, and any referenced attachments or links come off the resulting JSON document.
2. Extract from the issue:
   - **Requirements and acceptance criteria** — what the code must do
   - **Expected behavior** — how the feature or fix should work
   - **Edge cases and constraints** — mentioned by the reporter or in comments
   - **Test data** — any sample inputs, payloads, or scenarios provided in the issue
3. Use this context to evaluate whether the implementation fully satisfies the issue — not just whether the code is technically correct.
4. If the issue contains test data or test scenarios, verify they are covered by existing or new tests. Flag missing test coverage as a finding.

#### Reviewer Comment Fulfillment Gate (mandatory)

Every CR run is also a verification that the reviewer feedback **already on the PR** was actually carried out. After loading **all** PR comments, the next CR iteration must confirm that each reviewer's comment is satisfied by the current diff and that the applied change corresponds to what the reviewer asked for — not merely that no new Critical / Moderate findings appeared. This is the gate that closes the loop with `@skills/process-code-review/SKILL.md`: the previous round applies fixes, this gate verifies they match the instructions before the run can converge.

1. **Load every reviewer comment.** Read the PR's general comments and review summaries off the JSON loaded in step 1, **and** fetch the line-anchored review threads (resolved **and** unresolved) with the GraphQL `reviewThreads` connection documented in `@skills/process-code-review/SKILL.md` (*Load unresolved reviewer threads*). Page until `reviewThreads.pageInfo.hasNextPage == false` and page each thread's `comments` the same way — a truncated list breaks the "every reviewer comment" guarantee. Include human reviewers **and** review bots; exclude this skill's own status posts (the `` / `` marker bodies).
2. **Keep only actionable instructions.** Discard greetings, plain approvals (`LGTM`, `:+1:`), and questions already answered in a later reply on the same thread. The remaining set is the reviewer instructions this PR must satisfy.
3. **Verify each instruction against the checked-out diff.** For every instruction, read the code path it targets on the checked-out branch and classify it:
   - **Fulfilled** — the current diff implements exactly what the reviewer asked; the corresponding review thread is resolved or ready to be resolved.
   - **Not fulfilled** — no change implements the instruction, or the change does not match what was asked (partial fix, wrong target, or a different change that does not satisfy the reviewer's intent).
   - **Rejected / deferred with a recorded reason** — the PR author replied on the thread (or the PR description states) why the instruction is not applied; treat as resolved for this gate and carry the reason into the summary, do not raise a finding.
4. **Raise one finding per not-fulfilled instruction.** Severity **Critical** (the PR carries unaddressed review feedback). Cite the reviewer comment URL, the `file:line` the instruction targets, the instruction in one sentence, and the four reproducer fields — **Faulty Example** (the current code that still violates the instruction), **Expected Behavior** (the state the reviewer asked for), **Test Hint**, **Suggested Fix** (the change that satisfies the instruction). A free-form reviewer instruction that implies no behavior change (naming, dead code, readability) carries the Suggested Fix only and may use `n/a — ` for the snippet, mirroring the reproducer exemption in `@skills/process-code-review/SKILL.md`.
5. **Record the fulfillment verdict on the summary line:** `reviewer comments: M/N fulfilled` (M = fulfilled or rejected-with-reason, out of N actionable). When `M == N` the gate is clean; when `M  **Inline dispatch.** Each sub-review below runs **inline in this wrapper's context** — invoke each skill directly (`@skills//SKILL.md` with any `MODE=cr` flag), passing the PR URL / number and the branch already checked out, and declare the publishing contract for this CR run (quiet vs publish; see step 4). Each invoked skill must return its findings as the canonical markdown block (`## Assignment Compliance` block, Critical / Moderate / Minor lists with reproducer fields, refactoring proposals). The CR wrapper then assembles the outputs into the final PR comment + linked-issue summary. Run the sub-reviews **one at a time** — do not dispatch them as parallel subagents.
>
> The mysql-problem-solver / race-condition-review / refactor-entry-point-to-action conditionals follow the same rule: when their trigger fires, invoke them inline after the always-run set, still one at a time.

- Always run (inline, one at a time):
    - @skills/assignment-compliance-check/SKILL.md — non-technical business-logic vs assignment check. The skill **does not publish anywhere itself** — it returns either the assembled `## Assignment Compliance` markdown block (only when at least one Critical gap exists), the status `no critical gaps — assignment compliance block omitted` (when the implementation satisfies every stated requirement), or the status `no linked issue — assignment compliance skipped` (when `closingIssues[]` is empty). The CR wrapper passes the returned block as an embedded block to `@skills/pr-summary/SKILL.md` **only when a block is returned** so the linked-issue audience reads **one consolidated comment** per CR run (per issue #498) — on either skip status the wrapper embeds nothing and surfaces the status on the PR comment summary line. **Do not embed** the block into the PR comment — keep the PR comment focused on technical findings and surface the consolidated-comment status in the summary line.
    - @skills/code-review/SKILL.md
    - @skills/analyze-problem/SKILL.md — **always run, scoped to assignment conformance**, invoked inline and read-only (analysis-only — no plan artifact, no code / git writes). Compares the loaded issue requirements / acceptance criteria / expected behavior against what the PR diff actually implements and raises every unmet requirement as a **Critical** finding with reproducer fields. Canonical definition lives in `@skills/code-review/SKILL.md` Specialized Reviews → Always run; it is distinct from the per-Critical-finding verification (issue #537) and must not duplicate gaps already raised by `assignment-compliance-check`.
    - @skills/security-review/SKILL.md
    - @skills/class-refactoring/SKILL.md **with `MODE=cr`** — read-only refactoring lens scoped to the PR diff. Surface DRY duplication and tech-debt-reducing changes that apply to lines actually touched by the PR. `MODE=cr` guarantees no code changes, commits, fixers, or review chaining. Do not propose changes outside the diff.

- Run conditionally:
    - **Diff is a refactoring (behavior-preserving structural change per `@rules/refactoring/general.mdc`) → run the full refactoring skill set read-only.** When the PR restructures existing code without adding a feature or changing observable behavior, additionally invoke `@skills/refactor-entry-point-to-action/SKILL.md` **with `MODE=cr`** to surface the entry-point → Action proposals. **Both refactoring skills run read-only — no code changes, no commits, no fixers, no review chaining — `MODE=cr` enforces this.** Fold their output into the **Refactoring (DRY / Tech Debt Reduction)** section (in-scope) and **Refactoring Proposals** section (out-of-scope) of the PR comment.
    - **Database operations detected in the diff → `@skills/mysql-problem-solver/SKILL.md` is mandatory.** Trigger pattern list is owned by `@skills/code-review/SKILL.md` Specialized Reviews (raw SQL, Eloquent / query-builder calls, eager loads, model scopes, ModelManager / Repository methods, migrations, seeders, DynamoDB / NoSQL access). Capture its findings and surface them in the published PR comment under the dedicated `## Database Analysis` section (see Output Rules) — never silently fold them into the Critical / Moderate / Minor buckets.
    - Shared state → @skills/race-condition-review/SKILL.md
    - Third-party API or service changes → ensure the **Third-Party API & Service Analysis** step from `@skills/code-review/SKILL.md` is executed for the diff

#### Refactoring & Tech Debt (DRY) Analysis (PR diff only)

1. Restrict the analysis to lines added or modified in the PR — never review untouched code.
2. For each changed block, apply `@skills/class-refactoring/SKILL.md` (run with `MODE=cr` — read-only) and look for:
   - duplicated logic that already exists elsewhere (DRY) — verify the change reuses existing logic instead of introducing a parallel implementation, per `@rules/code-review/general.mdc` Reuse Existing Logic section
   - data shaping repeated across Actions/Services/controllers/jobs/listeners/Livewire/commands
   - oversized methods, deep nesting, mixed responsibilities introduced or amplified by the change
   - when the PR is itself a refactoring (see the conditional trigger in **Run Reviews**), also fold in the entry-point → Action proposals from `@skills/refactor-entry-point-to-action/SKILL.md` run with `MODE=cr`
3. Each finding must include the file path, the affected line range, and a concrete refactoring that *reduces* tech debt.
4. In-scope refactorings go into the **Refactoring (DRY / Tech Debt Reduction)** section of the PR comment template. Out-of-scope structural problems still belong in **Refactoring Proposals**.

### 4. Post Results

> **Quiet mode (loop iterations from `@skills/process-code-review/SKILL.md`):** when the caller explicitly requests "do not publish; return findings as in-memory markdown for this loop iteration only", **skip the entire Post Results step** — do not post the PR comment, do not post the linked-issue summary. Return the assembled review markdown to the caller and stop. Only the very last (publishing) call from `process-code-review` after convergence runs Post Results in full.

#### Always-new comment (per CR run)
- Every CR run posts a **fresh PR comment**. The helper never edits a prior comment in place — each run produces its own self-contained entry so reviewers see one comment per run, in chronological order. The hidden marker `` is still appended to the body for traceability (auto-appended by the helper), but it no longer drives an upsert lookup.
- Publish via `skills/code-review-github/scripts/upsert-comment.sh  -` (body on stdin). The helper detects the current actor (`gh api user --jq .login`), appends the marker, and POSTs a new comment. The published URL is emitted on stdout; the action (`created`) on stderr — log it in the PR comment summary line.
- If the helper exits with code 2 (missing tool) or 3 (API failure), fall back to the GitHub MCP server's `addIssueComment` — also as a fresh post. Never quote / reply to an earlier CR comment and never call `updateIssueComment` to edit one in place; the always-new-comment convention replaces the previous in-place edit flow.

#### Format
- Critical → Moderate → Minor → Refactoring (DRY / Tech Debt Reduction)
- Include file + line in the finding body
- Include actionable fix
- Post all findings inside the single PR comment — never as line-anchored review comments.

- If no findings:
    - post the header block (Status / Counts / Last updated / Issue tracker summary) and the final `Summary` line only. The `Coverage:` header line, the `## Coverage` section, and the `coverage …` slot in the summary line are all dropped when every changed line is at 100% coverage and the tool ran successfully — only render them when the coverage gate produced uncovered changed lines (Critical findings) or unavailable / non-runnable coverage tooling (Critical finding). Omit every other section entirely. Do not append a "No findings identified" line — the Counts line `Critical 0 · Moderate 0 · Minor 0 · Refactoring 0` already signals the clean state and the omitted sections confirm there is nothing to fix.

#### Linked-issue consolidated summary (mandatory — single comment per linked issue)
- After posting the PR comment, delegate the **single consolidated summary on every linked issue** listed in `closingIssues[]` of the JSON loaded in step 1 to `@skills/pr-summary/SKILL.md`. This CR skill must not author its own non-technical template — the goal is a uniform *"Authors / Available behind / Summary of changes / How to test"* output across both trackers that non-technical project managers understand

…

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [pekral](https://github.com/pekral)
- **Source:** [pekral/cursor-rules](https://github.com/pekral/cursor-rules)
- **License:** MIT
- **Homepage:** https://pekral.cz

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-pekral-cursor-rules-code-review-github
- Seller: https://agentstack.voostack.com/s/pekral
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
