Coding & Debugging Prompts

Senior-Level Code Review & Refactor Plan

Get a structured senior-engineer-style code review covering correctness, performance, security, and maintainability, ending in a prioritized refactor plan.

FreeClaudeChatGPT
Best for

Developers and engineering leads who want a thorough, prioritized code review rather than a surface-level style pass, especially before a merge or release.

Suitable LLM groups
ReasoningFrontier
Download Prompt.md
Prompt
Act as a senior software engineer conducting a thorough code review. Review the following code written in {{programming_language}}. Structure your review in this exact order:

1. Correctness — identify any logical bugs, edge cases not handled, or incorrect assumptions.
2. Security — flag any vulnerabilities (e.g. injection risks, unsafe deserialization, missing input validation, secrets handling).
3. Performance — identify inefficiencies (e.g. unnecessary loops, N+1 queries, unneeded allocations) and estimate their real-world impact.
4. Maintainability — comment on naming, structure, duplication, and testability.
5. Prioritized refactor plan — list the top 5 changes ranked by impact vs. effort, and provide corrected code snippets for the top 2.

Do not rewrite the entire file. Focus on the highest-impact issues only.

Code:
```{{programming_language}}
{{code_block}}
```

How to use

  1. Replace {{programming_language}} with the language of your code (e.g. Python, JavaScript, Go).
  2. Paste the specific function or module you want reviewed into {{code_block}} — keep it focused rather than pasting an entire large file.
  3. Read through the review in order; correctness and security issues should be fixed before performance or style issues.
  4. Apply the top 2 corrected snippets first, then address the remaining items in the prioritized list.

Example input

Act as a senior software engineer... Code:
```python
def get_user(user_id):
    query = "SELECT * FROM users WHERE id = " + user_id
    result = db.execute(query)
    return result
```

Example output

1. Correctness — the function assumes user_id is always a valid, existing ID; no handling for a missing user, which will silently return an empty result rather than raising a clear error.
2. Security — this is a SQL injection vulnerability; user_id is concatenated directly into the query string instead of using parameterized queries.
3. Performance — SELECT * retrieves all columns even if only a subset is needed downstream, increasing payload size unnecessarily.
4. Maintainability — no type hints or docstring; unclear what 'result' returns (single row vs list).
5. Prioritized refactor plan: (1) Fix SQL injection via parameterized query [highest impact, low effort], (2) Add explicit not-found handling, (3) Select only needed columns, (4) Add type hints and docstring, (5) Add unit test for missing user case.
Corrected code:
```python
def get_user(user_id: int) -> dict | None:
    query = "SELECT id, name, email FROM users WHERE id = %s"
    result = db.execute(query, (user_id,))
    return result[0] if result else None
```

Customization tips

  • Add context about the code's environment (e.g. 'this runs in a high-traffic production API') so performance and security assessments are calibrated correctly.
  • Ask for a stricter review if the code handles sensitive data (PII, payments, auth).
  • Request the review in a specific format (e.g. as inline comments) if you want to paste it directly into a pull request.

Tags

#code review#refactoring#security#software engineering

FAQ

What is this prompt for?
It produces a structured, senior-engineer-level code review covering correctness, security, performance, and maintainability, ending in a concrete, prioritized action plan.
How much code should I paste in at once?
Keep it focused — a single function, class, or small module works best. Pasting an entire large file tends to produce a shallower, less actionable review.
What's a limitation of this prompt?
The model reviews the code in isolation and does not have access to your full codebase, so it may miss issues that depend on context elsewhere in your system (e.g. how a function is called).
How is this different from just asking 'review this code'?
A generic request often produces a shallow pass focused mostly on style. This prompt enforces a specific, ordered framework (correctness, security, performance, maintainability, then a prioritized plan) that mirrors how experienced engineers actually review code.
Free

Legacy Code Explainer & Refactor Planner

Explains what an unfamiliar or legacy piece of code actually does, then proposes a safe, incremental refactor plan instead of a risky full rewrite.

ClaudeChatGPT
#legacy-code#refactoring#code-review
Free

Code Review Simulator

Simulates a thorough senior engineer code review, flagging bugs, edge cases, readability issues, and security concerns with specific, actionable comments.

ClaudeChatGPT
#code-review#debugging#software-engineering
Free

Root Cause Bug Investigator

Guides a systematic investigation of a bug from symptom to root cause, avoiding quick patches that mask the real problem, and produces a targeted fix.

ClaudeChatGPT
#debugging#root-cause-analysis#bug-fixing

Related Skills

Code ImprovementFree

Code Review & Refactor Assistant

Reviews a pasted code snippet for bugs, readability, and performance issues, then delivers a prioritized refactor with explanations for each change.

ClaudeChatGPTCursor
#code review#refactoring#software engineering
Code ImprovementFree

Engineering Judgment Coach

Makes an AI coding agent pause and reason like a senior engineer before writing code — right layer, reuse over rebuild, the right pattern, and honest refactor timing.

ClaudeClaude CodeCursor
#code quality#software architecture#design patterns
Code ImprovementFree

Code Refactor Advisor

Reviews a code snippet and returns a prioritized refactor plan — readability, structure, and performance issues, each with a concrete fix.

ClaudeChatGPTCursor
#code-review#refactoring#clean-code

Related Articles

Article · Testing & Quality Checks

How to Test AI-Generated Code Before You Trust It

Learn how to review and test AI-generated code before using it in production, including functionality, security, edge cases, permissions, and regression checks.

Jul 5, 20268 min read
Read How to Test AI-Generated Code Before You Trust It
Article · AI Models and Product Launches

Claude Code Security Concerns Highlight Agent Trust Risks

Claude Code’s recent security controversy shows that coding agents must be reviewed as installed software with trust, telemetry, and policy implications.

Jul 9, 20267 min read
Read Claude Code Security Concerns Highlight Agent Trust Risks
Article · AI Coding and Developer Tools

Coding Agent Benchmarks Are Moving Toward Task Types

AI coding agents are becoming measurable in real repositories and workplaces, making review practices and task-specific evaluation essential.

Jul 9, 20267 min read
Read Coding Agent Benchmarks Are Moving Toward Task Types