Review code

From NVIDIA-NeMo/DataDesigner · View interactive version

Review code is an AI agent skill from the GitHub repository NVIDIA-NeMo/DataDesigner. Perform a thorough code review of the current branch or a GitHub PR by number. The argument may start with a pull-request number to review that PR, optionally followed by focus instructions such as "focus on the API changes"; with no number, the current branch is reviewed.

How to use this skill

Skill file

Review Code Changes

Perform a comprehensive code review of either the current branch or a specific GitHub pull request.

Arguments

$ARGUMENTS determines the review mode:

PR mode — first argument is a number:

Branch mode — no number, or only instructions:

Additional instructions work in both modes:

Step 1: Gather Changes

If PR mode (argument starts with a number)

Run these commands in parallel using gh:

  1. PR details: gh pr view <number> --json title,body,author,baseRefName,headRefName,state,additions,deletions,changedFiles,commits,url
  2. PR diff: gh pr diff <number>
  3. PR files: gh pr diff <number> --name-only
  4. PR commits: gh pr view <number> --json commits --jq '.commits[].messageHeadline'
  5. Existing inline review comments: 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'

  1. Repo info: 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:

If Branch mode (no number)

First, fetch the base branch to ensure the remote ref is current:

  1. Fetch base: git fetch origin <base>

Then run these commands in parallel:

  1. Current branch: git branch --show-current
  2. Commits on branch: git log origin/<base>..HEAD --oneline
  3. File changes summary: git diff --stat origin/<base>..HEAD
  4. Full diff: git diff origin/<base>..HEAD
  5. Uncommitted changes: git status --porcelain
  6. Merge base: git merge-base origin/<base> HEAD

Where <base> is main unless overridden in arguments.

Important checks:

Step 2: Load Project Guidelines

Read the following files at the repository root to load the project's standards and conventions:

Documentation sources (load when the changeset touches matching areas):

Use these guidelines as the baseline for the entire review. Project-specific rules take precedence over general best practices.

Step 3: Understand the Scope

Before diving into details, build a mental model:

  1. Read the PR description (PR mode) or commit messages to understand the stated intent
  2. Read each commit message to understand the progression of changes
  3. Group changed files by module/package to identify which areas are affected
  4. Identify the primary goal (feature, refactor, bugfix, etc.)
  5. Note cross-cutting concerns (e.g., a rename that touches many files vs. substantive logic changes)
  6. Check existing feedback (PR mode): inspect both inline comments (Step 1, item 5) and PR-level review bodies (Step 1, item 5b) so you don't duplicate feedback already given
  7. Classify the contract impact: note whether the change introduces or modifies supported public symbols or exports, config or model schemas, serialized formats, extension/plugin boundaries, or builder APIs. If none apply, skip items 8-10 and continue to Step 3.5.
  8. Inventory the changed contract: list each changed contract element—including symbols, schema fields, serialized representations, extension entry points, and builder operations—and record its exposure, stability commitment, and expected callers or consumers
  9. Map invariant ownership: identify where each new rule is parsed, normalized, validated, resolved, and compiled so duplicated checks and unclear responsibility are visible before the detailed review
  10. Find the closest existing analogue: compare the complete neighboring API surface—not just individual names—for builder vocabulary, type precision, export strategy, errors, and contract clarity

Step 3.5: Structural Impact (if available)

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:

violations, and cluster spread

codebase (high blast radius if changed)

layering rule (interface -> engine -> config)

If the file exists, read it and use it to calibrate your review:

Verify backward compatibility for god nodes. Check that cross-package

changes don't break existing callers.

inferred edges) as at least Warnings. Use Critical when the violation

breaks packaging or establishes a foundational public boundary in the

wrong layer.

can focus more on correctness (Pass 1), but still perform the mandatory

public-contract checks below when applicable.

If the file does not exist (e.g. local branch review), skip this step.

Step 4: Review Each Changed File (Multi-Pass)

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.

Pass 1: Correctness & Logic

Read each changed file in full (not just the diff), but evaluate only the new or modified code:

Pass 2: Design, Architecture & API

Re-read the changed files with a focus on structure and design of the new/modified code:

Public interface inventory (mandatory when Step 3 identifies contract impact):

Review every item in the Step 3 inventory individually, using the invariant map and neighboring analogue built there. Do not infer that a coherent-looking module implies a coherent public API.

Boundary and representation checks:

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 Fern docs:

  1. Identify the closest architecture/<topic>.md (and any obvious fern/versions/latest/pages/ pages) for that subsystem.
  2. If the PR also edits those docs, sanity-check that the edits match the code.
  3. If the PR does not edit docs but the change contradicts what architecture/ or Fern docs currently assert, 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.
  4. Skip this check for pure refactors with no observable behavior change, typo-only PRs, or changes already limited to documentation.

The local search-docs skill can help locate Fern docs pages by topic when the right file is not obvious.

Pass 3: Standards, Testing & Polish

Final pass focused on project conventions and test quality for new/modified code only:

Testing:

Project 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.

Step 5: Run Linter

Run 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-all or uv run ruff check (and ruff format --check) without file arguments.

For new or substantially expanded production modules, also use complexity rules as an exploratory signal:

.venv/bin/ruff check --select C901,PLR0912,PLR0913,PLR0915 <changed-production-files>

Do not report a metric violation by itself. Use it to identify functions or modules that need a closer cohesion, responsibility, and maintainability review, then report the concrete design problem if one exists.

Expect broad signals in config- or builder-heavy modules; pursue a violation only when it coincides with a concrete cohesion or ownership concern.

If the branch isn't checked out locally (e.g., external fork in PR mode), skip this step and note it in the review.

Tone

Write as a supportive teammate, not a gatekeeper. The goal is to help the author ship great code, not to prove you found problems.

Step 6: Produce the Review

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, include Open Questions only with Needs discussion, and omit Residual Risk when empty, 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.

Summary

1-2 sentence description of what the changes accomplish. In PR mode, note whether the implementation matches the stated intent in the PR description.

Findings

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.

Critical — Let's fix these before merge

Issues that would cause bugs, data loss, security vulnerabilities, or broken functionality; also foundational flaws in a new or materially changed public, serialized, or extension contract that should block merge because correcting them after release would require a breaking compatibility change.

Warnings — Worth addressing

Significant design issues that are not foundational compatibility blockers, missing error handling, test gaps, or violations of project standards that could cause problems later.

Suggestions — Take it or leave it

Style improvements, minor simplifications, or optional enhancements that would improve code quality.

What Looks Good

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.

Open Questions (Needs discussion only)

State the material question, why it affects compatibility or merge readiness, and the team decision needed.

Residual Risk (optional)

Note validation gaps or lower-impact uncertainty that do not change merge readiness. If a risk is concrete enough to require action before merge, report it as a finding instead.

Verdict

Choose the verdict that matches the highest severity confirmed finding in the review. If there are no confirmed Critical or Warning findings but a design question material to compatibility or merge readiness cannot be resolved without team input, use Needs discussion.

A confirmed foundational contract flaw is Critical and requires Needs changes. Reserve Needs discussion for material uncertainty that requires team input. Lower-impact uncertainty belongs in Residual Risk and does not preclude Ship it or Ship it (with nits).

Signature (PR mode only)

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.


Step 7: Post the Review (PR mode only)

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.


Review Principles

Do not flag (focus on what CI won't catch):

Edge Cases

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.