Modh
AboutServicesWorkPlaybookResourcesBook a call
Book a call
Agent Skills/Universal/Code Review
Universalintermediate9 min

search-check Code Review

Run educational code reviews against your project's quality standards. Use when reviewing PRs, checking current branch before pushing, or doing batch quality sweeps across all open PRs. Applies observability, testing, SOLID, type safety, security, business logic, and clean code checks with pass/fail verdicts. Produces actionable findings with real-world impact explanations, not just "best practice" citations.

Install this skill

git submodule add https://github.com/modh-labs/playbook.git .playbook

One submodule installs all 17 skills. Reference .playbook/skills/code-review/SKILL.md from your AGENTS.md.


Code Review

Educational code review that applies your project's quality standards to diffs. Every finding explains what is wrong, why it matters (product/compliance/reliability context), and exactly how to fix it. Produces a pass/fail verdict.

When This Skill Activates

  • User invokes /review
  • User asks to "review", "check", or "audit" code changes or PRs
  • User wants a quality sweep before merging

Invocation Modes

CommandModeDiff SourceOutput
/reviewCurrent branchgit diff main...HEADTerminal report
/review 423Single PRgh pr diff 423Terminal + GitHub PR review
/review --prsAll open PRsgh pr list then loopTerminal summary + GitHub PR reviews

Review Dimensions

Seven categories. Critical findings auto-fail the review.

1. Observability

CheckCritical?What to look for
Structured loggingYesUses your project's logger, not console.log/error
Error tracking integrationYesErrors captured with domain context, not bare catch blocks that swallow
PII in error tagsYesNo emails, phones, names in searchable error tags (use metadata/context)
Tracing wrappersNoExported functions wrapped with tracing/instrumentation
Wide eventsNoPrefer fewer, attribute-rich logs over many thin logs
Span namingNoFollows consistent naming convention (db.*, http.*, function.*)

2. Testing

CheckCritical?What to look for
Test file existsYesNew/changed logic files must have corresponding tests
Auth test caseYesTests unauthorized access (no user, no org/tenant)
Validation test caseYesTests invalid input (bad schema, missing required fields)
Happy path testYesTests success case with correct service/repo calls
Error handling testNoTests failure paths, error propagation
Mock structureNoUses hoisted mocks, proper type assertions

Exemptions (tests not required):

  • Pure UI/layout changes (loading states, error boundaries, CSS-only)
  • Config file changes (bundler, linter, formatter configs)
  • Documentation-only changes (*.md)
  • Type-only changes (type definitions, generated types)
  • Generated files (migrations, code generation output)
  • Skill files (agent skills, prompt files)

3. SOLID Architecture

CheckCritical?What to look for
Layer violationYesBusiness logic calls database directly (must use service/repository layer)
Cross-boundary importYesModule imports internals from another module's directory
Wrong domain couplingYesModule uses error handling/services from wrong domain
God fileNoFile >500 lines, should split by responsibility
Side effect mixingNoOne function does DB + email + webhook + cache
Dependency directionNoDependencies point UP instead of DOWN

4. Type Safety

CheckCritical?What to look for
as anyYesUse as Record<string, unknown> or proper type guards
@ts-nocheckYesRemove, fix each error with targeted assertions
Untyped parametersNoFunction parameters should have explicit types
@ts-ignoreNoReplace with @ts-expect-error and a comment

5. Security & PII

CheckCritical?What to look for
PII in logs/tagsYesEmails, phones, names must be in metadata, not searchable tags
Missing input validationYesServer/API inputs must be validated with a schema (Zod, etc.)
Authorization bypass riskYesValidates input but doesn't verify ownership/permissions
Hardcoded secretsYesAPI keys, tokens, passwords in source code
SQL injectionYesRaw string interpolation in queries

6. Business Logic

CheckCritical?What to look for
Missing cache invalidationYesMutation without cache bust / revalidation
Side effects before commitYesEmail/webhook fires before DB write is confirmed
Missing error returnNoCatch block doesn't return error to caller
Race condition riskNoConcurrent access without optimistic locking
Stale data after mutationNoUI doesn't refresh after successful mutation

7. Clean Code

Advisory only, never auto-fails.

CheckCritical?What to look for
Dead codeNoCommented-out code, unused imports, stale compatibility shims
Duplicated patternsNoSame pattern in 3+ files, extract helper
Console statementsNoconsole.log/warn/error left in (should be structured logger)
NamingNoUnclear variable/function names

Finding Format

Every finding MUST follow this template:

### [Category] Finding Title

**What:** `file:line` -- one-line description
**Why it matters:** Product/compliance/reliability impact (never just "best practice")
**How to fix:**
  <concrete code example or step-by-step>
**Standard:** dimension name, specific check reference
**Severity:** Critical | Important | Advisory

Writing "Why it matters"

This is what makes the review educational. Always ground in real consequences:

CategoryBad "Why"Good "Why"
Observability"You should use structured logging""Bare console.log is invisible to your error tracker. When this fails at 2 AM, no alert fires and no one knows until a customer reports it"
Testing"Missing test coverage""This function handles payment state. Untested payment logic is how you get duplicate charges in production"
SOLID"Violates single responsibility""This 600-line file means 3 developers will have merge conflicts every sprint when touching unrelated features"
Security"Should validate input""Without schema validation, a malformed tenant ID could bypass authorization and leak data across accounts"

Verdict

After all findings are collected, compute the verdict:

======================================================
  REVIEW VERDICT: [APPROVED | CHANGES REQUESTED | NEEDS DISCUSSION]
