A Few Prompts I Use When Developing, Organized
Lately, having AI do code reviews has become a habit for me, but just saying "take a look at this" doesn’t work well—giving it a role and criteria makes a difference. Here are the formats I use often.
- Review: "You are a senior backend developer with 10 years of experience. Point out issues in the code below from the perspectives of performance, readability, and security, and assign a priority to each item."
- Refactoring: "Remove duplication while preserving behavior. Add comments explaining the reason for each change."
- Testing: "First list test cases focused on boundary values and exception cases, then write the code."
The key seems to be specifying 'role + criteria + output format.' This significantly cuts down on unnecessary fluff.
10 answers
Do you have a source? I feel like most prompt tips of this kind are just hearsay.
This is so true lol. If you don’t give it a role, it just turns into a compliment machine.
I feel the same way. If you just say "take a look," there isn't much there.
Well, I’m not so sure about that. Isn’t it better to write good code than to write good prompts? lol I’ve also seen cases around me where someone blindly trusted an AI review, applied a weird suggestion as-is, and ended up causing an outage. Use it only as a reference, and a human should make the final call.
Oh, I didn't know this—saving it for later.
I disagree. Role prompts ultimately just restate what the model already knows, and these days models can figure that out on their own. I suspect the difference comes not from the prompt but from the model version and the amount of context.
Having it pull test cases first is really great. If you ask it to write code right away, you just get happy-path cases endlessly. I also add "a one-line explanation of why each case is needed"—try adding that. It makes it easier to find coverage gaps.
In a refactoring prompt, asking the AI to "add comments explaining why the change was made" can be a bit risky: if the AI invents a plausible-sounding reason and bakes it into a comment, people may later believe it's actually true. I prefer to have it summarize the rationale in the commit message or PR description instead of in comments.
But I’m a bit skeptical about how much the "10-year senior" role assignment actually changes the results. Have you ever run benchmarks on it? Honestly, role prompts don’t really feel like they make much difference—maybe it’s just in my head—and specifying criteria (a checklist) had a bigger effect. Output format definitely seems to work, though.
When I ask for a review, I always include: "If there's nothing to point out, say so. Don't force problems." Without this, they create issues that aren't even there and point them out. I also agree with making them assign priorities; otherwise, minor style nitpicks pour in with the same weight as security issues, making it hard to read.