coding•5 prompts
AI Coding Prompts
AI can write boilerplate, catch bugs, and suggest better patterns, but only if you prompt it well. These templates produce production-quality code, not just toy examples.
1. Function Generator with Edge Cases
Best: ClaudeWrite a [language] function that [describe behavior]. Requirements: handle these edge cases: [list them], include input validation, add JSDoc/docstring with parameter descriptions, use [naming convention]. Return type: [specify]. Throw meaningful errors, don't return null silently.
Specify the language and conventions upfront. Include example inputs/outputs for clarity.
2. Refactor for Readability
Best: ClaudeRefactor this code to improve readability without changing behavior. Focus on: extracting well-named helper functions, reducing nesting depth, replacing magic numbers with named constants, and simplifying conditionals. Explain each change. [paste code]
Paste the full function with surrounding context. Specify any performance constraints.
3. API Endpoint Implementation
Best: ChatGPTWrite a REST API endpoint in [framework] that [describe operation]. Include: input validation with error messages, proper HTTP status codes, error handling middleware, rate limiting logic, and a brief OpenAPI/Swagger comment. Use [authentication method] for auth.
Specify the framework version. ChatGPT is good at framework-specific boilerplate.
4. Database Query Optimizer
Best: DeepSeekOptimize this database query for performance: [paste query]. Current execution time: [if known]. Table sizes: [approximate rows]. Indexes available: [list them]. Explain: why it's slow, what the query plan likely looks like, and provide an optimized version with expected improvement.
Include the table schema and current indexes. DeepSeek handles complex SQL optimization well.
5. Convert Between Languages
Best: ClaudeConvert this [source language] code to idiomatic [target language]. Don't just translate syntax - use the target language's native patterns, standard library, and best practices. Note any functionality that doesn't have a direct equivalent and how you handled it. [paste code]
Specify which standard library or framework conventions to follow in the target language.
Try These Prompts with Multiple AIs
Get responses from Claude, ChatGPT, Gemini, and more—all at once. Compare which AI handles these prompts best.
Try Council Free