Skip to content

Coding & Technical Prompts

Templates for debugging, explaining, writing, and reviewing code. These work whether you’re a seasoned developer or just getting started with scripting.


When to use it: You hit an error message and don’t know what’s causing it or how to fix it.

I'm getting the following error. Help me debug it.
Error message:
[PASTE THE FULL ERROR MESSAGE HERE]
Relevant code:
[PASTE THE CODE SECTION WHERE THE ERROR OCCURS]
Context:
- Language/framework: [e.g., Python 3.11, Node.js, React]
- What I was trying to do: [ONE SENTENCE DESCRIPTION]
- What I've already tried: [ANY FIXES YOU ATTEMPTED]

!!! tip Always include the full error message, not just the last line. Stack traces have the context Claude needs to diagnose the root cause quickly.


When to use it: You’re reading someone else’s code (or your own from 6 months ago) and need to understand what it does.

Explain the following code to me. I [am new to programming / have intermediate experience / am experienced but unfamiliar with this library].
Walk through what it does step by step. For any patterns or concepts that aren't obvious, explain them briefly.
Code:
[PASTE YOUR CODE HERE]

!!! example “Filled-in example” Explain the following code to me. I am new to programming.

Walk through what it does step by step. For any patterns or concepts that aren't obvious, explain them briefly.
Code:
def process_items(items):
return [item.strip().lower() for item in items if item]

!!! tip Add “Focus especially on [X]” to direct attention to the part you’re most confused about. Useful for large files.


When to use it: You need a one-off script to automate something and don’t want to write it from scratch.

Write a [Python/Bash/JavaScript] script that does the following:
Task: [DESCRIBE WHAT THE SCRIPT SHOULD DO]
Inputs: [WHAT DATA OR FILES IT RECEIVES]
Outputs: [WHAT IT SHOULD PRODUCE]
Requirements:
- [REQUIREMENT 1]
- [REQUIREMENT 2]
Keep it simple and well-commented. If there are multiple approaches, use the most straightforward one.

!!! example “Filled-in example” Write a Python script that does the following:

Task: Read a CSV file of email addresses, remove duplicates, and output a cleaned CSV.
Inputs: A CSV file with a column called "email"
Outputs: A new CSV file called "emails_clean.csv"
Requirements:
- Case-insensitive deduplication ([email protected] and [email protected] are the same)
- Print a summary of how many duplicates were removed
Keep it simple and well-commented.

!!! tip If you need it to run in a specific environment, mention it: “This will run on a Mac” or “This runs inside a Docker container with Python 3.11.”


When to use it: You have working code in one language and need it in another.

Convert the following [SOURCE LANGUAGE] code to [TARGET LANGUAGE].
Preserve the same logic and behavior. Use idiomatic patterns for the target language — don't just do a line-by-line translation. Add a brief note if anything doesn't translate directly.
Code:
[PASTE YOUR CODE HERE]

!!! tip Specify the version if it matters: “Python 3.12” or “ES2020 JavaScript.” Some language features don’t exist in older versions.


When to use it: You have a function and want test coverage but don’t want to write all the test cases manually.

Write unit tests for the following function.
Testing framework: [pytest / Jest / JUnit / etc., or "whatever is standard for this language"]
Cover:
- The happy path (normal expected inputs)
- Edge cases (empty inputs, boundary values, unexpected types)
- Error cases (inputs that should raise exceptions or return errors)
Function:
[PASTE YOUR FUNCTION HERE]

!!! tip After getting the tests, ask “what cases did you not cover and why?” — Claude will often flag scenarios it deliberately skipped.


Review This Code for Bugs and Improvements

Section titled “Review This Code for Bugs and Improvements”

When to use it: You want a code review before merging, shipping, or sharing something.

Review the following code and give me two separate sections:
1. Bugs and issues: anything that will cause errors, unexpected behavior, or security problems
2. Improvement suggestions: readability, performance, better patterns — things that aren't bugs but make the code better
Be specific. For each item, explain what the problem is and how to fix it.
Language/framework: [LANGUAGE OR FRAMEWORK]
Code:
[PASTE YOUR CODE HERE]

!!! tip Add “Focus especially on security” or “Focus especially on performance” if you have a specific concern.


When to use it: You’ve built something and need documentation so other people (or future you) can understand and use it.

Write a README.md for the following project.
Include:
- What it does (1-2 sentences)
- Requirements / dependencies
- How to install and set it up
- How to use it (with a basic example)
- Any important configuration or environment variables
Project description:
[DESCRIBE YOUR PROJECT OR PASTE RELEVANT CODE]
Tech stack: [LANGUAGE, FRAMEWORKS, KEY LIBRARIES]

!!! tip Paste your main file or entry point along with the description — Claude can infer a lot about requirements and usage from the actual code.


When to use it: You need to understand something new, or explain it to someone without a technical background.

Explain [TECHNICAL CONCEPT] in plain terms.
My background: [no programming experience / some programming / experienced developer unfamiliar with this area]
Use an analogy if it helps. Give a brief real-world example of when this matters.
Keep it under 200 words unless more depth is genuinely needed.

!!! example “Filled-in example” Explain “idempotency” in plain terms.

My background: experienced developer unfamiliar with this area.
Use an analogy if it helps. Give a brief real-world example of when this matters.
Keep it under 200 words unless more depth is genuinely needed.

When to use it: You need realistic test data to develop against and don’t want to invent it yourself.

Generate [NUMBER] rows of sample data in [FORMAT: JSON / CSV / SQL INSERT statements] for the following schema:
[DESCRIBE THE DATA STRUCTURE OR PASTE YOUR SCHEMA]
Requirements:
- Make the data realistic (real-looking names, plausible numbers, valid formats)
- Include variety — don't repeat the same values
- [ANY SPECIFIC CONSTRAINTS, e.g., "dates should be within the last 90 days"]

!!! tip For sensitive fields like emails or phone numbers, ask Claude to generate realistic-looking but clearly fake data: “use @example.com domains” or “use 555-xxxx phone numbers.”


When to use it: You know what you want to accomplish but aren’t sure of the best approach, or your current solution feels overcomplicated.

What is the simplest way to [DESCRIBE WHAT YOU WANT TO DO] in [LANGUAGE/FRAMEWORK]?
Context: [BRIEF DESCRIPTION OF YOUR SITUATION]
I want the most straightforward approach — not the most elegant or scalable one. If there's a built-in way to do this, show me that first. Include a working code example.

!!! tip “Simplest” is a more useful constraint than “best.” It pushes Claude toward practical, readable solutions rather than impressive but complex ones.