PROMPT LIBRARY · CODING
6 coding prompts to practise with
Copy a prompt, replace the [BRACKETS] with your details, run it in any AI tool, then check the result. Each prompt includes the habit that makes it reliable.
1Explain this code
Explain what this code does, line by line, for a beginner. Then list 2 possible bugs and how to test for them. [CODE]
2Debug with evidence
This code gives [ERROR/WRONG RESULT]. Expected: [EXPECTED]. Here is the code and the full error. List likely causes in order, and the smallest test to confirm each. [CODE + ERROR]
3Write tests first
Write unit tests for a function that [BEHAVIOUR], including edge cases (empty input, wrong type, very large values). Use [LANGUAGE/FRAMEWORK].
4Refactor safely
Refactor this function for readability without changing behaviour. Keep the same inputs and outputs, and list every change. [CODE]
5Security review
Review this code for security issues: secrets in code, injection, missing validation, unsafe defaults. Rate each finding and show the fix. [CODE]
6API call example
Show how to call [API ENDPOINT] in [LANGUAGE] with an API key read from an environment variable, handling 401, 429 and timeouts.