Field SOP
Field SOP

Code Review & Debug Prompt Pack: Three-level Prompts from Bug Localization to Refactor

Stop saying "check for bugs." Beginner quick bug localization (cite lines + minimal fix), intermediate full code review (red/yellow/green priorities), expert refactor advice (coupling/duplication/long functions)-key constraints pull AI from vague to concrete.

Published July 26, 20263 min read
<!-- prompt-code-review-debug-pack | resource | Code Review & Debug Prompt Pack -->

AI writes code fast, but bugs come fast too. Most people just say "check for bugs" and get either a pile of irrelevant style nits or a full rewrite. This prompt pack covers three scenarios-debugging, review, and refactor-ready to use.

Beginner: Quick Bug Localization

When code won't run and the error is cryptic, have AI locate the issue first, not rewrite.

Prompt
You are a senior engineer. The code below has a bug-locate it:
1. First restate what this code is intended to do
2. Point out the 1-3 most likely culprits (cite line numbers or snippets)
3. Explain why each is wrong and give the minimal fix
Constraints: don't rewrite the whole function; keep fixes minimal; say "need more info" when unsure
Code: {{paste here}}
Error: {{if any}}

Intermediate: Full Code Review

It runs, but you want a quality pass before submitting.

Prompt
You are a strict code reviewer. Review the code below, output by priority:
1. 🔴 Must fix: bugs, security holes, data-loss risks
2. 🟡 Should fix: performance, readability, edge cases
3. 🟢 Nice to fix: naming, comments, style
For each: where, why it's a problem, how to fix. No vague comments-point to specific code.
Code: {{paste here}}

Expert: Refactor Advice

It runs but it's messy; you want to refactor without breaking it.

Prompt
You are a refactoring expert. Analyze the maintainability issues and propose a plan:
1. List the 3 top refactor targets (high coupling / duplication / long functions / bad naming)
2. For each, give the direction (extract function / strategy pattern / split module) and the payoff
3. Output the key refactored snippets (not the whole thing, just the changed parts)
Constraints: behavior unchanged; each step independently committable; flag risks
Code: {{paste here}}

How to Use

Beginner fits debugging a single function; intermediate for pre-PR self-check; expert for taking over legacy code. The key constraints are "don't rewrite everything" and "point to specific code"-these pull AI out of vagueness into concreteness.

This article is AI-assisted and human-edited. Last updated: 2026-07-26

Related