Senior-level code review
Professional structure: role, context, objective, details, steps, format, criteria and self-check. Designed for better results, not guaranteed ones: always review the answer.
Never use real personal data. If you need to, run it through the data cleaner.
## Role Act as a senior software engineer who gives demanding but kind code reviews. ## Context I want my code reviewed before merging it. ## Objective Find bugs, security risks, performance and readability problems, with concrete proposals. ## Details (fill in what is in square brackets) - [code or diff, without keys or secrets] - [language and version] - [what the code should do] - [project conventions] ## Step-by-step instructions 1. Summarise what the code does to confirm you understand it. 2. Look for logic errors and edge cases. 3. Check security: inputs, injections, secrets and permissions. 4. Suggest readability and performance improvements with corrected code. ## Output format List of findings with severity (critical, major, minor), line, explanation and proposal; then the corrected snippet. ## Quality criteria - It does not invent non-existent APIs or functions. - Every finding has a specific reason. - It separates bugs from style preferences. ## Self-check Before answering, check every quality criterion. If information is missing, ask me instead of making it up, and at the end state what you have assumed.
Objective
Find bugs, security risks, performance and readability problems, with concrete proposals.
When to use it
This prompt is brilliant when you are working solo or in a small team and need a second pair of eyes before merging a pull request. It excels at catching logic slips and security oversights that tired eyes often miss. However, it is not a replacement for a proper QA cycle or unit tests. Avoid using it for extremely large, multi-file architectural refactors where the context window might get crowded, leading to weaker analysis and less reliable suggestions.
Worked example: input (fictional data)
Worked example: full response
Variants
Quick Sanity Check
Focus strictly on finding critical bugs and security vulnerabilities only. Ignore style, readability, or minor performance nitpicks. Provide your response as a concise, bulleted list. The goal is a rapid pre-commit check rather than a comprehensive code review. Prioritise issues that could immediately crash the application or expose user data.
Junior Developer Mentor
Review this code as if you are mentoring a junior developer. Be encouraging and provide educational explanations for why each change is necessary. Explain the 'why' behind the best practices, such as modularity and cleaner variable naming, to help the developer learn and grow while improving their current code.
Performance Optimisation Focus
Specifically analyse this code for performance bottlenecks, memory leaks, and inefficient algorithms. Identify areas where complexity could be reduced from O(n^2) to O(n). Provide concrete refactoring suggestions that specifically improve execution speed and reduce memory consumption in high-traffic scenarios. Ignore general style conventions.
Common mistakes
- Pasting API keys or customer data in the code.
- Accepting changes without running the tests.
- Expecting the AI to detect logic errors without providing the intended business rules. How to avoid it: Always include a brief description of the expected behaviour so the AI can verify logic.
- Failing to mention specific framework versions when the code relies on platform-specific features. How to avoid it: State the environment and version clearly to ensure the AI suggests relevant, compatible methods.
- Submitting massive, multi-file codebases in a single prompt for a code review. How to avoid it: Break large reviews into smaller, logical chunks to keep the AI focused and accurate.
- Ignoring the AI's suggestions because you assume your initial code was already optimal. How to avoid it: Treat feedback as a discussion point; verify the AI's reasoning before dismissing or accepting changes.
Related guide
General and assistant-specific tips
Tips by assistant
- Claude: ask for the result as an artifact to view and edit it separately from the chat.
- ChatGPT: open the result in Canvas to edit specific paragraphs without regenerating the whole text.
Getting the most out of it
- Paste the prompt as is and only replace what is in [brackets].
- If the answer does not fit, do not start over: ask for “shorter”, “more formal” or “as a table”.
- Always review the result before using it: AI can get facts, dates or names wrong.
Before you paste it: quick checklist
- Remove client names, amounts and internal data before pasting.
- Say who the text is for and which tone you want.
- Ask for a specific length: “120 words max” or “three bullet points”.
- Read the result aloud and fix anything you wouldn’t say yourself.
How to adapt it to your assistant
The template works the same in ChatGPT, Gemini, Copilot or Claude because it only uses plain language. If your assistant supports fixed instructions (custom instructions, Gems or projects), you can store your preferred tone and format there and paste only the variable part. On a free plan, split long requests into two or three shorter messages.