Debug an error message
Find the cause of an error and fix it, with an explanation.
The prompt
I'm getting this error: ``` [paste full error message and stack trace] ``` Relevant code: ``` [paste the code around where the error happens] ``` Environment: [language version, framework, OS] What I expected: [behaviour] What I've tried: [list] Explain the most likely cause, give the fix, and explain why it works. If there are several possible causes, list them in order of likelihood with a way to check each.
How to use this prompt
- Select Copy prompt.
- Paste it into your AI assistant (ChatGPT, Claude, Gemini, Copilot or similar).
- Replace every part in [square brackets] with your own details before sending.
- Review the answer and ask for changes — the first reply is a draft.
Tip: Include the full error and what you've already tried. Remove passwords and API keys from code before pasting.
Related prompts
Code review checklist
A structured review covering bugs, security, readability and tests.
Review this code as a senior developer. ```[language] [paste code] ``` Context: [what it's for] Organise feedback under: Bugs, Security, Performance, Readability, Tests. For each issue: severity (high/medium/low), the line or section, the problem, and the suggested fix. Finish with what's done well.
How to use it
AI reviews miss things; use them alongside human review and automated tests.
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.
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.