Skip to content
AI Resource Hub
Software development

Write unit tests

Generate tests covering normal cases, edge cases and errors.

The prompt

Write unit tests for this function using [test framework, e.g. pytest, Jest, Vitest].

```[language]
[paste function]
```

Cover normal inputs, edge cases (empty, zero, very large, unusual characters), and error handling. Use clear test names that describe the expected behaviour. Point out any behaviour that seems like a bug rather than writing a test that passes for it.

How to use this prompt

  1. Select Copy prompt.
  2. Paste it into your AI assistant (ChatGPT, Claude, Gemini, Copilot or similar).
  3. Replace every part in [square brackets] with your own details before sending.
  4. Review the answer and ask for changes — the first reply is a draft.

Tip: Run the tests; a failing test may reveal a real bug.

Related prompts

Software development

Plan a feature before coding

Break a feature into requirements, design decisions and tasks.

Help me plan this feature before I write code. Project: [description and tech stack] Feature: [what users should be able to do] Constraints: [deadlines, performance, existing architecture] Give: user stories, acceptance criteria, data model changes, API/interface changes, edge cases, security considerations, a task breakdown in the order to build it, and the tests I should write.

How to use it

Use the plan to discuss with your team before building.

Details
Python

Write a Python script with explanations

Get working Python code plus an explanation of how it works.

Write a Python script that [describe the task]. Input: [describe input data/format] Output: [describe expected output] Python version: [e.g. 3.12] Libraries allowed: [e.g. standard library only, pandas] Requirements: clear variable names, comments for non-obvious parts, error handling for [likely problems], and a small example of how to run it. After the code, explain how it works in plain English and list any assumptions you made.

How to use it

Run the code on test data first. Read the assumptions list and correct any that are wrong.

Details
Python

Clean a dataset with pandas

Generate pandas code to clean and summarise a messy CSV.

I have a CSV with these columns and sample rows: [paste column names and 5 sample rows — remove personal data] Problems I see: [e.g. missing values, mixed date formats, duplicates] Goal: [e.g. monthly sales totals by region] Write pandas code that loads the file, fixes these problems step by step with comments explaining each choice, and produces the goal output. Print row counts before and after each cleaning step so I can check nothing was lost unexpectedly.

How to use it

Never paste real customer data into an AI tool; use anonymised samples.

Details