Skip to content
AI Resource Hub

Programming prompts

Prompts for Python, JavaScript, SQL, debugging, documentation and software design.

11 prompts

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
JavaScript

Explain this JavaScript code

Understand unfamiliar JavaScript line by line.

Explain this JavaScript code to someone with [beginner/intermediate] experience: ```js [paste code] ``` 1. Summarise what it does in 2 sentences. 2. Walk through it section by section. 3. Point out any bugs, security problems or outdated patterns. 4. Suggest one improvement with an example.

How to use it

Great for code you inherited or found online. Test any suggested change.

Details
JavaScript

Accessible form validation in JavaScript

Client-side validation with accessible error messages.

Write vanilla JavaScript (no frameworks) to validate this HTML form: ```html [paste form HTML] ``` Rules: [e.g. email required and valid, phone optional, password 12+ characters] Show errors next to each field, link them with aria-describedby, move focus to the first invalid field on submit, and don't block the user from typing. Remind me that server-side validation is still required.

How to use it

Client-side validation improves usability, but always validate on the server too.

Details
SQL

Write a SQL query from plain English

Describe what you need and get a SQL query that matches your schema.

Write a SQL query for [database: PostgreSQL / MySQL / SQL Server / SQLite]. Tables: [paste CREATE TABLE statements or column lists] What I need: [plain-English description, e.g. "top 10 customers by total spend in 2025, with their email and number of orders"] Explain each part of the query, mention any indexes that would help performance, and point out edge cases (e.g. NULLs, ties).

How to use it

Test on a copy of your data. Check that joins don't duplicate rows.

Details
Debugging

Debug an error message

Find the cause of an error and fix it, with an explanation.

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 it

Include the full error and what you've already tried. Remove passwords and API keys from code before pasting.

Details
Debugging

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.

Details
Code documentation

Add documentation to code

Generate docstrings and comments in your project's style.

Add documentation to this code using [docstring style, e.g. Google style, JSDoc]. ```[language] [paste code] ``` Document each function's purpose, parameters, return value, and errors raised. Add comments only where the logic isn't obvious. Don't change the code itself.

How to use it

Check that the documentation matches what the code actually does.

Details
Code documentation

Project README

A clear README for a code project.

Write a README.md for my project. Name: [name] What it does: [description] Tech stack: [list] How to install and run: [steps/commands] Configuration: [environment variables] Licence: [licence] Sections: overview, features, requirements, installation, usage with examples, configuration, contributing, licence. Keep it concise and use code blocks for commands.

How to use it

Run every command in the README yourself to make sure it works.

Details
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
Software development

Write unit tests

Generate tests covering normal cases, edge cases and errors.

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 it

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

Details