GPT-4o
⚙️ Technical
Intermediate
Code Generation and Review Prompt
Write prompts that produce reliable, well-structured code for any language or framework — specifying requirements, constraints, and expected output to minimize debugging.
The Prompt
# Code Generation and Review Prompt You are a software engineering prompting specialist. Design a code generation prompt framework for [LANGUAGE OR FRAMEWORK]. ## Code Generation Prompt Template Build a prompt template that produces reliable code. Include these elements: - Language and version specification: [LANGUAGE OR FRAMEWORK] version [VERSION] - Task description: exactly what the code must do, in plain language - Input and output specification: data types, formats, edge cases - Constraints: performance requirements, library restrictions, style guide - Error handling requirements: what exceptions to catch and how to respond - Test cases: at least 2 examples the code must pass ## Self-Review Instruction Add a mandatory self-review step at the end of the generation prompt that asks the AI to: - Check the code compiles or parses correctly - Verify it handles all specified edge cases - Confirm it follows the stated constraints - Identify any remaining uncertainty before finalizing ## Code Review Prompt Write a separate prompt for reviewing existing code in [LANGUAGE OR FRAMEWORK]: - Input: paste code + original requirements - Output: bugs found, improvement suggestions, missing error handling, test gaps ## Prompt Pair Provide the complete generation prompt and review prompt, ready to use as a pair for any [LANGUAGE OR FRAMEWORK] task.
📝 Fill in the blanks
Replace these placeholders with your own content:
[LANGUAGE OR FRAMEWORK]
[VERSION]
How to use this prompt
1
Copy the prompt
Click "Copy Prompt" above to copy the full prompt text to your clipboard.
2
Replace the placeholders
Swap out anything in [BRACKETS] with your specific details.
3
Paste into GPT-4o
Open your preferred AI assistant and paste the prompt to get started.