<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: chatterjay411</title>
    <description>The latest articles on DEV Community by chatterjay411 (@chatterjay411).</description>
    <link>https://dev.to/chatterjay411</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3999380%2F17f5a10d-7509-4c2d-b411-3b56ca284088.png</url>
      <title>DEV Community: chatterjay411</title>
      <link>https://dev.to/chatterjay411</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chatterjay411"/>
    <language>en</language>
    <item>
      <title>AI Prompting for Code Review</title>
      <dc:creator>chatterjay411</dc:creator>
      <pubDate>Tue, 23 Jun 2026 20:20:17 +0000</pubDate>
      <link>https://dev.to/chatterjay411/ai-prompting-for-code-review-jpl</link>
      <guid>https://dev.to/chatterjay411/ai-prompting-for-code-review-jpl</guid>
      <description>&lt;h1&gt;
  
  
  Stop telling AI to "review this code." Do this instead.
&lt;/h1&gt;

&lt;p&gt;You already use Claude or ChatGPT for code review, debugging, and tests. And if you are honest, the output is usually mediocre: an unranked wall of style nits mixed with real bugs, a confident fix for the line that threw while the actual bug sits upstream, or three happy-path tests that prove nothing.&lt;/p&gt;

&lt;p&gt;It is tempting to blame the model. The real problem is the prompt. "Review this code" is a vague instruction, and vague instructions get vague answers. Here is a concrete example and the one change that fixes it.&lt;/p&gt;

&lt;h2&gt;
  
  
  A real bug
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_order_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;price&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;quantity&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;   &lt;span class="c1"&gt;# TypeError fires here
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;build_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cart_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;cart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;catalog_client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_cart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cart_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;          &lt;span class="c1"&gt;# migrated to Catalog API v2
&lt;/span&gt;    &lt;span class="n"&gt;items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sku&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sku&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;price&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;unit_price&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;quantity&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;qty&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;lines&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cart_id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cart_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;total&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;calculate_order_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;items&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It throws &lt;code&gt;TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'&lt;/code&gt;, but only on about 2% of checkouts, and it started right after an API migration.&lt;/p&gt;

&lt;p&gt;A naive prompt, "Why is this throwing a TypeError? Fix it.", gets you this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;item["price"]&lt;/code&gt; is &lt;code&gt;None&lt;/code&gt;, so add a guard:&lt;br&gt;
&lt;code&gt;price = item["price"] or 0&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It "works." The crash stops. And you have just shipped a worse bug: every unsellable item is now silently priced at $0. The error moved. It was never understood.&lt;/p&gt;

&lt;h2&gt;
  
  
  The prompt that finds the actual cause
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You are a debugging specialist. Your job is to find the ROOT CAUSE of a bug,
not to apply a random fix and hope. You reason from evidence and you are honest
about uncertainty.

SYMPTOM
{{ERROR_MESSAGE_STACK_TRACE_OR_DESCRIPTION}}

RELEVANT CODE
{{PASTE_CODE_HERE}}

WHAT CHANGED RECENTLY (if known)
{{RECENT_DEPLOY_DEP_BUMP_CONFIG_OR_"unknown"}}

ENVIRONMENT
{{LANGUAGE_VERSION_AND_WHERE_IT_HAPPENS}}

Work the problem in this order and output exactly these sections:

## What the symptom tells us
Read the trace/symptom literally. State what is definitely true before theorizing.

## Ranked hypotheses
A numbered list, MOST LIKELY FIRST. For each: the hypothesis, a confidence
(HIGH/MEDIUM/LOW), the evidence for it, and the evidence against it.

## Most likely root cause
Commit to the top hypothesis. Name the exact line(s) where the bug ORIGINATES
(not just where it throws) and explain the chain of events.

## The fix
The concrete change, with corrected code. State any assumption it depends on.

## How to verify
A specific way to confirm the fix works AND that you found the real cause.

## How to prevent recurrence
One or two concrete guards: a test, a type, an assertion, input validation.

RULES
- Do NOT propose a fix before identifying a cause. Cause first, then fix.
- Rank hypotheses by likelihood; don't list everything equally.
- Distinguish where the error SURFACES from where it ORIGINATES.
- If you need information you don't have, say what you'd check and why.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run that on the same bug and the output is different in kind, not degree:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The bug originates in &lt;code&gt;build_order&lt;/code&gt;, which copies the price from the API response with no validation. It only surfaces later in the pricing math, where the &lt;code&gt;None&lt;/code&gt; is first used. The crash site is an innocent victim of unvalidated data admitted upstream. This explains every clue: only ~2% of carts (those with an unpriced item), started at the migration cutover, and not reproducible locally. Reproduce it by pulling a failing cart's raw response and confirming a null price, then add the regression test before trusting the fix.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It found the upstream cause, refused to guess, and told you how to confirm you actually fixed it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it works
&lt;/h2&gt;

&lt;p&gt;Three rules do the heavy lifting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cause before fix.&lt;/strong&gt; The model is forbidden from proposing a fix until it has named a cause. Stack traces point at the crash site, which is usually downstream of the real bug.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ranked hypotheses with confidence and counter-evidence.&lt;/strong&gt; "Here are six things it could be" becomes a prioritized investigation, and the counter-evidence keeps it honest about what it is guessing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verify the cause, not just the symptom.&lt;/strong&gt; "The error went away" is not the same as "I understood it."&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The same idea, everywhere
&lt;/h2&gt;

&lt;p&gt;This is not specific to debugging. Every weak AI coding prompt has the same fix: tell the model what a good answer looks like, and constrain it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Code review:&lt;/strong&gt; demand a severity label on every finding and a ship / don't-ship verdict, so you can triage in seconds instead of reading prose.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test generation:&lt;/strong&gt; ask for edge and error cases first, plus invariants that hold for all inputs, instead of three happy-path asserts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PR descriptions:&lt;/strong&gt; derive everything from the diff, refuse to fabricate testing, and flag leftover debug code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The model was always capable of the good answer. The structure is what pulls it out.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you want the rest
&lt;/h2&gt;

&lt;p&gt;I packaged six of these prompts, code review, debugging, refactor planning, test generation, PR descriptions, and blameless postmortems, each with a real, tested worked example: &lt;a href="https://chatterjay.gumroad.com/l/wlnum" rel="noopener noreferrer"&gt;Code Review Copilot Prompts&lt;/a&gt;. The bug-triage prompt above is yours regardless. Copy it and use it on your next bug.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3fxk6k98b24xwkohvz81.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3fxk6k98b24xwkohvz81.png" alt=" " width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>chatgpt</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