======================================================
  Critical:  N findings (must fix)
  Important: N findings (should fix)
  Advisory:  N findings

  Breakdown:
    Observability   Pass | Fail
    Testing         Pass | Fail
    SOLID           Pass | Fail
    Type Safety     Pass | Fail
    Security & PII  Pass | Fail
    Business Logic  Pass | Fail
    Clean Code      Pass (always passes, advisory only)
======================================================

Rules:

  • APPROVED -- Zero critical findings
  • CHANGES REQUESTED -- 1+ critical findings
  • NEEDS DISCUSSION -- Zero critical but 5+ important findings

Workflow

Step 1: Get the Diff

# Branch mode
git diff main...HEAD --name-only   # List changed files
git diff main...HEAD               # Full diff

# PR mode
gh pr diff 423 --name-only
gh pr diff 423

# All PRs mode
gh pr list --state open --json number,title,author
# Then loop through each

Step 2: Classify Changed Files

For each changed file, determine which dimensions apply:

File PatternDimensions to Check
Actions, handlers, controllersAll 7 dimensions
Repository/service/data-access filesType Safety, Clean Code
Test files (*.test.*, *.spec.*)Clean Code only
Page/layout/route entry pointsSOLID, Type Safety, Clean Code
UI componentsSOLID, Type Safety, Clean Code
Config, docs, styles (*.md, *.json, *.css)Skip review
Generated files (migrations, types)Skip review

Step 3: Review Each File

For each non-skipped file:

  1. Read the FULL file (not just the diff -- you need context)
  2. Read the diff to identify what changed
  3. Run applicable dimension checks against the changed code
  4. Collect findings with exact file:line references

Step 4: Compute Verdict

Aggregate all findings across all files. Apply verdict rules.

Step 5: Output

Terminal (all modes): Print formatted report with findings grouped by dimension, then verdict.

GitHub (PR modes): Two-part output — a review body AND inline line comments.

5a. Post the review body

Post the verdict summary as the review body via gh api:

gh api repos/{owner}/{repo}/pulls/{pr}/reviews \
  --method POST \
  -f body="<verdict summary>" \
  -f event="REQUEST_CHANGES"

Use REQUEST_CHANGES when verdict is CHANGES REQUESTED, APPROVE when APPROVED, COMMENT when NEEDS DISCUSSION.

5b. Post inline line comments (REQUIRED for PR modes)

Always post inline comments on the specific lines that need attention. This is not optional — the review body alone is not actionable enough. Developers need to see findings pinned to the exact code they need to change.

For each Critical and Important finding, post a standalone line comment:

gh api repos/{owner}/{repo}/pulls/{pr}/comments \
  --method POST \
  -f body="<finding with severity, explanation, and fix>" \
  -f path="<file path relative to repo root>" \
  -F line=<line number in the new version of the file> \
  -f commit_id="<head commit SHA>" \
  -f side="RIGHT"

Get the head commit SHA: gh pr view {pr} --json headRefOid -q .headRefOid

Rules:

  • Critical + Important findings: Always post inline comments (these are actionable)
  • Advisory findings: Summarize in the review body only (don't clutter the diff with non-blocking items)
  • Max 15 inline comments per PR. Group related findings if there are more
  • Use the diff to find exact line numbers in the new version of each file

Anti-Patterns

Anti-PatternWhy It's Wrong
"This violates best practices"Always explain the REAL impact
Reviewing generated filesSkip migrations, type generation, lock files
Reviewing test files for business logicTests follow their own patterns
Posting 50+ comments on one PRGroup related findings, max 15 comments
Blocking on advisory findingsOnly critical findings produce CHANGES REQUESTED
Reviewing code you didn't read fullyAlways read the full file, not just the diff
Reviewing non-logic filesSkip .md, .json, .css, config files

Relationship to Other Skills

SkillHow It Relates
code-quality-auditDeep audit of a single module. Use /review for PR-scoped checks, code-quality-audit for full-module remediation
pull-requestCreates PRs. /review reviews them. Run /review before /pr to catch issues early
testingDefines test patterns. /review checks that those patterns are followed
security-and-complianceDefines security rules. /review enforces them at PR time
observabilityDefines logging/tracing patterns. /review checks compliance

Related Skills

shield-question

Prove Your Telemetry

Instrumentation fails silently, and its failure looks exactly like good news. An absent field reads as "nothing to report", a quiet dashboard reads as "nothing is wrong", a low issue count reads as "we fixed it". Before trusting any of those, read a real emitted event and confirm it carries what you think. Use when adding or changing logging/error capture, when an error report has no useful detail, when a metric or dashboard is suspiciously quiet, when an error "stopped happening" on its own, or when a shipped fix cannot be confirmed.

Universal
settings-2

Cross-Editor AI Setup

Ensure AI configuration works across Claude Code, Cursor, Copilot, Windsurf, and Codex. Use when creating AGENTS.md files, adding skills, setting up project rules, or discussing cross-editor compatibility. Enforces the @import convention and single-source-of-truth strategy.

Universal
palette

Premium UI Design Engineering

Premium UI/UX design engineering skill. Overrides default LLM design biases with tunable dials for variance, motion, and density. Enforces anti-AI-tell patterns, strict typography rules, color calibration, layout diversification, performance guardrails, and comprehensive design audit checklists. Framework-agnostic.

Universal

Related Playbook Chapters

  • →Code Quality Audit
  • →Testing Strategy
  • →Typescript Strict
←Back to Agent Skills