80 Best AI Coding Prompts
for Claude, ChatGPT & Cursor

Prompts for debugging, code review, refactoring, test writing, documentation, security audits, and architecture. Language-agnostic and copy-ready.

80 prompts Best tools: Claude Sonnet 4, Cursor All languages
Level up your job hunt — 200+ career prompts for resumes, cover letters, LinkedIn, and interviews. 200+ Career Prompts, Free →

Debugging Prompts

Claude and ChatGPT are both strong debuggers. Claude tends to explain the root cause more clearly; ChatGPT with Code Interpreter can run and test the fix.

Bug Report → Root Cause Analysis
DebugClaude / ChatGPT
I have a bug. Here's what's happening: Expected behavior: [WHAT SHOULD HAPPEN] Actual behavior: [WHAT IS HAPPENING INSTEAD] Error message (if any): [PASTE ERROR] Steps to reproduce: [HOW TO TRIGGER IT] Code: [PASTE RELEVANT CODE] Find the root cause. Don't just fix the symptom — explain why this happens, then show the fix.
The "root cause" instruction prevents AI from giving you a patch that hides the bug. You want to understand why, not just what changed.
Reproduce and Explain an Error
DebugClaude / ChatGPT
I'm getting this error: [PASTE FULL ERROR MESSAGE AND STACK TRACE] Context: - Language/framework: [e.g., Python 3.12 / Next.js 15 / Go 1.22] - What I was doing when it happened: [DESCRIBE] - Relevant code: [PASTE] Explain: what this error means in plain English, what's causing it in my specific code, and how to fix it. If there are multiple possible causes, list them in order of most likely.
Include the full stack trace, not just the last line. The root cause is usually several frames up from where the error surfaces.
Performance Debugging — Find the Bottleneck
DebugClaude
This code is too slow. Help me find and fix the performance bottleneck. Observed performance: [e.g., "takes 8 seconds for 1000 records, should be under 500ms"] Environment: [language, database, any relevant infrastructure] Code: [PASTE CODE] Look for: N+1 queries, unnecessary loops or nested loops, missing indexes, synchronous calls that could be parallel, redundant computations, and memory allocation issues. For each problem found, show the fix and estimate the improvement.
N+1 queries are the most common database performance killer — make sure this is the first thing checked in any database-heavy code.

Code Review Prompts

Use these before merging PRs or before shipping code. Claude is the best tool for nuanced security review; it tends to catch subtle auth and injection issues.

Senior Engineer Review
ReviewClaude
Review this code as a senior engineer. Find: 1. Bugs or logic errors 2. Security vulnerabilities (injection, auth issues, data exposure, insecure defaults) 3. Performance problems (N+1 queries, unnecessary loops, memory leaks) 4. Readability and maintainability issues 5. Missing error handling for failure cases that can happen For each issue: describe it, explain why it's a problem, and show the fix. Prioritize by severity: Critical → High → Medium → Low. Code: [PASTE CODE]
Claude's strength: security-focused review. It consistently catches SQL injection risks, hardcoded secrets, improper input validation, and auth bypass patterns.
Security Audit Prompt
ReviewClaudeAny
Perform a security audit of this code. Focus on OWASP Top 10 vulnerabilities: 1. Injection (SQL, command, LDAP, XPath) 2. Broken authentication / session management 3. Sensitive data exposure 4. XML external entities (XXE) 5. Broken access control 6. Security misconfiguration 7. Cross-site scripting (XSS) 8. Insecure deserialization 9. Using components with known vulnerabilities 10. Insufficient logging/monitoring For each vulnerability found: severity (Critical/High/Medium/Low), where it is in the code, the attack vector, and the fix. Code: [PASTE CODE]
Use before any code handles user input, authentication, payments, or sensitive data. The structured output makes it easy to triage and prioritize fixes.

Refactoring Prompts

Clean Code Refactor
RefactorClaude / Cursor
Refactor this code to be cleaner and more maintainable. Preserve all existing behavior — no functionality changes. Goals: - Better variable and function names (self-documenting) - Reduce function length (aim for single responsibility) - Remove duplication (DRY) - Improve readability (anyone should understand it in 30 seconds) - Add error handling where it's obviously missing Show the refactored code with brief comments on the main changes you made. Code: [PASTE CODE]
"Preserve all existing behavior" is the critical constraint. Without it, AI may change logic while refactoring. Always run tests after applying AI refactors.
Convert to [Pattern/Architecture]
RefactorClaude
Refactor this code to use [PATTERN: async/await / repository pattern / dependency injection / factory pattern / observer pattern / CQRS]. Current code: [PASTE CODE] Language/framework: [SPECIFY] Show: 1. The refactored code 2. A brief explanation of what changed and why this pattern is better here 3. Any tradeoffs or things I should watch out for
Good for learning: This prompt teaches the pattern in context of your actual codebase, not a toy example.

