{"slug": "a-workflow-and-reusable-prompt-for-ai-code-reviews-that-check-correctness-and", "title": "A workflow and reusable prompt for AI code reviews that check correctness and impact, not style.", "summary": "A developer published a reusable prompt and workflow for running AI-assisted code reviews that focus on correctness and impact rather than style, aiming to complete reviews in seconds instead of minutes. The approach fetches PR metadata, discussion, and diffs in parallel via the GitHub CLI, uses a code graph built from the AST with Tree-sitter and exposed over MCP to trace callers and downstream impact, and checks changes against a checklist covering concurrency, memory and I/O, time and state, boundaries, and security.", "body_md": "A workflow and a reusable prompt for running code reviews with an AI coding agent. The goal is a review that checks correctness and impact, not style, and finishes in seconds instead of minutes.\n\nTwo things tend to make AI reviews slow and noisy:\n\n- Spending time on formatting and naming, which linters and CI already cover.\n- Exploring the repo one call at a time: checking out branches, reading file after file, grepping for usages.\n\nThe workflow below avoids both.\n\n- **Approve improvements.** If the PR moves the codebase forward, approve it. Don't block on personal preference.\n- **Read the discussion first.** Review only new code and unresolved threads. Don't re-raise resolved comments.\n- **Calibrate to size.** Aim for around 100 changed lines. Flag PRs over 300 lines; recommend splitting anything over 1,000.\n- **No formatting comments.** Leave formatting and linting to tooling. Review correctness, concurrency, resource handling, and impact.\n\n1. **Fetch everything in parallel.** PR metadata, discussion, and diff in the same turn.\n2. **Map the impact.** Use a call graph to find callers and affected code.\n3. **Check intent.** If a ticket is linked, compare the change to its acceptance criteria.\n4. **Analyze and report.** Review against the checklist below and output findings by severity.\n\nDon't check out the branch locally, run commands one after another, or write temp files. Pull what you need straight from the remote, in parallel, and keep it in context.\n\nThe example uses the GitHub CLI. Other Git hosts have equivalent APIs.\n\n```\n# PR metadata, commits, comments, and review threads (with resolved status) in one query\ngh api graphql -F owner=\"<OWNER>\" -F repo=\"<REPO>\" -F pr=<PR_NUMBER> -f query='\nquery($owner: String!, $repo: String!, $pr: Int!) {\n  repository(owner: $owner, name: $repo) {\n    pullRequest(number: $pr) {\n      title\n      body\n      author { login }\n      commits(last: 20) { nodes { commit { oid messageHeadline } } }\n      comments(last: 20) { nodes { author { login } body } }\n      reviewThreads(first: 50) {\n        nodes {\n          isResolved\n          path\n          line\n          comments(first: 10) { nodes { author { login } body } }\n        }\n      }\n    }\n  }\n}'\n\n# The diff, straight from the remote (no checkout)\ngh pr diff <PR_NUMBER> -R <OWNER>/<REPO>\n```\n\nDon't let the agent grep for usages or pull whole files into context to find where a function is called. Give it a code index it can query instead.\n\nI use [CodeGraph](https://colbymchenry.github.io/codegraph/), which builds a symbol graph from the AST (Tree-sitter, 20+ languages) and exposes it to agents over MCP. With it, the agent can:\n\n- Trace callers and callees of every changed symbol.\n- Follow interface-to-implementation and other dynamic-dispatch hops that grep can't follow.\n- Find downstream consumers and the full impact radius of the change.\n\nOne query replaces a chain of searches, and the result comes from the actual code structure rather than text matching.\n\nClean code can still miss the requirement.\n\n1. If the PR description links a ticket (Jira, Linear, GitHub Issues, etc.), fetch its description and acceptance criteria.\n2. Use a 5-second timeout (for example, `curl --max-time 5` ). If there's no linked ticket, or the tracker doesn't answer in time, skip this step and continue.\n\nReview the diff against these areas:\n\n| Area | What to look for | \n|---|---|\n| Concurrency and async | Fire-and-forget tasks nobody awaits or catches errors from, missing cancellation propagation, deadlocks, race conditions, worker/thread pool starvation | \n| Memory and I/O | Heavy allocations in hot paths or tight loops, unbuffered I/O, connections not returned to the pool, N+1 queries | \n| Time and state | Server-local time instead of UTC, nullable values used without a check, swallowed exceptions | \n| Boundaries | Business logic in the wrong layer, hardcoded config instead of injected config, over-engineering, dead code | \n| Security and contracts | Unsanitized input, exposed secrets, missing authorization checks, breaking changes to public APIs | \n\nEvery finding gets a severity:\n\n- **Blocking** : bugs, security issues, data corruption, resource leaks. Must be fixed before merge.\n- **Recommended** : performance, resilience, or design improvements. Worth doing, doesn't block.\n- **FYI** : context for later.\n\nEach finding follows this template:\n\n```\n### [Severity] Short title\n- Location: path/to/file.ext:line\n- Issue: what goes wrong and when\n- Reference: link to relevant docs (language docs, OWASP, etc.)\n- Fix: a code snippet that can be applied as-is\n```\n\nWorks with any coding agent that can run shell commands (Claude Code, Codex, Gemini CLI, Cursor, etc.).\n\n```\nYou are reviewing a pull request. Focus on correctness, impact, and risk. Do not comment on formatting or style.\n\n1. Fetch in parallel: in your first turn, fetch PR metadata and review threads in one query, and fetch the diff from the remote. Do not check out the branch or write files to disk.\n2. Read the discussion first. Skip any thread that is resolved.\n3. Use the code index (e.g. CodeGraph over MCP) to find callers, implementations, and affected code. Do not grep for usages.\n4. If the PR links a ticket, fetch its acceptance criteria with a 5-second timeout. If there is no ticket or it does not respond, continue without it.\n5. Check the diff for:\n   - Concurrency: unawaited background tasks, missing cancellation, deadlocks, race conditions\n   - Memory and I/O: allocations in hot paths, unbuffered I/O, leaked connections, N+1 queries\n   - Time and state: local time instead of UTC, unchecked nulls, swallowed exceptions\n   - Boundaries: logic in the wrong layer, hardcoded config, dead code\n   - Security: unsanitized input, exposed secrets, missing authorization, breaking API changes\n6. Output findings grouped by severity: Blocking, Recommended, FYI. For each, give file and line, the issue, a documentation link, and a concrete fix.\n7. Size check: flag PRs over 300 changed lines, recommend splitting over 1,000.\n```\n\n", "url": "https://wpnews.pro/news/a-workflow-and-reusable-prompt-for-ai-code-reviews-that-check-correctness-and", "canonical_source": "https://gist.github.com/dvirsegal/987e1d5dbd423640e86d9102e80edf1c", "published_at": "2026-09-26 18:52:06+00:00", "updated_at": "2026-09-26 21:30:27.002989+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "agent-protocols", "mlops"], "entities": ["GitHub", "CodeGraph", "Tree-sitter", "MCP", "Jira", "Linear"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/a-workflow-and-reusable-prompt-for-ai-code-reviews-that-check-correctness-and", "markdown": "https://wpnews.pro/news/a-workflow-and-reusable-prompt-for-ai-code-reviews-that-check-correctness-and.md", "text": "https://wpnews.pro/news/a-workflow-and-reusable-prompt-for-ai-code-reviews-that-check-correctness-and.txt", "jsonld": "https://wpnews.pro/news/a-workflow-and-reusable-prompt-for-ai-code-reviews-that-check-correctness-and.jsonld"}}