Coding Help
Debug, explain, and generate code with an AI pair programmer.
Write & Convert
Write Regex or SQL From a Description
Act as a [REGEX/SQL] expert. I need a [REGEX PATTERN / SQL QUERY] that does this: [DESCRIBE IN PLAIN ENGLISH, e.g. “match US phone numbers in (555) 123-4567 format” / “find all customers who ordered more than twice in the last 30 days”]. My dialect is [e.g. PostgreSQL / PCRE]. Give me: 1) the pattern/query in a code block, 2) a plain-English breakdown of how each part works, 3) three test cases it should match and two edge cases it correctly rejects. Warn me about any performance gotchas (like catastrophic backtracking or full table scans).
Convert Code Between Languages
Act as a polyglot programmer fluent in [SOURCE LANGUAGE] and [TARGET LANGUAGE]. Convert the code below from [SOURCE] to [TARGET]. Preserve the exact behavior – do not “improve” the logic unless the direct translation would be broken or dangerously unidiomatic, in which case flag the change explicitly. Use idiomatic [TARGET] conventions (naming, error handling, standard library). After the converted code, list: 1) any behavior differences to be aware of, 2) language-specific pitfalls in this translation, 3) what the [TARGET] standard library equivalent of each [SOURCE] dependency is. Code: [PASTE CODE]
Write Unit Tests
Act as a test-driven development coach. Write unit tests for the code below using [TEST FRAMEWORK, e.g. pytest / Jest]. Cover: the happy path, edge cases (empty inputs, boundary values, nulls), and error cases (invalid input, exceptions). Use clear test names that describe the behavior being tested. Mock external dependencies (databases, APIs, file system) – do not hit real services. After the tests, tell me: what coverage gaps remain, and which test would catch the most likely real-world bug. Code: [PASTE CODE] Language/framework: [LANGUAGE + FRAMEWORK]
Build a Function From a Description
Act as a senior [LANGUAGE] developer. Write a function that does this: [DESCRIBE WHAT IT SHOULD DO, its inputs, and the expected output]. Requirements: handle invalid or missing inputs gracefully, include a clear docstring with a usage example, and follow [LANGUAGE] naming conventions. Do not add extra features beyond what I described. After the code, list the edge cases you handled and one assumption you made that I should double-check. Keep it clean and dependency-free unless a library is clearly the right call.
Write a Python Automation Script
Act as an automation specialist. Write a Python script that automates this repetitive task: [DESCRIBE THE TASK, e.g. “rename all files in a folder by date”]. Requirements: read inputs from command-line arguments (not hardcoded paths), print progress as it runs, skip files it cannot process instead of crashing, and include a dry-run mode that lists what it WOULD do before changing anything. Use only the standard library. End with exact instructions for running it on [Windows/macOS/Linux], including how to schedule it to run daily.
Write a Bash Shell Script
Act as a Linux sysadmin. Write a bash script that [DESCRIBE GOAL, e.g. “backs up a folder and keeps the last 7 copies”]. Requirements: exit immediately on any error (set -euo pipefail), validate that required arguments are provided, log each step with timestamps, and clean up temp files even if it fails. Comment every non-obvious line so a beginner can follow it. After the script, show me how to make it executable and how to test it safely with a dry run.
Write a Web Scraper
Act as a data engineer. Write a [Python/JavaScript] script that extracts [WHAT DATA] from [URL OR SITE DESCRIPTION]. Requirements: respect robots.txt and add polite delays between requests, handle pagination, save results to [CSV/JSON], and retry failed requests up to 3 times with backoff. Only scrape publicly available data I have the right to use – flag anything that looks like it may violate the site’s terms. Warn me if the site likely needs JavaScript rendering and suggest the fix.
Build a REST API Endpoint
Act as a backend developer. Build a REST API endpoint in [FRAMEWORK, e.g. Express/FastAPI] for this: [DESCRIBE, e.g. “create a new user account”]. Requirements: validate all inputs and return clear 400 errors, use proper status codes (201 on create, 404 on missing), never expose stack traces or sensitive fields in responses, and include a working curl example request. Show the route, handler, and any middleware. End with a checklist of what to add before production (auth, rate limiting, logging).
Write a Database Migration
Act as a database engineer. Write a migration for [DATABASE, e.g. PostgreSQL] that [DESCRIBE CHANGE, e.g. “adds an email_verified column to the users table”]. Requirements: make it reversible (up AND down), safe to run on a table with existing data (backfill defaults), and idempotent where possible. Warn me about any locking risks on large tables and suggest a safer approach if needed. Show the exact commands to run it with [TOOL, e.g. Alembic/Flyway].
Generate Realistic Test Data
Act as a QA engineer. Generate realistic test data for this schema: [PASTE SCHEMA OR DESCRIBE FIELDS]. I need [NUMBER] rows in [FORMAT, e.g. JSON/CSV/SQL INSERTs]. Requirements: data must look real (believable names, valid email formats, dates in the right range), include tricky cases (unicode characters, very long strings, nulls, duplicates), and NEVER use real people’s data. Give me a small script I can re-run to regenerate it with a different row count.
Write a Spreadsheet Formula
Act as a spreadsheet expert. Write a formula for [Excel/Google Sheets] that does this: [DESCRIBE IN PLAIN ENGLISH, e.g. “sum sales for each region in the last quarter”]. My data is laid out like this: [DESCRIBE COLUMNS, e.g. “Column A = date, B = region, C = amount”]. Give me: the exact formula to paste, a plain-English explanation of each part, and how to adapt it if my columns move. Flag any version-specific functions that may not work in older Excel.
Convert Between Data Formats
Act as a data wrangler. Convert the data below from [SOURCE FORMAT, e.g. CSV] to [TARGET FORMAT, e.g. JSON]. Rules: preserve all values exactly (no rounding numbers, no dropping empty fields), apply these field renames: [OLD NAME to NEW NAME], and nest [FIELD] under [PARENT] in the output. Handle quoted commas and line breaks correctly. After the converted data, tell me how to do this conversion at scale with a one-line command or script. Data: [PASTE DATA]
Write a Dockerfile
Act as a DevOps engineer. Write a Dockerfile for this app: [DESCRIBE, e.g. “a Node.js Express API”]. Requirements: use a minimal official base image, run as a non-root user, copy only what is needed (show a .dockerignore), install dependencies in a cached layer, and expose the right port. Keep the final image small. After the Dockerfile, give me the exact docker build and docker run commands, plus one command to check the image size.
Write a CI/CD Workflow
Act as a DevOps engineer. Write a [GitHub Actions/GitLab CI] workflow for a [LANGUAGE] project that: runs on every pull request, installs dependencies with caching, runs the test suite and linter, and fails the build if either fails. Requirements: use pinned action versions, keep secrets out of logs, and make the YAML readable with comments. After the workflow, tell me how to trigger it manually and where to see the run results.
Write a Google Apps Script
Act as a Google Workspace automator. Write a Google Apps Script that [DESCRIBE, e.g. “emails me a daily summary of new rows in a Sheet”]. Requirements: work from a time-based trigger, handle empty data gracefully, include the exact steps to install the trigger, and never hardcode email addresses – read them from the Sheet. Add error handling that emails me if the script fails. End with how to view the execution log when something goes wrong.
Build a Discord/Slack Bot Starter
Act as a bot developer. Build a starter [Discord/Slack] bot in [LANGUAGE] that [DESCRIBE, e.g. “responds to !help with a list of commands”]. Requirements: load the token from an environment variable (never hardcode it), structure the code so adding new commands is easy, and include basic error handling so one bad command does not crash the bot. Show me exactly where to get the token and how to run the bot locally for testing.
Parse a Log or CSV File
Act as a data engineer. Write a [LANGUAGE] script that parses this file: [DESCRIBE FORMAT, e.g. “Apache access logs”]. Extract [WHAT YOU WANT, e.g. “the top 10 IP addresses by request count”]. Requirements: stream the file line by line (do not load it all into memory), skip malformed lines with a warning count, and print a clean summary table at the end. Show me how to run it against a 10GB file without running out of memory.
Write a Backup Script
Act as a sysadmin. Write a [bash/Python] script that backs up [WHAT, e.g. “/var/www”] to [WHERE, e.g. an external drive or S3]. Requirements: keep the last [N] backups and delete older ones automatically, verify each backup is not corrupt after creating it, log success/failure with timestamps, and send me an alert (email or message) if it fails. Include a dry-run mode. Show the cron line to run it every night at 2 AM.
Build an HTML/CSS Page From a Description
Act as a front-end developer. Build a single-file HTML page with embedded CSS for this: [DESCRIBE, e.g. “a landing page for a dog-walking business with hero, services, and contact sections”]. Requirements: clean semantic HTML, modern responsive CSS (mobile-first, no frameworks), and accessible contrast and labels. No JavaScript unless I ask. After the code, tell me how to preview it locally and one thing to change before using it on a real site.
Write a Form Validator
Act as a front-end developer. Write JavaScript validation for a form with these fields: [LIST FIELDS AND RULES, e.g. “email must be valid, password min 8 chars”]. Requirements: validate on submit AND as the user types, show a clear error message next to each invalid field, prevent submission until all fields pass, and never rely on client-side validation alone – note what the server must re-check. Keep the code framework-free so I can adapt it anywhere.
Write a Password Generator
Act as a security-conscious developer. Write a [LANGUAGE] function that generates a secure random password: [LENGTH] characters, including [UPPERCASE/LOWERCASE/NUMBERS/SYMBOLS as needed]. Requirements: use a cryptographically secure random source (NOT Math.random or the basic random module), exclude ambiguous characters like l, 1, O, 0, and include a strength check that rejects weak results. Explain in one line why the random source you chose is safe.
Write a Cron Schedule Command
Act as a Linux sysadmin. I want this to run automatically: [DESCRIBE, e.g. “a Python script that emails a report”]. The schedule is [DESCRIBE IN WORDS, e.g. “every weekday at 8 AM”]. Give me: the exact cron line, a plain-English translation of each field so I understand it, where to put it (crontab -e), and how to log output to a file so I can debug failures. Warn me about the two most common cron gotchas (PATH and environment variables).
Generate a GraphQL Query
Act as an API developer. Write a GraphQL query against this schema: [PASTE SCHEMA OR DESCRIBE TYPES]. I need to fetch [WHAT DATA, e.g. “a user’s orders with product names”]. Requirements: request only the fields I need (no over-fetching), use variables for inputs, handle pagination with first/after, and use fragments if the same fields repeat. Show the query plus an example variables object. Flag any N+1-style pitfalls in my request.
Write an API Client Wrapper
Act as a backend developer. Write a [LANGUAGE] wrapper class for this API: [API NAME AND DOCS LINK OR DESCRIPTION]. It must support these calls: [LIST, e.g. “list users, create order”]. Requirements: handle auth headers in one place, retry on 429/5xx with exponential backoff, raise clear custom exceptions on errors (never return raw error blobs), and include a short usage example for each call. Keep the interface simple enough that a teammate can use it without reading the API docs.
Add Pagination to a List
Act as a backend developer. Add pagination to this endpoint/query that currently returns everything: [PASTE CODE]. Requirements: use cursor or offset pagination (recommend which and why for my case), return total count and a has-more flag, validate page size with a sane max, and keep it working with existing filters and sorting. Show the updated code plus an example of fetching page 2. Warn me about the performance trap of OFFSET on large tables.
Write a Search and Filter Function
Act as a [front-end/backend] developer. Write a search and filter function for [DESCRIBE DATA, e.g. “a product list with name, category, price”]. It must support: text search across [FIELDS], filtering by [CRITERIA], and sorting by [OPTIONS]. Requirements: make text search case-insensitive and typo-tolerant if reasonable, combine filters with AND logic, and return results fast for [N] items – say if I need indexing. Include 5 test cases proving each feature works.
Add a CSV Export Feature
Act as a [back-end/front-end] developer. Add a “Download CSV” feature for this data: [DESCRIBE DATA SOURCE, e.g. “the users table via my Flask admin page”]. Requirements: escape commas, quotes, and newlines correctly, include a header row, stream large exports instead of building the whole file in memory, and set the right filename and MIME type so the browser downloads it. Show the code plus how to test it with data containing tricky characters.
Scaffold a Project Structure
Act as a senior [LANGUAGE] developer. Scaffold a clean project structure for [DESCRIBE PROJECT, e.g. “a Flask REST API with auth”]. Requirements: separate routes, business logic, and data access; manage config via environment variables; include a tests folder mirroring the source layout; and include a README skeleton. Show the full folder tree with one-line descriptions of each file’s job, then generate the key starter files. Tell me what to build first.
Turn Pseudocode Into Working Code
Act as a senior [PROGRAMMING LANGUAGE] developer. Convert my pseudocode into clean, working code. Pseudocode: [PASTE PSEUDOCODE]. Requirements: [LANGUAGE VERSION, e.g. Python 3.12], style: [FUNCTIONAL / OOP], constraints: [ALLOWED LIBRARIES, PERFORMANCE NEEDS]. Output: the complete code with clear variable names and comments on the non-obvious parts, plus a short runnable example with sample input. If any step of the pseudocode is ambiguous, state your assumption in a brief note before the code instead of guessing silently. Do not add features I did not describe.
Write a File Organizer Script That Never Deletes
Act as a careful automation engineer who writes safe utility scripts. Write a [PYTHON / BASH] script that organizes files in [FOLDER PATH] by [RULE, e.g. file type or date] into subfolders I name here: [SUBFOLDER NAMES]. Requirements: default to a dry-run preview that prints a table (File | Current Location | New Location | Reason) and changes nothing, and only move files when I pass the [CONFIRM FLAG]. Never delete, overwrite, or change a file extension: if a name collides, add a numbered suffix. Log every move to [LOG FILE NAME], handle spaces in filenames, and end with usage instructions and 3 test cases.
Build a Tiny Command-Line Tool From a Job Description
Act as a senior developer who builds small, reliable tools. I need a command-line tool that does this job: [JOB, e.g. rename photos by date or merge CSV files]. Use [PYTHON / JAVASCRIPT] on [WINDOWS / MAC / LINUX]. Inputs are [INPUT FILES OR FOLDER] and the output must be [DESIRED OUTPUT]. Deliver: (1) the complete runnable script in one code block, (2) 3 example commands with expected results, and (3) a short troubleshooting list. Rules: default to a preview mode that changes nothing, handle bad inputs with a clear error instead of crashing, add comments a beginner can follow, and add no extra features.
Write a CSV Cleanup Script With a Before-and-After Report
Act as a careful data engineer who never destroys the original file. Write a [PYTHON / BASH] script that cleans a CSV at [FILE PATH]. Cleanup rules: [RULES, e.g. trim spaces, standardize dates to YYYY-MM-DD, drop exact duplicates, flag blank emails]. Requirements: always write to a new file named [OUTPUT NAME], never overwrite the input, and print a before-and-after report: rows in, rows out, duplicates removed, and every changed row with the reason. Use only the standard library, handle a header row and quoted commas correctly, and end with 3 test cases, including one messy row, and clear run instructions.
Add Input Validation Without Breaking Existing Callers
Act as a senior engineer in [LANGUAGE] who protects existing callers. I will paste a function below. Add validation for [INPUTS TO CHECK, e.g. empty, out of range, wrong type] using the error style already in the code: [RAISE / RETURN NULL / ERROR OBJECT]. Rules: keep the function name, signature, and valid-input behavior unchanged, reject only what I list, and never silently change values. Output: (1) the updated code, (2) a table of each new check, the bad input it catches, and the error returned, and (3) 5 test cases - 2 valid, 3 invalid. Code: [PASTE FUNCTION]
Understand & Improve
Debug This Error
Act as a senior developer debugging with me. I’m getting this error: [PASTE FULL ERROR MESSAGE]. Context: [LANGUAGE/FRAMEWORK, e.g. Python 3.11 with Django], and here’s the relevant code: [PASTE CODE]. Do three things: 1) explain in plain language what the error means, 2) identify the most likely cause with the exact line or pattern to check, and 3) give me the fixed code with the change clearly marked. Then tell me how to avoid this class of error in the future. If you need more info, ask for the specific missing piece instead of guessing.
Explain Code Simply
Act as a patient programming teacher. Explain what this code does, line by line, assuming I know basic programming but not [LANGUAGE/CONCEPT]. For each significant line or block: what it does in plain English, and WHY it’s written that way (the reasoning, not just the mechanics). Flag any tricky, clever, or potentially buggy parts. End with a one-paragraph summary of the whole thing and one suggestion for making it clearer. Keep jargon minimal – define any term you must use. Code: [PASTE CODE]
Code Review Checklist
Act as a strict but fair code reviewer. Review the code below against this checklist: correctness (bugs, edge cases), readability (naming, structure), security (injection, auth, secrets), performance (obvious bottlenecks), and maintainability (duplication, testability). For each issue found: quote the problematic lines, explain why it’s a problem, rate severity (critical/major/minor), and show the fix. End with a verdict: approve, approve with changes, or needs rework. Don’t nitpick style – focus on things that actually matter. Code: [PASTE CODE] Language: [LANGUAGE]
Refactor for Readability
Act as a senior developer who values clean code. Refactor the code below to be more readable WITHOUT changing what it does. Improve: confusing names, long functions (split them), nested conditionals (flatten with early returns), and magic numbers (give them names). Keep the public interface identical. After the refactored code, list each change and why you made it, and flag anything whose behavior you could not verify – I will test those parts myself. Code: [PASTE CODE]
Find Performance Bottlenecks
Act as a performance engineer. Analyze this code for performance problems: [PASTE CODE]. Context: it processes [DATA SIZE, e.g. “100k records”] and currently takes [TIME IF KNOWN]. Find: nested loops, repeated work inside loops, N+1 queries, and memory hogs. For each issue: show the slow lines, explain WHY they are slow, and give the optimized version with the expected speedup. Rank the fixes by impact so I know what to do first. Do not sacrifice readability for a 1% gain.
Scan for Security Vulnerabilities
Act as an application security engineer. Audit this code for vulnerabilities: [PASTE CODE]. Check: injection (SQL, command, XSS), hardcoded secrets, broken auth, insecure randomness, unsafe deserialization, and missing input validation. For each finding: quote the vulnerable lines, explain how an attacker could exploit it in plain terms, rate severity, and show the fix. End with the top 3 things to fix before this code touches production. I am the code owner doing a self-audit.
Fix Silent Bugs (Wrong Output, No Error)
Act as a debugging expert. This code runs without errors but produces WRONG output: [PASTE CODE]. Expected: [WHAT SHOULD HAPPEN]. Actual: [WHAT HAPPENS INSTEAD]. Walk me through your reasoning: state your hypothesis about the cause, point to the exact lines, and explain the logic mistake in plain English. Then show the fixed code with the change highlighted. Finally, suggest one test I can add that would have caught this bug.
Learn a Programming Concept With Examples
Act as a programming teacher. Teach me [CONCEPT, e.g. “recursion” / “async/await” / “SQL JOINs”] in [LANGUAGE]. Start with a one-sentence plain-English definition, then show 3 examples: trivial, realistic, and tricky – each with code and a line-by-line explanation of what is happening. End with: the 2 most common mistakes beginners make with this concept, and a small exercise I can try myself (with the answer hidden until I attempt it). Assume I know [MY CURRENT LEVEL].
Compare Two Approaches
Act as a pragmatic senior developer. I need to [GOAL], and I am torn between these two approaches: [DESCRIBE A] vs [DESCRIBE B]. Compare them on: code complexity, performance at [SCALE], maintainability in 6 months, and failure modes. Give me a clear recommendation with the deciding factor, and the specific situation where you would pick the OTHER option instead. No fence-sitting – pick one and defend it.
Simplify Code Without Changing Behavior
Act as a code minimalist. Take this verbose code and make it shorter and clearer WITHOUT changing behavior: [PASTE CODE]. Use the language’s idioms (list comprehensions, destructuring, built-ins, early returns). Every simplification must be behavior-preserving – if you are unsure about an edge case, keep the original and flag it. After the simplified version, list what you removed and confirm the behavior is identical. Target: cut the line count significantly while improving clarity.
Get Better Variable and Function Names
Act as a naming expert. These names in my code are confusing: [PASTE CODE OR LIST NAMES WITH CONTEXT]. Suggest better names for each, following [LANGUAGE] conventions. For each rename: the new name, and one line on why it is clearer (what it reveals about purpose, type, or scope). Keep names pronounceable and searchable – no single letters except loop counters, no abbreviations a new hire would not know. Return the code with the new names applied.
Add Docstrings and Comments
Act as a technical writer who codes. Add documentation to this code: [PASTE CODE]. Write: a module/class docstring explaining purpose, function docstrings with parameters, return values, and one usage example each, plus inline comments ONLY where the WHY is non-obvious (never restate what the code says). Follow [LANGUAGE] doc conventions [e.g. Google style / JSDoc]. Skip documenting trivial getters – focus on what a new teammate would actually need.
Write a README From Existing Code
Act as a technical writer. Write a README.md for this project based on its code: [PASTE KEY FILES OR DESCRIBE STRUCTURE]. Include: what it does (one paragraph), prerequisites, installation steps, configuration (env vars), usage examples with real commands, and a troubleshooting section for the 3 most likely setup failures. Infer sensibly from the code but mark anything you guessed with [VERIFY]. Keep it scannable – headers, code blocks, no walls of text.
Write a Commit Message and PR Description
Act as a senior developer who writes great commit history. Based on this diff: [PASTE DIFF OR DESCRIBE CHANGES], write: 1) a commit message with a short imperative subject line (under 50 chars) plus a body explaining WHY the change was made, and 2) a pull request description with summary, what changed, how to test it, and any risks. Follow conventional-commits style. If the diff mixes unrelated changes, tell me to split it and suggest the split.
Break a Feature Into Build Steps
Act as a tech lead planning a sprint. Break this feature into buildable steps: [DESCRIBE FEATURE]. Output an ordered task list where each step: is small enough to finish in one sitting, ends in something testable, and lists its dependencies on earlier steps. Mark which steps are risky or unclear and suggest how to de-risk them first. End with what “done” looks like and the simplest version I could ship first (MVP).
Analyze Big-O Time Complexity
Act as a computer science tutor. Analyze the time (and space) complexity of this code: [PASTE CODE]. For each loop and recursive call, state its cost and WHY, then combine them into the final Big-O. Explain what the Big-O means in practical terms for input sizes of 100, 10k, and 1M. If there is a way to improve the complexity class (not just constants), show it. Keep the math minimal – focus on intuition I can reuse.
Spot Code Smells
Act as a refactoring coach. Scan this code for code smells: [PASTE CODE]. Check for: duplicated logic, functions doing too many things, deep nesting, primitive obsession, shotgun surgery, and dead code. For each smell: name it, quote the offending lines, explain why it will hurt later, and show the specific refactoring to fix it. Rank by which smell will cost me the most time if ignored. Do not rewrite the whole file – targeted fixes only.
Pick the Right Design Pattern
Act as a software architect. My problem: [DESCRIBE, e.g. “I need to support multiple payment providers with different APIs”]. Recommend the most fitting design pattern in [LANGUAGE]. Show: a minimal implementation of the pattern applied to MY problem, why it fits better than the 2 closest alternatives, and where this pattern becomes overkill (so I know when NOT to use it). Keep the example small enough to understand in 5 minutes.
Review a Database Schema
Act as a database architect. Review this schema: [PASTE SCHEMA]. Check: normalization, primary/foreign keys, indexing for my query patterns [DESCRIBE QUERIES], data types (right sizes), and missing constraints. For each issue: what is wrong, what breaks at scale, and the corrected definition. End with the 3 highest-impact changes and whether I need a migration strategy for existing data.
Improve an API’s Design
Act as an API design consultant. Review this API design: [PASTE ENDPOINTS OR DESCRIBE]. Evaluate: RESTfulness (verbs, plural nouns, proper status codes), consistency of naming and error formats, versioning strategy, and pagination/filtering conventions. For each problem: show the current design, the improved version, and why it is better for API consumers. End with a short style guide I can follow for future endpoints.
Explain a Git Diff in Plain English
Act as a patient senior developer. Explain this git diff in plain English: [PASTE DIFF]. For each hunk: what changed, and WHY it likely changed (the intent, not just the mechanics). Flag anything that looks risky, accidental (debug code left in?), or like it belongs in a separate commit. End with a one-paragraph summary I could paste into a standup update. Assume I understand basic git but not this codebase.
Write a Codebase Onboarding Guide
Act as a tech lead onboarding a new hire. Based on this codebase overview: [DESCRIBE STRUCTURE, KEY FILES, STACK], write an onboarding guide: the 5 files to read first (in order, with why), how data flows through the system, how to run it locally step by step, how to run the tests, and where the risky “here be dragons” parts are. End with a good first task for a new developer and how long setup should take.
Translate Technical Docs to Plain English
Act as a translator between engineers and everyone else. Rewrite this technical documentation in plain English for [AUDIENCE, e.g. “a non-technical manager”]: [PASTE DOCS]. Keep every important fact and warning – simplify the language, not the meaning. Replace jargon with everyday terms (define any you must keep), use short sentences, and add a “what this means for you” line per section. Flag anything in the original that was ambiguous even to you.
Check for Deprecated Code Before Upgrading
Act as an upgrade specialist. I am upgrading [LIBRARY/FRAMEWORK] from version [OLD] to [NEW]. Scan this code for deprecated or removed APIs: [PASTE CODE]. For each hit: the old API, its replacement in the new version, and the exact code change needed. Flag any breaking behavior changes that are NOT simple renames. End with an ordered upgrade checklist: what to change, what to test, and what to watch in production after deploy.
Harden Code Against Edge Cases
Act as a defensive programming coach. Take this code and make it bulletproof: [PASTE CODE]. Add handling for: null/undefined inputs, empty collections, unexpected types, extremely large inputs, and concurrent access if relevant. Do not change the happy-path behavior. For each guard you add, comment what disaster it prevents. End with a list of inputs I should test that would have crashed the original.
Improve Error Handling
Act as a reliability engineer. Review the error handling in this code: [PASTE CODE]. Fix: swallowed exceptions, generic catch-all blocks, missing validation at boundaries, and unhelpful error messages. Requirements: fail fast with specific errors, include context in messages (what failed, with what input), never leak sensitive data in errors, and distinguish retryable from fatal failures. Show before/after for each fix.
Add Logging That Actually Helps
Act as a SRE. Add logging to this code so I can debug production issues: [PASTE CODE]. Requirements: log at the right levels (ERROR for failures, WARN for degraded, INFO for key lifecycle events, DEBUG for details), include correlation IDs and relevant context in every message, never log secrets or PII, and keep log volume sane (no per-iteration spam in hot loops). Show the updated code and one example of how I would grep these logs to find a failed request.
Write a QA Test Plan
Act as a QA lead. Write a test plan for this feature: [DESCRIBE FEATURE AND HOW TO USE IT]. Cover: happy path, boundary values, invalid inputs, and the 5 most likely real-world failure scenarios. Format as a checklist table: step, expected result, pass/fail. Include one exploratory testing prompt (“try to break it by…”) per area. Prioritize the tests – mark which 20% would catch 80% of bugs so I can run a quick smoke pass.
Accessibility Audit for a Web Page
Act as a web accessibility auditor. Review this page’s code: [PASTE HTML/CSS]. Check it against WCAG 2.1 AA basics: missing or empty alt text, unlabeled form fields, color contrast problems, keyboard navigation traps, missing focus styles, heading hierarchy, and ARIA misuse. List every issue as: line or element, what fails, why it matters to a real user, and the exact code fix. Rank issues as critical, important, or nice-to-have. End with a 5-item checklist I can reuse on future pages. Flag anything you cannot verify from code alone (like actual contrast ratios) and tell me how to check it.
Turn Vague Bug Reports Into Reproducible Steps
Act as a senior QA engineer. Here is a vague bug report from a user: [PASTE REPORT]. The app is a [APP TYPE] built with [STACK]. Turn it into a professional, reproducible bug ticket with: 1) environment details to confirm, 2) numbered reproduction steps – if a step is missing from the report, write [ASSUMED – VERIFY] instead of inventing it, 3) expected vs actual behavior, 4) a severity rating with a one-line business-impact justification, 5) the three clarifying questions I should ask the reporter first, 6) the most likely code areas to check first and why. Keep the ticket under 250 words and jargon-light so a non-technical reporter can follow it.
Walk Through a SQL Query Line by Line
Act as a patient database tutor. I will paste a SQL query below and tell you what I think it should return: [EXPECTED RESULT]. Walk through it line by line: for each clause, say in plain English what it does, which rows survive that step, and any columns it creates, renames, or removes. Then flag anything that could surprise me: NULL handling, duplicate rows, joins that multiply rows, or filters applied after grouping. End with a tiny worked example: invent 5 sample rows, show the intermediate result after the two most important clauses, and the final output. Query: [PASTE SQL HERE].
Explain a Git Conflict and Resolve It Safely
Act as a patient Git mentor who never risks losing work. I hit a merge conflict in [FILE NAME] between branches [BRANCH A] and [BRANCH B]. I will paste the conflicted section below. First explain, in plain English, what each side was trying to change and where they overlap. Then show the resolved code, explain each choice in one line, and list the exact steps to mark it resolved and test it before committing. If both changes are needed, combine them instead of picking a winner. Never suggest force-pushing or deleting a branch to make the conflict go away. Conflict: [PASTE CONFLICT HERE].
Trace a Bug From Symptom to Root Cause
Act as a senior developer who debugs by evidence, not guesses. A bug appeared: [SYMPTOM AND WHEN IT STARTED]. What changed recently: [RECENT CHANGES, OR NONE KNOWN]. The code involved is: [PASTE CODE OR FILE NAMES]. Build a root-cause hunt: first, list 5 hypotheses ranked by likelihood, each with the cheapest check that would prove or rule it out; second, give me the exact logs, inputs, or values to collect for the top 2; third, once I paste those results back, narrow to one cause before suggesting any fix. Rules: change one variable at a time, never rewrite working code to fix a guess, and flag anything that risks data loss.
Translate a Stack Trace for a Non-Technical Stakeholder
Act as a senior developer who explains incidents plainly without hiding the truth. This error happened in [APP OR FEATURE] when [WHAT THE USER WAS DOING]: [PASTE STACK TRACE - REMOVE SECRETS, KEYS, AND PERSONAL DATA FIRST]. Write two versions. First, for a non-technical stakeholder in under 120 words: what broke in plain English, who is affected, whether data was lost based only on the trace, and what happens next. Second, for me: the exact file and line to inspect first, what that frame means, and the 3 most likely causes ranked, each with one check. Never invent a cause the trace does not support; say what is still unknown.
Make a One-Off Script Safe to Run Twice
Act as a careful senior developer reviewing a script I only meant to run once. I will paste a script in [LANGUAGE] that [WHAT IT DOES, e.g. renames files or updates rows]. Make it safe to run twice: (1) point out every step that would duplicate, overwrite, or corrupt data on a second run, (2) rewrite it with a dry-run mode that prints planned changes first, clear logging, and a stop if inputs look wrong, and (3) add a short pre-run checklist. Constraints: keep the original logic and style, change nothing unrelated, and explain each safety change in one line. Code: [PASTE SCRIPT HERE].
Map Legacy Code Before You Change It
Act as a senior developer who makes unfamiliar code safe to change. I need to change [FEATURE OR BEHAVIOR] in code I did not write, pasted below in [LANGUAGE / FRAMEWORK]. Before proposing any edit: (1) map what this code does, what calls it, and what it depends on, (2) flag side effects, shared state, and assumptions that could break, and (3) list the smallest safe change plan with tests to run before and after. Output: a one-paragraph summary, a risk table, and a step-by-step change plan. Constraints: propose no rewrite yet, invent no functions I did not show you, and mark anything you cannot tell from the code as unknown. Code: [PASTE CODE HERE].
Build a Minimal Reproduction Case From a Bug Report
Act as a senior debugger who isolates faults before fixing them. I have a bug in [LANGUAGE / FRAMEWORK] where [EXPECTED BEHAVIOR] but instead [ACTUAL BEHAVIOR]. Relevant code: [PASTE SMALLEST RELEVANT SNIPPET]. Build a minimal reproduction: strip the code to the smallest runnable example that still triggers the bug, remove unrelated setup, and replace real data with fake values. Output: (1) the minimal example in one code block, (2) the exact steps and input to run it, (3) what output proves the bug, and (4) one line on what you removed and why. Never invent a fix yet, and never include real credentials or user data.
Add Retry Logic That Retries Safely and Fails Clearly
Act as a senior backend engineer in [LANGUAGE] who makes integrations resilient without hiding failures. My code calls [SERVICE OR API] and fails intermittently with [ERRORS YOU SEE, e.g. timeouts or 503s]. The operation is [SAFE TO REPEAT / NOT SAFE TO REPEAT] and the current code is: [PASTE CODE]. Add retry logic that: (1) retries only transient errors, never validation or auth errors, (2) uses capped backoff with a maximum of [MAX ATTEMPTS] attempts, and (3) logs each attempt. Output: the revised code, a table of retry vs no-retry errors, and the final error message a user or on-call engineer will see. Change nothing else in the function signature.
