Idiomatic Code
Refactor this code to be more idiomatic for your language.
This prompt
Refactor this code to be more idiomatic for [Language]: [Paste code]
Related prompt
Suggest better comments for this code where they would actually help: [Paste code] Avoid obvious or noisy comments.
All Coding prompts
Bug Diagnosis Prompt
Give the model the error, the code and what you expected. It ranks likely causes by evidence, tells you how to confirm each, and proposes a minimal fix.
Add Defensive Checks
Suggest defensive checks and guards that would make this code safer.
Algorithmic Improvement
Suggest a more efficient approach for this code if appropriate.
Ask for Multiple Approaches
Propose 2–3 different implementation approaches for this problem.
Before / After Refactor Plan
Create a safe refactor plan for this code. Break the improvements into small steps I can apply and verify one at a time.
Behavior-Preserving Refactoring Prompt
Restructures code in small, named steps while holding its observable behavior fixed, and reports anything it could not prove equivalent.
Clear Spec to Code
Write clean and maintainable code for this requirement.
Code with Explicit Assumptions
Generate code for this task. Before writing the code, list your assumptions.
Constrain the Style
Generate code for this task using these style rules.
Debug a Specific Problem
I’m seeing this bug. Here is the relevant code.
Debug with Structure
I’m facing this bug. Here is the relevant code.
Dependency Review
Analyse the dependencies in this code and suggest ways to reduce unnecessary coupling.
Design Before Coding
Help me design a clean solution before writing code.
Design Review
Review the design decisions in this code. Comment on coupling, cohesion and separation of concerns.
Edge Case Analysis
Identify important edge cases this code may not handle well.
Error Handling Review
Review the error handling in this code. Suggest clearer and more reliable handling of failures.
Explain Code Clearly
Explain what this code does in plain language.
Explain Risk Areas
Identify the riskiest parts of this code and explain why they need careful attention.
Extract Functions / Modules
Refactor this code by extracting clearer functions or modules.
Fill in a Partial Implementation
Complete this partially written code. Keep the existing structure and style.
Find Likely Bugs
Analyse this code for likely bugs and edge-case failures.
Full Code Review
Review this code for correctness, readability, maintainability and potential bugs.
Generate + Explain
Write code for this task. How the solution works.
Generate Code + Tests Together
Write the code and useful tests for this requirement.
Generate Tests
Write useful tests for this code. Happy path tests.
Idiomatic Code
Refactor this code to be more idiomatic for your language.
Improve Comments
Suggest better comments for this code where they would actually help.
Improve Error Handling
Improve the error handling in this code. Make failures clearer, safer, and easier to debug.
Improve Naming
Suggest better names for variables, functions and classes in this code.
Input Validation
Suggest stronger input validation for this code.
Interface / API Clarity
Review this interface/API for clarity and ease of use.
JavaScript and TypeScript Function Prompt
A contract-first prompt: the model fixes the signature, types and error behavior of a function or module before it writes the implementation.
Memory / Resource Usage
Analyse this code for potential memory or resource usage problems.
Minimise Complexity
Write the simplest correct solution for this problem.
Missing Test Cases
Review this code and suggest the most important test cases that are likely missing.
Optimise Without Premature Complexity
Review this code for meaningful performance improvements.
Performance Review
Review this code for meaningful performance issues.
Prioritised Review Summary
Review this code and give me a prioritised summary.
Production-Minded Generation
Write production-minded code for. Clear structure.
Python Script and Module Prompt
Turns a plain-language spec into a complete, typed Python script or module, with assumptions, run commands and edge cases listed separately.
Race Conditions / Concurrency Issues
Analyse this code for concurrency or race condition risks.
Reduce Nesting
Refactor this code to reduce nesting and improve control flow.
Refactor for Clarity
Refactor this code to improve clarity and readability while preserving behaviour.
Refactor for Clarity (Productivity Version)
Refactor this code to make it cleaner and easier to maintain.
Remove Duplication
Identify duplication in this code and refactor to reduce it.
Replace Complex Logic with Clearer Structure
Propose a cleaner structure for this complex logic.
Review for Maintainability
Evaluate how maintainable this code is. Identify what would make it harder to change later and suggest improvements.
Review for Readability
Review this code purely from a readability perspective.
Review for Simplicity
Review this code and suggest ways to simplify it without changing behaviour.
Safe Defaults
Identify unsafe defaults or risky assumptions in this code and recommend safer alternatives.
Security Review
Review this code for common security issues. Focus on input validation, injection risks, secrets handling and unsafe defaults.
Simplify Conditional Logic
Refactor the conditional logic in this code to make it easier to understand.
Step-by-Step Implementation
Help me implement this feature in small steps.
Strengths and Weaknesses
Review this code and list. What’s done well.
Style Consistency
Review this code for style and consistency issues.
Testability Review
Evaluate how testable this code is and suggest changes that would make testing easier.
Turn Requirements into an Implementation Plan
Turn this feature request into a clear implementation plan.
Understand an Existing Codebase
Help me understand this part of a codebase. How the main pieces fit together.
Unit Test Writing Prompt
Produces a case inventory first, then readable tests that check behavior at the boundaries, with suspected bugs flagged instead of encoded as passing.
Write Clean Code from a Clear Spec
Write clean, readable, and production-minded code for this task.
Write a Clear Summary
Summarise what this code does in plain language.
Related guides
Technical guide
36 Code Review Prompts for AI: Debug & Refactor (2026)
A complete set of AI prompts to review, debug, refactor and improve code quality.