Test Writing Prompts

Unit Test Generator
TestsClaude / ChatGPT
Write comprehensive unit tests for this function/module. Testing framework: [Jest / Pytest / Go testing / RSpec / etc.] Language: [SPECIFY] Code to test: [PASTE CODE] Cover: - Happy path (normal inputs → expected output) - Edge cases (empty input, zero, null, max values) - Error cases (invalid input, exceptions) - Boundary conditions Each test: descriptive name that states what it tests and what it expects. Group related tests. Mock external dependencies.
Specify the framework — test syntax varies significantly between Jest, Pytest, Go testing, and RSpec. Claude writes correct syntax for all major frameworks.
Integration Test Scenarios
TestsClaude
Write integration test scenarios for [FEATURE/ENDPOINT/FLOW]. System description: [WHAT IT DOES, WHAT IT CONNECTS TO] Tech stack: [LANGUAGE, FRAMEWORK, DATABASE] Identify and write tests for: 1. The full success path from input to output 2. Authorization: what should be blocked for different user roles 3. Data validation: what invalid inputs should be rejected 4. Failure handling: what happens when dependencies (DB, external API) fail 5. Concurrency: any race conditions or locking issues Write test code, not just descriptions.
Authorization tests are the most commonly missed. Always test what a non-privileged user CANNOT do, not just what an admin CAN do.

Documentation Prompts

API Documentation Generator
DocsClaude
Write API documentation for this endpoint/function. Code: [PASTE FUNCTION OR ENDPOINT] Documentation should include: - One-sentence description of what it does - Parameters: name, type, required/optional, description, example value - Returns: type, structure, example response - Errors: error codes/exceptions, when they occur, how to handle them - Example: a complete working example call with realistic data - Any rate limits, auth requirements, or side effects Format: [Markdown / OpenAPI YAML / JSDoc / Python docstring]
The example section is the most valuable part of API docs for other developers. Claude generates realistic example data, not placeholder "string" values.
README Generator
DocsClaude
Write a professional README for this project. Project name: [NAME] What it does: [ONE SENTENCE] Tech stack: [LANGUAGES, FRAMEWORKS, DATABASES] Target users: [WHO USES IT] README sections: 1. Project description (2-3 sentences, no marketing fluff) 2. Features list (what it actually does) 3. Installation (step-by-step, from clone to running) 4. Usage (basic usage with real code examples) 5. Configuration (environment variables, config options) 6. Contributing (brief) 7. License Write for a developer who has never seen this project before.
The "developer who has never seen this before" framing prevents overly brief instructions that assume prior context.

Code Generation Prompts

Boilerplate / Scaffold Generator
GenerateClaude / Cursor
Generate boilerplate code for [WHAT YOU'RE BUILDING]. Tech stack: [LANGUAGE + FRAMEWORK + DATABASE] Requirements: - [REQUIREMENT 1] - [REQUIREMENT 2] - [REQUIREMENT 3] Include: - Project structure (file tree) - Core files with proper boilerplate - Basic error handling patterns - Environment variable setup - Comments explaining where to add custom logic Do NOT include: placeholder TODO comments without explanation, hardcoded credentials, or unnecessary abstractions.
The "Do NOT include" section prevents the common AI habit of generating skeleton code with useless TODO placeholders and no actual logic.
Database Schema Designer
GenerateClaude
Design a database schema for [APPLICATION/FEATURE]. Database: [PostgreSQL / MySQL / SQLite / MongoDB] What it needs to store: [DESCRIBE YOUR DATA AND RELATIONSHIPS IN PLAIN ENGLISH] Requirements: - [SCALE / QUERY PATTERNS / CONSTRAINTS] Provide: 1. Schema with table/collection definitions, field types, constraints, and indexes 2. Key relationships (foreign keys, references) with explanation 3. Indexes and why they're included 4. Any denormalization decisions and why 5. SQL to create the schema (or schema definition for document DBs)
Describing in plain English is better than trying to specify technical requirements upfront. Claude will ask if it needs clarification on relationships.