skills/pr-code-reviewer/SKILL.md
Review pull requests and staged changes for bugs, security issues, and code quality. Use this skill whenever the user mentions: review PR, code review, check this PR, review my changes, /review, PR #123, look at this diff, is this safe to merge, or provides a GitHub PR URL. Also triggers on: 'what do you think of these changes', 'review --staged', 'check my code before merge'.
npx skillsauth add nano-step/skill-manager pr-code-reviewerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Version: 3.4.0 | Architecture: 4 Parallel Subagents + Verification Pipeline + Confidence Scoring | Memory: nano-brain CLI
Comprehensive PR reviewer: gathers full context, applies smart tracing by change type, runs four specialized subagents in parallel, iteratively refines findings, and produces a short, actionable report — only what matters. Also suggests code improvements when opportunities exist.
Each phase catches a different class of issue. A 1-line deletion can hide a critical logic bug that only cross-repo tracing (Phase 2) would reveal. A "trivial" style change can mask a hidden logic change that only subagent consensus (Phase 3-4) would catch. The only exception: Phase 0 (worktree checkout) is skipped for --staged local reviews.
People don't read long reports. Every section must earn its place.
Filtering rule: If a finding wouldn't make a senior engineer stop and think, drop it.
Do NOT load all reference files upfront. Read each file only when the relevant phase runs:
| Phase | Read at start of phase |
|-------|------------------------|
| Phase -2 | references/setup-wizard.md (only if no config) |
| Phase 1 | {workspace_root}/AGENTS.md + .agents/_repos/{repo}.md + .agents/_domains/{domain}.md |
| Phase 1 | references/nano-brain-integration.md |
| Phase 2 | Domain checklist for changed file types (one file only) |
| Phase 3 | references/subagent-prompts.md + stack framework rules (from config) |
| Phase 4 | references/confidence-scoring.md |
| Phase 4.5 | references/verification-protocol.md |
| Phase 5 | references/report-template.md |
| Phase 5.5 | references/nano-brain-integration.md (save section only) |
Framework rules: load ONLY the files matching stack in .opencode/code-reviewer.json. Never load all framework rules.
Requires gh CLI authenticated as nus-rick.
gh auth status # Verify: must show nus-rick as active account
Needs repo scope. If not authenticated: gh auth login and select the nus-rick account.
Verify with: /review PR#1
| Command | Purpose |
|---------|---------|
| gh pr view <N> --json title,body,author,baseRefName,headRefName,files,reviews,statusCheckRollup,additions,deletions,changedFiles | PR metadata, files, reviews, CI status |
| gh pr diff <N> | Full diff of changed files |
| gh pr checks <N> | CI/check status |
| gh pr view <N> --json comments --jq '.comments' | PR comments |
| gh api repos/{owner}/{repo}/contents/{path}?ref={branch} | File content at specific ref |
Author enforcement: All gh commands default to the nus-rick account (active in ~/.config/gh/hosts.yml). If multiple accounts exist, verify with gh auth status before review.
For --staged or local reviews, uses git commands directly (git diff --staged, git diff, git log).
Persistent memory for historical context — past reviews, architectural decisions, known issues.
Full tool reference + query patterns: nano-brain-integration.md
When a Linear ticket is linked to the PR (via branch name or PR description), the reviewer fetches ticket context automatically.
Available Linear MCP Tools:
| Tool | Purpose |
|------|---------|
| linear_get_issue | Ticket title, description, acceptance criteria, status, priority, labels |
| linear_list_comments | Discussion thread on the ticket |
| linear_get_attachment | Attached specs, screenshots, designs |
| linear_extract_images | Extract images embedded in ticket description/comments |
Ticket ID extraction (checked in order):
feature/DEV-1234-... or fix/DEV-1234-... → extracts DEV-1234Linear: DEV-1234, Ticket: DEV-1234, or Linear URL linear.app/.../DEV-1234[DEV-1234] or DEV-1234: prefixIf no ticket ID found → skip Linear context silently (no error, no warning).
Check for config at .opencode/code-reviewer.json. Full example: config.json
Reviews are resumable via checkpoints saved at each phase. If the agent crashes mid-review, resume from the last completed phase.
Full details: checkpoint-system.md — manifest schema, checkpoint files, Phase 3 special handling.
Full checklist: review-checklist.md — use this to track every step.
Before anything else, check if .opencode/code-reviewer.json exists.
If it exists: read stack field → load only the matching framework rule files (listed in setup-wizard.md mapping table). Continue to Phase -1.
If it doesn't exist (or user ran /review --setup):
references/setup-wizard.md for the full wizard flow.opencode/code-reviewer.json with stack field filled in/review --setup (not a real review), stop here. Otherwise continue.Stack → framework rules mapping (also in setup-wizard.md):
frontend: nuxt/vue → framework-rules/vue-nuxt.mdfrontend: nextjs → framework-rules/nextjs.mdfrontend: react → framework-rules/react.mdbackend: express → framework-rules/express.mdbackend: nestjs → framework-rules/nestjs.mdorm: typeorm → framework-rules/typeorm.mdorm: prisma → framework-rules/prisma.mdlanguage: typescript* → framework-rules/typescript.mdStore the resolved $FRAMEWORK_RULES content (concatenated) for Phase 3. If multiple match, concatenate them.
Before starting a new review, check for existing checkpoints to resume interrupted reviews.
Steps:
Look for existing worktree:
Call listworktrees — look for a worktree whose branch matches the PR's head_branch.
For local reviews: check for .checkpoints/manifest.json in current directory.
If worktree found, read its checkpoint manifest:
cat "${WORKTREE_PATH}/.checkpoints/manifest.json"
Validate checkpoint is still valid:
pr.number matches current PRhead_sha in manifest matches current PR head SHA (PR not updated since checkpoint)deleteworktree(branch="${head_branch}") and start freshAsk user to resume:
📂 Found checkpoint from previous review:
Phase: {completed_phase} → {next_phase}
Started: {started_at}
Last updated: {last_updated}
Resume from phase {next_phase}? (y/n)
If user says yes:
manifest.jsonnext_phase in the workflowsubagent_status and only run incomplete subagentsIf user says no or checkpoint invalid:
deleteworktree(branch="${head_branch}") to remove existing worktreeFor Local Reviews: Checkpoint directory is .checkpoints/ in current working directory. No SHA validation needed (working directory changes are expected).
Why: Your local repo may be on any branch or have uncommitted changes. Creating a git worktree ensures:
/tmp directories)Steps:
Extract repo info from PR URL or gh pr view:
repo — repository name only (e.g., tradeit-backend)pr_number (e.g., 1159)head_branch (e.g., feature/dev-4650-callback-url-for-payment-method)Create a worktree using the createworktree tool:
createworktree(
branch: "${head_branch}",
name: "PR #${pr_number} review",
repo: "${repo}" ← repo name (required in workspace mode, ignored in single-repo)
)
createworktree returns { ok: false } → STOP review, report error to user.worktreePath as $WORKTREE_PATH.Verify worktree succeeded:
git -C "$WORKTREE_PATH" log --oneline -1
If this fails → call deleteworktree(branch="${head_branch}") then STOP, report error.
Record the worktree path — ALL subsequent phases use $WORKTREE_PATH for file reads, grep, LSP, etc.
Print confirmation:
📂 Worktree ready: ${WORKTREE_PATH}
🌿 Branch: feature/dev-4650-callback-url-for-payment-method
📝 Ready for review
For Local Reviews (--staged): Skip Phase 0 — use current working directory as $WORKTREE_PATH.
Store $WORKTREE_PATH — every file read, grep, and subagent prompt references this path, not the original workspace repo.
Checkpoint: Save worktree metadata to .checkpoints/phase-0-clone.json (worktree_path, branch, head_sha, files_changed) and create manifest.json with completed_phase: 0, next_phase: 1, phase_status: {"0": "complete", ...}.
Step 0 — Load agent knowledge base (MANDATORY if configured):
Read agents config from .opencode/code-reviewer.json. If has_agents_md: true:
Read {workspace_root}/AGENTS.md — keyword→domain→repo mapping table. Use this to identify which domain the PR's repo belongs to.
Read {workspace_root}/.agents/_repos/{repo-name}.md (if has_repos_dir: true) — repo-specific context: framework, port, key files, known issues, cross-repo relationships. repo-name comes from the PR's owner/repo (e.g., PR from tradeit-backend → read .agents/_repos/tradeit-backend.md).
Read {workspace_root}/.agents/_domains/{domain}.md (if has_domains_dir: true) — domain context for the repo's domain. Domain identified from AGENTS.md mapping (e.g., tradeit-backend → trading-core domain → read .agents/_domains/trading-core.md).
For cross-repo tracing (Phase 2): if the PR touches API contracts or shared data, also read:
.agents/_indexes/by-database.md — which repo owns which DB table.agents/_indexes/by-data-source.md — which repo consumes which external APIDo NOT read all repo/domain files — only the ones relevant to the PR being reviewed. Store combined result as $AGENTS_CONTEXT.
If agents config is missing or files not found: continue without it, no error.
For PR Reviews (gh CLI):
gh pr view <N> -R {owner}/{repo} --json title,body,author,baseRefName,headRefName,additions,deletions,changedFiles → title, description, author, base branchgh pr diff <N> -R {owner}/{repo} --name-only → changed file list; gh pr diff <N> -R {owner}/{repo} → full diff$WORKTREE_PATH (NOT from GitHub API — local reads are faster and give full file)For Local Reviews (git):
git diff --staged or git diff → changed filesgit log --oneline -5 → recent commit contextThen for all reviews: 3. Classify each file's change type:
DELETION classification: Any PR that removes user-facing behavior, error messages, validation logic, UI elements, or API responses is classified as DELETION, not STYLE or REFACTOR. Deletions feel safe but can hide regressions — they require the same depth as LOGIC changes plus a Premise Check.
4. Gather full context per changed file from $WORKTREE_PATH: callers/callees, tests, types, usage sites
5. Query nano-brain for project memory on each changed module — query patterns
6. Fetch Linear ticket context (if ticket ID found) — see Phase 1.5
Checkpoint: Save results to .checkpoints/phase-1-context.json (PR metadata, file classifications, nano-brain context) and update manifest.json (completed_phase: 1, next_phase: 1.5).
If a Linear ticket ID was extracted from the branch name, PR description, or PR title:
linear_get_issue(id) → title, description (contains acceptance criteria), status, priority, labels, assigneelinear_list_comments(issueId) → discussion thread, clarifications, edge cases mentioned- [ ] items)linear_extract_images(description)What to do with ticket context:
## LINEAR TICKET CONTEXT sectionAmbiguity Detection: If acceptance criteria are vague or open to multiple interpretations (e.g., "fix it", "make it correct", "improve this", "need to fix to make it correct"):
If Linear is unavailable or ticket not found: Continue review without ticket context. Do NOT fail the review.
Checkpoint: Save results to .checkpoints/phase-1.5-linear.json (ticket details, acceptance criteria, comments, images) and update manifest.json (completed_phase: 1.5, next_phase: 2).
LOGIC changes:
DELETION changes (all LOGIC steps above, PLUS): 6. Premise Check — answer these questions before proceeding:
Cross-Repo API Tracing (for multi-repo workspaces): For any changed code that consumes data from an API (fetches, reads responses, uses values from backend):
/api/v2/inventory/my/data)6 * 60 * 1000 vs backend's steamCInvCacheTTLMinutes), flag as a warning: values are out of sync.This applies even for deletions. If the deleted code consumed API data, trace into the backend to understand whether the deletion is correct or whether the code should be fixed instead.
STYLE changes: Check convention consistency, verify no hidden logic changes.
REFACTOR changes: Verify behavior preservation, check all usages still work.
Domain-Specific Checklists: Based on the file types in the PR, read the relevant checklist for domain-specific review criteria:
Checkpoint: Save results to .checkpoints/phase-2-tracing.json (tracing results per file, callers/callees, test coverage, data flow, premise check answers, cross-repo tracing) and update manifest.json (completed_phase: 2, next_phase: 2.5).
Before launching subagents, generate a GitHub Copilot-style PR summary. Reviewers need this context.
Full guidelines + pseudocode: report-template.md
Checkpoint: Save results to .checkpoints/phase-2.5-summary.json (PR summary text, key changes, file summaries) and update manifest.json (completed_phase: 2.5, next_phase: 3).
Launch all 4 subagents simultaneously with run_in_background: true. Each agent catches issues the others miss — the quality agent finds duplication the security agent ignores, the librarian catches framework anti-patterns the integration agent overlooks. Include PR Summary, nano-brain memory, Premise Check results (if DELETION), cross-repo tracing results, $WORKTREE_PATH, and $FRAMEWORK_RULES (from Phase -2) in each prompt.
Read references/subagent-prompts.md now for the full prompt templates.
| # | Agent | Type | Focus |
|---|-------|------|-------|
| 1 | Code Quality | explore | Style, naming, error handling, type safety, duplication, complexity, code improvements |
| 2 | Security & Logic | oracle | OWASP Top 10, logic correctness, edge cases, race conditions, auth, logic improvements, cross-repo data flow, deletion premise validation |
| 3 | Docs & Best Practices | librarian | API docs, framework best practices, anti-patterns, idiomatic improvements |
| 4 | Tests & Integration | general | Test coverage, edge cases, contract integrity, performance, perf improvements |
Full prompt templates: subagent-prompts.md
Each subagent returns JSON: {findings: [{file, line, severity, category, message, suggestion, code_suggestion?, evidence, confidence, trace_path?}]}
Severity values: critical (blocks merge), warning (should fix), improvement (code can be better), suggestion (nice-to-have)
New fields (v3.1): evidence (REQUIRED for critical/warning — concrete proof with file:line references), confidence (high/medium/low), trace_path (optional array of file:line strings showing verification trace)
Checkpoint: After EACH subagent completes, update .checkpoints/phase-3-subagents.json with that subagent's findings and update manifest.json subagent_status to "complete" for that subagent. After ALL subagents complete, update manifest.json (completed_phase: 3, next_phase: 4). On resume, only run subagents with status != "complete".
consensus_count >= 2 → boost confidence to high (multiple agents agree)consensus_count == 1 + non-empty evidence with file:line references → keep original severity and confidenceconsensus_count == 1 + empty/missing evidence + severity critical or warning → AUTO-DOWNGRADE to suggestioncritical + warning → KEEP with full detailimprovement → KEEP as one-liner with optional code suggestionsuggestion → COUNT only — report total number, omit individual details unless < 3 totalCheckpoint: Save results to .checkpoints/phase-4-refined.json (deduplicated findings with consensus scores, filtered by severity, gap analysis results) and update manifest.json (completed_phase: 4, next_phase: 4.5).
Verify each critical/warning finding by reading the actual code at cited evidence locations. This catches false positives that survived subagent self-verification.
If no critical/warning findings exist after Phase 4, skip to Phase 4.6.
Full protocol: verification-protocol.md — category-specific verification rules, timeout policy, checkpoint schema.
Checkpoint: Save to .checkpoints/phase-4.5-verification.json. Update manifest (completed_phase: 4.5, next_phase: 4.6).
Score how confident we are in the review's findings — are they correct and complete? Computed from accuracy rate (40%), consensus rate (30%), and evidence rate (30%).
| Score | Label | Gate Action | |-------|-------|-------------| | 80–100 | 🟢 High | Proceed normally | | 60–79 | 🟡 Medium | Add warning: "Some findings may be inaccurate" | | < 60 | 🔴 Low | Add warning: "Low confidence — manual review recommended" |
Full scoring details: confidence-scoring.md — formula, per-finding confidence levels, special cases, checkpoint schema.
Checkpoint: Save to .checkpoints/phase-4.6-confidence.json. Update manifest (completed_phase: 4.6, next_phase: 5).
Save to .opencode/reviews/{type}_{identifier}_{date}.md. Create directory if needed.
Report structure (compact — omit empty sections):
Omit unless actionable: Traced Dependencies, Memory Context, Test Coverage, Praise, Change Classification. Include only if they contain findings the developer must act on.
Full template: report-template.md
Checkpoint: Save final report to .checkpoints/phase-5-report.md (copy of the report saved to .opencode/reviews/) and update manifest.json (completed_phase: 5, next_phase: 5.5).
Save key findings for future sessions. Includes PR number, title, date, files, critical issues, warnings, decisions, recommendation.
Full save patterns: nano-brain-integration.md
Checkpoint: Update manifest.json (completed_phase: 5.5, next_phase: 6).
Always ask before removing the worktree — the user may want to inspect files, run tests, or review multiple PRs.
Show the worktree path:
listworktrees() ← verify the PR worktree is still listed
Ask the user:
🧹 Cleanup: PR review worktree exists at:
📂 ${WORKTREE_PATH} (branch: ${head_branch})
Want me to remove it? (yes/no)
Only if user confirms:
deleteworktree(branch: "${head_branch}", repo: "${repo}")
Note: deleteworktree will refuse if the worktree has uncommitted changes — safe by default.
After deletion, remove checkpoints manually:
rm -rf "${WORKTREE_PATH}/.checkpoints"
(Only needed if checkpoints were stored inside the worktree path.)
If user declines: Remind them to clean up later:
ℹ️ Worktree kept. Remove when done:
deleteworktree(branch: "${head_branch}")
Or: listworktrees() to see all active worktrees
If reviewing multiple PRs: Each PR has its own worktree. Ask about each one individually at the end.
Note: For local reviews (--staged), there is no worktree — skip Phase 6 entirely. Checkpoints remain in .checkpoints/ until manually deleted.
After review completes, ALWAYS inform the user:
✅ Review complete!
📄 Report saved to: .opencode/reviews/PR_123_2026-02-04.md
Summary:
• Critical: {count}
• Warnings: {count}
• Suggestions: {count}
🧹 Worktree: ${WORKTREE_PATH} — want me to remove it? (deleteworktree)
/review PR#123
/review https://github.com/owner/repo/pull/123
/review --staged
| Document | Content | When to Read | |----------|---------|--------------| | setup-wizard.md | Stack setup wizard — questions, mapping, config schema | Phase -2 (first run) | | subagent-prompts.md | Full prompt templates for all 4 subagents | Phase 3 execution | | report-template.md | Report format, PR summary guidelines, pseudocode | Phase 2.5 + Phase 5 | | nano-brain-integration.md | Tool reference, query patterns, save patterns | Phase 1, 2, 5.5 | | config.json | Full workspace + output + trace + stack config | Setup | | security-patterns.md | OWASP patterns, auth checks | Phase 3 (Security agent) | | quality-patterns.md | Code quality anti-patterns | Phase 3 (Quality agent) | | performance-patterns.md | N+1, caching, allocation patterns | Phase 3 (Integration agent) | | framework-rules/ | vue-nuxt, express, nestjs, typeorm, typescript, nextjs, react, prisma | Phase -2 (load only stack-matching files) | | checkpoint-system.md | Manifest schema, checkpoint files, resume logic | Phase -1 (resume detection) | | verification-protocol.md | Category-specific verification rules | Phase 4.5 | | confidence-scoring.md | Confidence formula, thresholds, display format | Phase 4.6 | | checklists/database.md | MySQL/Redis patterns, transactions, migrations | Phase 2 (DB file changes) |
tools
Humanization layer for LLM conversation — makes the model sound and respond like a real, thoughtful, embodied human rather than an assistant or chatbot. Use whenever the reply will be read by a human and warmth, presence, or texture matter more than machine-readability. Triggers on any of: "human", "humans", "humanize", "humanization", "be human", "more human", "feel human", "people", "person", "real person", "real human", "friend", "friendly", "like a friend", "respond like a friend", "buddy", "talk", "talking", "talk to me", "talk like a person", "chat", "chatting", "conversation", "converse", "discuss", "discussion", "communication", "communicate", "listen", "just listen", "sit with me", "vent", "venting", "I just want to vent", "company", "presence", "stop being an AI", "stop sounding like a bot", "less corporate", "less robotic", "less formal", "warmer", "warm tone", "empathy", "empathetic", "comfort", "support me", "emotional support", "be honest with me", "be real with me", "real talk", "heart-to-heart", "deep conversation", "casual", "casual chat", "small talk", "chitchat", "say something", "tell me something", and on any emotional / relational / personal-decision / interpersonal context — grief, joy, anger, fear, shame, doubt, loneliness, dating, breakup, conflict, family, parents, sibling, friendship, marriage, divorce, in-laws, kids, parenting, work stress, burnout, career decision, quitting, firing, layoff, anxiety, depression, panic, sleep, dreams, identity, faith, doubt, meaning, mortality, celebration, milestone, achievement, gratitude, apology, forgiveness. Also loads when the user writes in non-English (any language) with emotional weight, when the user's message is shorter than 8 words and affect-laden, when the user types in lowercase fragments, when the user types in ALL CAPS with excitement, or when the user explicitly asks for a friend / mentor / older-sibling / wise-listener voice. Do NOT use for code generation, tool calls, structured data output, SQL, API contracts, or any task where machine-readability matters more than human warmth.
tools
Use this skill whenever the user mentions open-design, od_generate_design, OD daemon, BYOK design generation, generating HTML mockups from a PRD, creating or managing Open Design projects, saving design artifacts, linting generated HTML, or any of the 10 `od_*` MCP tools (od_list_projects, od_get_project, od_create_project, od_update_project, od_delete_project, od_save_artifact, od_save_project_file, od_lint_artifact, od_compose_brief, od_generate_design). Also trigger on phrases like "generate a design", "create a mockup", "make a landing page", "list my OD projects", "the design daemon", "the streaming design tool", and on any 401/404/422 error coming from an `od_*` tool call. Covers env-var setup (`OD_DAEMON_URL`, auth modes, BYOK), the full PRD → generate → save → lint workflow, error diagnosis, and the safety rails (lint before save, never commit BYOK keys). Triggers even if the user doesn't explicitly say "open-design-mcp" — keyword matches on `od_*` tool names or "design generation" workflows are enough.
tools
Use this skill whenever a user wants the **full Open Design experience** — discovery questions asked first, brand-spec extraction from URLs/files, TodoWrite planning with live updates, 5-dimensional self-critique, polished artifact at the end. Trigger phrases include "design with questions first", "OD-style workflow", "full interactive design brief", "make me a complete landing page" (when the user wants quality over speed), "design my pitch deck", "brand-aware multi-page site", "follow the Open Design playbook", or any request where the user is starting a new design project rather than tweaking an existing artifact. Also trigger on any request that mentions wanting brand consistency across multiple pages or that provides a brand URL/spec. Pair with the `open-design-mcp` tool-reference skill — both loaded together give an LLM the full picture (this skill = workflow choreography; that skill = tool catalog + errors). This skill explicitly does NOT trigger for one-off tweaks ("make the nav stickier", "swap slide 3 image") — use od_generate_design directly for those.
development
Sync a locally-developed OpenCode skill to the skill-manager npm package and (if private) the private-skills GitHub repo. Handles per-skill version bumps, public/private classification, build verification, and conventional-commit-style git push. Auto-publish to npm is handled downstream by nano-step/shared-workflows@v1 when the push to master lands. Use this skill whenever the user says 'sync skill', 'publish skill', 'push skill to manager', '/sync-skill-to-manager <name>', or asks to release/distribute a skill they just edited.