Petit test
Guess first, no penalty. A developer types: "Write a Python function that removes duplicate emails from a list." What is missing?
A prompt is the message you send to the AI. For code, a vague prompt gets code that runs but makes choices you didn't make. An edge case is an unusual input, such as an empty list, that breaks code written only for normal input.
A coding prompt that gets reviewable code has four parts:
- Task: one verb and one job. "Write a function that...", "Add a test for...".
- Context: where the code runs, the data it gets, and the language version.
- Rules: style, error handling, and limits like "no new dependencies" (outside packages your code would need to install).
- Return: what you want back. Ask for the code, the edge cases it handled, and tests.
Asking for edge cases and tests is the trick. It makes the model show its assumptions, so you review choices instead of hunting for them.
A worked example
Task: Write a Python 3.12 function dedupe_emails(emails: list[str]) -> list[str].
Context: Input comes from a CSV upload. Emails may have spaces or capitals.
Rules: Keep the first time each email appears, in the original order.
Treat "[email protected]" and "[email protected] " as the same. Skip blank strings.
No new dependencies. Raise TypeError if the input isn't a list.
Return: the function, a list of edge cases you handled, and 4 pytest tests.
Complétez les trous
Fill the gaps.
Prompt
Task: . Rules: . Return: the function, .
Your turn:
Task: Write [what] that [does what].
Context: It runs in [where]. Input looks like [example]. Language: [version].
Rules: [style], [error handling], [no new dependencies?]
Return: the code, the edge cases you handled, and [N] tests.
Try it
Vos étapes, environ 2 minutes
- 1.Write the prompt for a small function you need this week, and compare its edge cases with yours. Add the template to your AI code review kit.2 min