FREE PRACTICAL AI LEARNING · LEARN BY DOINGNO SIGNUP NEEDED · YOUR WORK STAYS YOURS
Open PracticePRACTICAL AI ENGINEERING
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]

Make it reliable: Ask for tests, not just explanations.

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]

Make it reliable: Full error messages get much better answers.

3Write tests first

Write unit tests for a function that [BEHAVIOUR], including edge cases (empty input, wrong type, very large values). Use [LANGUAGE/FRAMEWORK].

Make it reliable: Tests first makes AI code safer to accept.

4Refactor safely

Refactor this function for readability without changing behaviour. Keep the same inputs and outputs, and list every change.

[CODE]

Make it reliable: Run your tests before and after.

5Security review

Review this code for security issues: secrets in code, injection, missing validation, unsafe defaults. Rate each finding and show the fix.

[CODE]

Make it reliable: Never paste real secrets into any AI.

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.

Make it reliable: Keys belong in secrets, not in code.

Other categories