ワンクリックで
review-code
// Perform a thorough code review of the current branch or a GitHub PR by number.
// Perform a thorough code review of the current branch or a GitHub PR by number.
Maintain the NeMo Data Designer Fern docs site under fern/. Use for any documentation change. Triggered by: "edit docs", "add doc page", "update docs", "rename page", "fix broken link", "add redirect", "preview docs", "publish docs", "regenerate notebooks", "update dev note", any request that touches `fern/`.
Use when the user wants to create a dataset, generate synthetic data, or build a data generation pipeline.
Create a GitHub PR with a well-formatted description matching the repository PR template (flat Changes by default; optional Added/Changed/Removed/Fixed grouping)
Commit current changes with a clear, descriptive message
Search local documentation in the docs/ folder for content related to a topic
Search GitHub issues, discussions, and PRs for content related to a topic
| name | review-code |
| description | Perform a thorough code review of the current branch or a GitHub PR by number. |
| argument-hint | [pr-number] [special instructions] |
| disable-model-invocation | true |
| metadata | {"internal":true} |
Perform a comprehensive code review of either the current branch or a specific GitHub pull request.
$ARGUMENTS determines the review mode:
PR mode — first argument is a number:
366 — review PR #366366 focus on the API changes — review PR #366 with a focus areaBranch mode — no number, or only instructions:
maincompare against develop — review against a different basefocus on the API changes — review current branch with a focus areaAdditional instructions work in both modes:
be strict about type annotationsskip style nitsRun these commands in parallel using gh:
gh pr view <number> --json title,body,author,baseRefName,headRefName,state,additions,deletions,changedFiles,commits,urlgh pr diff <number>gh pr diff <number> --name-onlygh pr view <number> --json commits --jq '.commits[].messageHeadline'gh api repos/{owner}/{repo}/pulls/<number>/comments --paginate --jq '.[].body'
5b. Existing PR-level reviews (top-level review bodies from "Review changes"): gh api repos/{owner}/{repo}/pulls/<number>/reviews --paginate --jq '.[].body'gh repo view --json nameWithOwner -q '.nameWithOwner'Then get the PR branch locally for full file access. Prefer a worktree so your current branch and uncommitted work are untouched:
git fetch origin pull/<number>/head:pr-<number> --force
git worktree add /tmp/review-<number> pr-<number>
# Cleanup when done: git worktree remove /tmp/review-<number> && git branch -D pr-<number>
If worktrees aren't suitable, you can use gh pr checkout <number> (this switches your current branch — only if you have no uncommitted work). Run the rest of the review from /tmp/review-<number>.
If checkout isn't possible (e.g., external fork), use gh api to fetch file contents:
gh api repos/{owner}/{repo}/contents/{path}?ref={head-branch} --jq '.content' | base64 --decode
Important checks:
First, fetch the base branch to ensure the remote ref is current:
git fetch origin <base>Then run these commands in parallel:
git branch --show-currentgit log origin/<base>..HEAD --onelinegit diff --stat origin/<base>..HEADgit diff origin/<base>..HEADgit status --porcelaingit merge-base origin/<base> HEADWhere <base> is main unless overridden in arguments.
Important checks:
Read the following files at the repository root to load the project's standards and conventions:
AGENTS.md — architecture, layering, core design principles, structural invariantsSTYLEGUIDE.md — code style rules (formatting, naming, imports, type annotations), design principles (DRY, KISS, YAGNI, SOLID), common pitfalls, lazy loading and TYPE_CHECKING patternsDEVELOPMENT.md — testing patterns and expectationsDocumentation sources (load when the changeset touches matching areas):
architecture/*.md — subsystem maps aligned with packages/ (e.g. engine/mcp/ ↔ architecture/mcp.md). Use to verify the PR does not leave recorded architecture false relative to new behavior.docs/ — published user-facing documentation. Cross-check when public API, CLI behavior, or config surface changes would affect what readers are told.Use these guidelines as the baseline for the entire review. Project-specific rules take precedence over general best practices.
Before diving into details, build a mental model:
Check for a pre-computed structural impact analysis at
/tmp/structural-impact-<pr-or-branch>.md. This file is produced by
graphify AST extraction and contains:
If the file exists, read it and use it to calibrate your review:
If the file does not exist (e.g. local branch review), skip this step.
Perform at least 2-3 passes over the changed files. Each pass has a different focus — this catches issues that a single read-through would miss.
Scope rule: Only flag issues introduced or modified by this changeset. Read the full file for context, but do not report pre-existing patterns, style issues, or design choices that were already present before this branch/PR. If existing code was merely moved without modification, don't flag it. The goal is to review what the author changed, not audit the entire file.
Read each changed file in full (not just the diff), but evaluate only the new or modified code:
if index: when index can be 0)getattr(obj, attr, fallback) or .get() on Pydantic models where the field always exists with a defaultRe-read the changed files with a focus on structure and design of the new/modified code:
Any)?Documentation alignment (same pass — scoped, not a full docs audit):
When code under packages/ changes behavior, structure, or public contracts in a way that a maintainer would reasonably describe in architecture/ or docs/:
architecture/<topic>.md (and any obvious docs/ pages) for that subsystem.architecture/ or docs/ currently asserts, flag it (Warnings if contributors rely on that text; Suggestions if impact is narrow). Suggest updating the same PR or an explicit follow-up issue.The local search-docs skill can help locate docs/ pages by topic when the right file is not obvious.
Final pass focused on project conventions and test quality for new/modified code only:
Testing:
@pytest.mark.parametrizeProject Standards (from AGENTS.md and STYLEGUIDE.md) — apply to new/modified code only:
Verify the items below on lines introduced or changed by this branch. Refer to AGENTS.md and STYLEGUIDE.md loaded in Step 2 for details and examples.
make update-license-headers; don't treat as critical if CI enforces this)from __future__ import annotations in new fileslist[str], str | None — not List[str], Optional[str])lazy_heavy_imports + TYPE_CHECKINGRun the linter on all changed files (requires local checkout). Use the venv directly to avoid sandbox permission issues in some environments (e.g. Claude Code):
.venv/bin/ruff check <changed-files>
.venv/bin/ruff format --check <changed-files>
Note: This runs ruff only on the changed files for speed. For a full project-wide check, use
make check-alloruv run ruff check(andruff format --check) without file arguments.
If the branch isn't checked out locally (e.g., external fork in PR mode), skip this step and note it in the review.
Write as a supportive teammate, not a gatekeeper. The goal is to help the author ship great code, not to prove you found problems.
Write the review as GitHub-flavored Markdown ready to post as a PR comment. Save it to a temporary file outside the repository (e.g. /tmp/review-<pr-or-branch>.md) so it doesn't pollute git status. Do not commit this file; treat it as ephemeral.
Use the template below exactly — omit a severity section if it has no findings, but keep all other sections.
Open with a brief, genuine thank-you to the author (e.g. "Thanks for putting this together, @author!" or "Nice work on this one, @author — here are my thoughts."). Keep it to one sentence; don't over-do it. Do NOT add a top-level title like "## Code Review" — the comment speaks for itself.
1-2 sentence description of what the changes accomplish. In PR mode, note whether the implementation matches the stated intent in the PR description.
Group findings by severity. Omit any severity section that has no findings. Format each finding as a heading + bullet list — do NOT use numbered lists:
**`path/to/file.py:42` — Short title**
- **What**: Concise description of the issue.
- **Why**: Why it matters.
- **Suggestion**: Concrete fix or improvement (with code snippet when helpful).
Separate each finding with a blank line. Use bold file-and-title as a heading line, then bullet points for What/Why/Suggestion. Never use numbered lists (1., 2.) for findings or their sub-items.
Issues that would cause bugs, data loss, security vulnerabilities, or broken functionality.
Design issues, missing error handling, test gaps, or violations of project standards that could cause problems later.
Style improvements, minor simplifications, or optional enhancements that would improve code quality.
Call out 2-3 things done well (good abstractions, thorough tests, clean refactoring, etc.). Be genuine — positive feedback is part of a good review and helps the author know what to keep doing.
Choose the verdict that matches the highest severity finding in the review:
When the review will be posted as a PR comment, end with a signature line so readers can distinguish agent-generated reviews from human ones:
---
*This review was generated by an AI assistant.*
In branch mode (local only), omit the signature.
In PR mode, display the review to the user and note the temp file path (/tmp/review-<number>.md). Then ask if they'd like you to post it as a PR comment. Only run the command after the user confirms:
gh pr comment <number> --body-file /tmp/review-<number>.md
In branch mode, skip this step — display the review to the user and note the temp file path.
items is empty" not "handle edge cases better"Do not flag (focus on what CI won't catch):
make check-all" if relevant, but don't list every style nitgh api to fetch file contents and skip the linter step