Coding Prompts

Coding prompts optimized for ChatGPT, Claude, and Cursor. Get better code generation, debugging, and code review results with these structured templates.

Code Generation

Function: “Write a [language] function that [description]. Include: input validation, error handling, type hints, and a docstring. Also write 3 unit tests covering normal use, edge cases, and error conditions.”

API Endpoint: “Create a [framework] API endpoint that [description]. Include: request/response schemas, authentication, input validation, error responses, and rate limiting. Follow RESTful conventions.”

Debugging

Error Analysis: “I’m getting this error: [error]. Here’s the relevant code: [code]. 1) Explain why this error occurs, 2) Provide the fix, 3) Explain how to prevent similar issues, 4) Are there any related potential bugs?”

Code Review

PR Review: “Review this code change. Focus on: correctness, security (OWASP top 10), performance implications, maintainability, and test coverage. For each issue, rate severity (critical/major/minor) and suggest a fix.”

For coding tools, see AI Coding Tools. For prompt engineering, explore Prompt Engineering.