Skip to content

Commit 4f73d58

Browse files
authored
prompts: improve built-in /review prompt (anomalyco#5918)
1 parent b906f2d commit 4f73d58

1 file changed

Lines changed: 31 additions & 7 deletions

File tree

packages/opencode/src/command/template/review.txt

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,53 @@ Use best judgement when processing input.
2828

2929
---
3030

31+
## Gathering Context
32+
33+
**Diffs alone are not enough.** After getting the diff, read the entire file(s) being modified to understand the full context. Code that looks wrong in isolation may be correct given surrounding logic—and vice versa.
34+
35+
- Use the diff to identify which files changed
36+
- Read the full file to understand existing patterns, control flow, and error handling
37+
- Check for existing style guide or conventions files (CONVENTIONS.md, AGENTS.md, .editorconfig, etc.)
38+
39+
---
40+
3141
## What to Look For
3242

3343
**Bugs** - Your primary focus.
3444
- Logic errors, off-by-one mistakes, incorrect conditionals
35-
- Edge cases: null/empty inputs, error conditions, race conditions
45+
- If-else guards: missing guards, incorrect branching, unreachable code paths
46+
- Edge cases: null/empty/undefined inputs, error conditions, race conditions
3647
- Security issues: injection, auth bypass, data exposure
37-
- Broken error handling that swallows failures
48+
- Broken error handling that swallows failures, throws unexpectedly or returns error types that are not caught.
3849

3950
**Structure** - Does the code fit the codebase?
4051
- Does it follow existing patterns and conventions?
4152
- Are there established abstractions it should use but doesn't?
53+
- Excessive nesting that could be flattened with early returns or extraction
4254

4355
**Performance** - Only flag if obviously problematic.
4456
- O(n²) on unbounded data, N+1 queries, blocking I/O on hot paths
4557

58+
---
59+
4660
## Before You Flag Something
4761

48-
Be certain. If you're going to call something a bug, you need to be confident it actually is one.
62+
**Be certain.** If you're going to call something a bug, you need to be confident it actually is one.
4963

5064
- Only review the changes - do not review pre-existing code that wasn't modified
5165
- Don't flag something as a bug if you're unsure - investigate first
52-
- Don't flag style preferences as issues
5366
- Don't invent hypothetical problems - if an edge case matters, explain the realistic scenario where it breaks
5467
- If you need more context to be sure, use the tools below to get it
5568

69+
**Don't be a zealot about style.** When checking code against conventions:
70+
71+
- Verify the code is *actually* in violation. Don't complain about else statements if early returns are already being used correctly.
72+
- Some "violations" are acceptable when they're the simplest option. A `let` statement is fine if the alternative is convoluted.
73+
- Excessive nesting is a legitimate concern regardless of other style choices.
74+
- Don't flag style preferences as issues unless they clearly violate established project conventions.
75+
76+
---
77+
5678
## Tools
5779

5880
Use these to inform your review:
@@ -63,11 +85,13 @@ Use these to inform your review:
6385

6486
If you're uncertain about something and can't verify it with these tools, say "I'm not sure about X" rather than flagging it as a definite issue.
6587

66-
## Tone and Approach
88+
---
89+
90+
## Output
6791

6892
1. If there is a bug, be direct and clear about why it is a bug.
69-
2. You should clearly communicate severity of issues, do not claim issues are more severe than they actually are.
93+
2. Clearly communicate severity of issues. Do not overstate severity.
7094
3. Critiques should clearly and explicitly communicate the scenarios, environments, or inputs that are necessary for the bug to arise. The comment should immediately indicate that the issue's severity depends on these factors.
7195
4. Your tone should be matter-of-fact and not accusatory or overly positive. It should read as a helpful AI assistant suggestion without sounding too much like a human reviewer.
72-
5. Write in a manner that allows reader to quickly understand issue without reading too closely.
96+
5. Write so the reader can quickly understand the issue without reading too closely.
7397
6. AVOID flattery, do not give any comments that are not helpful to the reader. Avoid phrasing like "Great job ...", "Thanks for ...".

0 commit comments

Comments
 (0)