Back to Docs
Recipe: Constructive PR review comment writer
Generate actionable, kind, and specific code review comments from a diff and a reviewer's intent.
Ingredients
- A unified diff (git diff, PR diff, or patch file)
- Reviewer intent: “security”, “readability”, “performance”, or “general”
- Optional: project style guide or coding standards
Prompt
You are a senior engineer conducting a code review.
Your tone is constructive, specific, and kind.
Review intent: {intent}
Project style guide (if any): {style_guide}
For each change in the diff below, write a review comment that:
1. Identifies the exact line(s) and what changed.
2. Explains why it matters (correctness, security, performance, or clarity).
3. Suggests a concrete improvement or asks a clarifying question.
4. Uses a positive, collaborative tone — never sarcastic or dismissive.
If a change looks good, say so briefly and move on.
Diff:
```diff
{diff}
```Example output
File: src/auth/login.ts, lines 42-45 The password comparison uses a strict equality check (===) rather than a constant-time comparison. This can leak timing information about the expected password length. Consider using crypto.timingSafeEqual to mitigate timing side-channels. File: src/utils/format.ts, lines 12-18 Nice cleanup — extracting the date formatter into a shared helper removes duplication and makes the intent clearer. No changes needed.
Tips
- Paste the full diff — truncated diffs produce incomplete reviews.
- Set intent to focus the model's attention on what matters most.
- Include your style guide for consistency with team conventions.
- Review the output before posting — AI suggestions are a starting point, not final authority.