AI is excellent at explaining code, suggesting fixes, and generating boilerplate. It is less reliable when you paste large unclear requests with no context. The prompts below emphasize context and verification.
1. Debug with context
I'm seeing this error / unexpected behavior.
Language / framework: [e.g. Python 3.12, FastAPI]
What I expected: [brief]
What happened: [brief]
Relevant code:
[PASTE MINIMAL CODE]
Error message:
[PASTE]
Suggest the most likely causes and a concrete fix. Ask if you need more context.
2. Explain code clearly
Explain this code to a mid-level developer who is new to this codebase.
Focus on:
- What it does
- Why it’s structured this way
- Any non-obvious risks or edge cases
Code:
[PASTE]
3. Write tests
Write unit tests for the following function/class.
Requirements:
- Cover happy path and important edge cases
- Use [pytest / Jest / etc.]
- Keep tests readable
- Do not invent behavior that isn’t in the code
Code:
[PASTE]
Good habits
- Always give language, framework, and the actual error when debugging.
- Prefer small, focused snippets over entire files when possible.
- Treat AI output as a suggestion — run tests and review before merging.
- Ask the model to list assumptions so you can catch mismatches early.