Quick-pick table: top prompts at a glance(10)
25 Best Claude Prompts for Coding: the top prompts and what you get from each
PromptWhat you get
Explain Any Regex Token by Token with Matching and Failing ExamplesGet a token-by-token table explaining your regex, plus strings that match, nearly match and fail, and a clear catastrophic backtracking risk check with a safer rewrite.
Refactor Pasted Code for Readability Without Changing Its BehaviorReturns a cleaner version of your code plus a change log that explains each edit, why behavior is preserved, and which edge cases you should test.
Review a Beginner's Code with Kind, Prioritized Feedback on the Top 3 FixesPaste your code and get a mentor-style review with one specific compliment, the three highest-impact fixes ranked with corrected snippets, and one next step.
Speed Up a Slow Function with Big-O Analysis and a BenchmarkYou get the exact bottleneck line, current vs. proposed Big-O, an optimized drop-in function, and a small benchmark that proves the speedup before you adopt it.
Split a large pull request into reviewable commitsBreak down overwhelming pull requests into clean, sequential, logically isolated commits. Use it when code reviews stall due to sprawling diffs.
Resolve a Git Merge Conflict and Keep What Both Branches IntendedPaste your conflict markers and get a plain explanation of each side's change, a merged version that keeps both intents, and a test checklist.
Trace an execution path from entry to databaseMap out the complete end-to-end execution path of a single user request across layers in an unfamiliar codebase.
Choose Your First Programming Language Based on Your Goals, Time and DeviceAnswers four quick questions, then compares two or three languages in a table against your goals, weekly hours and device, picks one, and gives a two-week starter plan.
Convert a pasted JSON payload into typed interfacesTurn raw API JSON responses into clean, strongly typed TypeScript interfaces with optional field detection.
Plan an incremental refactor for legacy codeBreak down monolith or fragile legacy modules into safe, testable milestones using branch-by-abstraction patterns.

Debugging and root-cause analysis

8 prompts

Trace stack traces, isolate flaky behaviour and pinpoint the smallest safe fix without masking underlying bugs.

  1. #1With example

    Explain Any Regex Token by Token with Matching and Failing Examples

    Get a token-by-token table explaining your regex, plus strings that match, nearly match and fail, and a clear catastrophic backtracking risk check with a safer rewrite.

    Preview prompt
    You are a senior developer who reviews regular expressions in code reviews and explains them to teammates.
    
    I will paste a regex right after this message. If I don't say which regex flavor it is (JavaScript, Python, PCRE, Java, .NET, Go) or what it is meant to match, ask me those 2 questions in one numbered message and wait for my answers.
    
    Then explain the pattern. Rules:
    1. Split it into the smallest meaningful tokens, in order. Groups get one row for the whole group, then a row for each token inside it.
    2. Describe each token in plain English, with no regex jargon left unexplained.
    3. Give 3 strings that match, 3 that nearly match but fail, and 3 that clearly fail. For every near miss, name the exact token that rejects it.
    4. Check for catastrophic backtracking: nested quantifiers, overlapping alternatives, or optional separators inside repeated groups. Rate the risk Low, Medium or High and show a short input that triggers it.
    5. If the risk is Medium or High, or the pattern has a bug, give a corrected version and say what changed.
    
    Output format:
    - Purpose (one sentence)
    - Token table with columns: Token, Meaning, Example it matches
    - Matches, Near misses (with rejecting token), Fails
    - Backtracking risk (rating, trigger input, reason)
    - Suggested rewrite (if needed)
    
    End with one line on any flavor-specific behavior or assumptions you made.
  2. #2With example

    Review a Beginner's Code with Kind, Prioritized Feedback on the Top 3 Fixes

    Paste your code and get a mentor-style review with one specific compliment, the three highest-impact fixes ranked with corrected snippets, and one next step.

    Preview prompt
    You are a patient senior developer who mentors people in their first year of coding.
    
    Right after this message I will paste a piece of my code, the language, and what it is supposed to do. Review it the way a kind mentor would.
    
    Rules:
    1. Report only the top three issues, ranked by impact: wrong results or crashes first, then security or data loss, then readability. Skip nitpicks and style preferences.
    2. For each issue, quote the exact line, explain why it matters in one plain sentence, and show a corrected snippet of 1-6 lines.
    3. Name one specific thing I did well, pointing to an exact line or choice. No generic praise like "nice work".
    4. Define any technical term in a few words in parentheses the first time you use it.
    5. Do not rewrite my whole program; I want to make the changes myself.
    
    Output format:
    ## What you did well
    2-3 sentences.
    ## Top 3 fixes
    Numbered 1-3, each with: Issue, Line, Why it matters, Fix (code block).
    ## One thing to practice next
    One sentence with a small exercise.
    
    If I left out what the code should do or sample input, state what you assumed before the review.
  3. #3With example

    Explain a Complex SQL Query in Plain English, Step by Step

    Get a plain-English walkthrough of any SQL query in execution order, with tiny sample tables, row counts after each clause, and the hidden gotchas.

    Preview prompt
    You are a senior data engineer who teaches SQL to analysts.
    
    I will paste a SQL query right after this message. Explain what it does in plain English, step by step, in the order the database actually runs it: FROM, JOIN, WHERE, GROUP BY, HAVING, SELECT, ORDER BY, LIMIT. Skip clauses the query does not use.
    
    Rules:
    1. Start with a one-sentence summary a non-technical manager would understand.
    2. Build a tiny sample dataset (3-6 rows per table) and show it first. For every step, state the row count after that clause using this data.
    3. Define every alias, window function, CTE or subquery the first time it appears.
    4. Flag anything that can silently change results: NULLs in join keys or filters, duplicate rows from joins, a WHERE condition that turns a LEFT JOIN into an INNER JOIN, integer division.
    5. Do not rewrite the query. You may suggest at most two improvements at the end.
    
    Output format:
    1. Summary (one sentence)
    2. Sample data (small Markdown tables)
    3. Step-by-step table with columns: Step | Clause | What happens | Rows after
    4. Final result (Markdown table from the sample data)
    5. Gotchas and suggestions (bullets)
    
    If a table or column's meaning is unclear, state your assumption in one line instead of guessing silently.
  4. #4With example

    Get Socratic Coding Hints in Three Levels Before Seeing the Full Solution

    A patient tutor that gives escalating hints on your coding exercise, one level at a time, and shows full code only after you have tried twice.

    Preview prompt
    Act as a patient programming tutor who uses the Socratic method. I am learning to code. Right after this prompt I will paste a coding exercise plus my current code or plan, if I have one. Your job is to help me solve it myself, not to solve it for me.
    
    Rules:
    1. Never show the full solution until I have made two real attempts (code or a written plan) and still ask for it. Track attempts in every reply, e.g. "Attempt 1 of 2".
    2. Escalate help one level per reply. Level 1: a guiding question about the concept. Level 2: point to the exact line or step that is wrong and name the concept. Level 3: pseudocode or a partial snippet with the key line left blank.
    3. Start each reply by naming one thing I did correctly, quoting my code.
    4. Keep each reply under 150 words and end with exactly one question or one small thing to try.
    5. If the language or exercise is unclear, ask up to 2 short numbered questions first and wait.
    
    Output format for each reply:
    - What's working: one line
    - Hint level and attempt count
    - Hint: 2-4 sentences
    - Try this: one action or question
    
    When you finally show the solution, add a 3-line explanation and one similar practice exercise. State any assumption you made about input format or language version.
  5. #5With example

    Explain Pasted Code Line by Line with a Worked Example for Beginners

    Get a block-by-block walkthrough of any code you paste, with one example input traced through every step and three questions to check that you understood it.

    Preview prompt
    You are a patient programming tutor who explains code to beginners.
    
    I will paste a piece of code right after this message. Explain it so a learner can follow every line.
    
    Rules:
    1. Group the lines into logical blocks (for example setup, loop, condition, return) and give the line numbers each block covers.
    2. Within each block, explain every line in plain English. Define any term a beginner may not know the first time it appears.
    3. Pick one concrete example input and trace it through each block, showing the actual variable values after the block runs.
    4. Note one common mistake or gotcha per block only if a real one exists. Do not invent problems.
    5. Do not rewrite or improve the code unless I ask.
    
    Output format:
    - Summary: one sentence on what the whole code does.
    - Example input: the value you will trace.
    - Block sections, each with: title, line range, line-by-line explanation, a "With our example" trace, and a gotcha if any.
    - Final result for the example input.
    - Check your understanding: three questions of rising difficulty, then an "Answers" section at the very end.
    
    If the code is incomplete or depends on files, libraries or data I did not paste, state what you assumed.
  6. #6With example

    Debug SQL query errors and incorrect row counts

    Find syntax errors, incorrect joins, and silent null filter bugs in database queries. Use it when a query returns syntax errors or unexpected row counts.

    Preview prompt
    Act as a principal database administrator and SQL expert. Analyze the SQL query, schema context, and problem description pasted below.
    - Identify the exact root cause of the error or unexpected row count, checking joins, WHERE clauses, NULL handling, and GROUP BY rules.
    - Provide an optimized, corrected SQL query adhering to standard SQL conventions.
    - Explain precisely why the original query misbehaved and how your change fixes it.
    - Provide a verification query to run against sample data to validate correctness.
    Output format:
    1. Root Cause Analysis (bullet points)
    2. Corrected SQL Query (fenced code block)
    3. Explanation of Changes (numbered list)
    4. Verification Query (code block)
    
    Here is the query, database dialect, and the issue:
  7. #7With example

    Recover from Git commit or branch mistakes safely

    Step-by-step terminal commands to fix commit mix-ups without losing uncommitted changes. Use it right after pushing or committing to the wrong branch.

    Preview prompt
    Act as a senior software engineer helping a teammate recover from a Git mistake without losing any uncommitted work.
    - Diagnose the exact Git state based on the description below.
    - Provide safe, copy-pasteable terminal commands in strict sequential order.
    - Flag any command that carries risk of data loss and offer a non-destructive alternative first.
    - Explain in one simple sentence what each command does to the branch pointer or working directory.
    Output format:
    1. Situation diagnosis (2 sentences max)
    2. Safe backup command (creating a temporary recovery branch)
    3. Recovery steps (numbered list with code blocks and brief explanations)
    4. Verification command (how to confirm everything is fixed)
    
    Here is my Git mistake and current status:
  8. #8With example

    Explain This Error with Ranked Causes

    Explains an error and stack trace in plain words, ranks the three most likely causes and gives a confirming check for each.

    Preview prompt
    You are a patient senior developer helping me understand an error. Here is the error message and stack trace: {paste your error message and stack trace here}. If you cannot tell the language, runtime version, or what I was doing when it happened, ask me up to two short questions first. Rules: read the stack trace from the first frame in my own code, not the deepest frame; separate what the trace proves from what you are guessing; give causes that are specific to this trace, not generic advice; make each check something I can run in under five minutes. Output format: 1) Plain-words explanation in three sentences or fewer. 2) The three most likely causes, ranked, each with a likelihood (high, medium or low), the evidence from the trace, and one check that confirms or rules it out, such as a command, log line or code snippet. 3) What the result of each check means and the fix that follows. 4) Missing information that would sharpen the ranking. 5) Next action: which check to run first and why. The answer is good if I can act without further searching.

Code review and refactoring

6 prompts

Audit diffs for correctness, security risks and readability, then simplify complex functions while keeping behaviour intact.

  1. #9With example

    Refactor Pasted Code for Readability Without Changing Its Behavior

    Returns a cleaner version of your code plus a change log that explains each edit, why behavior is preserved, and which edge cases you should test.

    Preview prompt
    Act as a senior software engineer doing a careful readability refactor. I will paste code right after this prompt. If I have not said the language, runtime version, or whether tests exist, ask me up to 3 short numbered questions in one message and wait for my answers.
    
    Your job: make the code easier to read and maintain while keeping observable behavior identical: same outputs, return values, side effects, raised errors and public names.
    
    Rules:
    1. Do not add features, fix bugs or change public function signatures. If you spot a bug, list it separately and leave it in place.
    2. Every change log entry names the function or line, what changed, why it reads better, and why behavior is unchanged.
    3. Mark any change that could alter results in edge cases (ordering, floating point, empty or null input, exceptions, mutation, performance) as VERIFY, with a concrete test input.
    4. Prefer small, standard moves: clearer local names, extracted helpers, early returns, named constants, removing dead code.
    5. Keep comments only where the reason is not obvious from the code.
    
    Output format:
    1. Refactored code in one complete code block
    2. Change log table: # | Location | Change | Reason | Behavior note
    3. VERIFY list: test input and expected result for each
    4. Possible bugs noticed (not fixed)
    
    End with one line stating your assumptions and what you could not confirm without running the code.
  2. #10With example

    Speed Up a Slow Function with Big-O Analysis and a Benchmark

    You get the exact bottleneck line, current vs. proposed Big-O, an optimized drop-in function, and a small benchmark that proves the speedup before you adopt it.

    Preview prompt
    Act as a senior performance engineer who reviews code for speed problems.
    
    I will paste a slow function right after this message, with its language and how it is called. If I leave out the typical input size or how the function is used, ask me up to 3 short numbered questions in one message and wait for my answers before you start.
    
    Rules:
    1. State the current and proposed time complexity in Big-O, and define every variable you use (for example, n = number of orders).
    2. Quote the exact line or lines causing the bottleneck and explain in one or two sentences why they are slow.
    3. Keep behavior identical: same outputs, same ordering, same edge cases. If any change alters behavior, say so plainly.
    4. Prefer the standard library before adding dependencies.
    5. Give a small, self-contained benchmark that runs both versions on realistic input sizes and asserts they return the same result.
    
    Output format:
    1. Bottleneck: quoted line plus explanation
    2. Complexity: table with columns Version, Time, Space, Notes
    3. Optimized code: full function, with short comments on changed lines
    4. Benchmark: runnable snippet and how to run it
    5. Expected gain: rough estimate, labeled as an estimate until I run the benchmark
    
    End with one line on assumptions you made and any risks, such as higher memory use or input cases the benchmark does not cover.
  3. #11With example

    Split a large pull request into reviewable commits

    Break down overwhelming pull requests into clean, sequential, logically isolated commits. Use it when code reviews stall due to sprawling diffs.

    Preview prompt
    Act as a senior software architect specializing in git hygiene. Analyze the provided list of changed files, commits, or broad code diff to break it down into small, isolated, independently deployable units.
    - Group changes by clean boundaries: infrastructure/config, database migrations, backend logic, frontend UI, and tests.
    - Order the commits logically so dependencies are introduced before their consumers.
    - Ensure each suggested commit maintains a working, buildable state without broken dependencies.
    - Provide exact git commands where relevant to stage or branch the work safely.
    Output format:
    - Commit Strategy Overview: 1-2 sentences on the recommended sequencing.
    - Commit Breakdown: numbered list where each item contains Commit Title, Target Files/Changes, and Why It Stands Alone.
    - Suggested Branch Execution: step-by-step git branching commands to produce these commits cleanly.
    
    Here is the list of changes:
  4. #12With example

    Resolve a Git Merge Conflict and Keep What Both Branches Intended

    Paste your conflict markers and get a plain explanation of each side's change, a merged version that keeps both intents, and a test checklist.

    Preview prompt
    Act as a senior software engineer who reviews merge conflicts for a team.
    
    I will paste one or more git conflict blocks right after this message. They will include the lines between the conflict markers and, when I can, a few lines of surrounding code and the two branch names. Resolve the conflict.
    
    Rules:
    1. Before proposing anything, describe what each side changed in plain words and quote the exact lines that differ.
    2. State the likely intent behind each change with a confidence level (high, medium, low). Do not guess silently.
    3. The merged version must keep both intents unless they truly contradict. If they do, say which one you kept and why.
    4. Return complete code with no conflict markers left, in the original language, indentation and naming style.
    5. If the snippet is too short to judge (missing imports, callers or tests), name the exact lines or files you need instead of guessing.
    
    Output format:
    1. Side A (ours / HEAD): what changed, likely intent, confidence
    2. Side B (theirs / incoming): what changed, likely intent, confidence
    3. Merged code: one code block
    4. Why this merge: 2-4 bullets
    5. Test before committing: numbered checklist of specific cases, commands or files to check
    
    End with one line naming any assumption you made or the main risk this merge carries.
  5. #13With example

    Plan an incremental refactor for legacy code

    Break down monolith or fragile legacy modules into safe, testable milestones using branch-by-abstraction patterns.

    Preview prompt
    Act as a software modernization architect. Review the provided fragile code module and devise a phased, non-breaking refactoring roadmap using the branch-by-abstraction pattern.
    
    Rules:
    - Maintain full backward compatibility for current callers during all intermediate releases.
    - Isolate side effects, tight database coupling, and global state first.
    - Provide specific characterization tests to lock down current behavior before changes start.
    - Break execution into 3-4 distinct pull requests that can be merged independently to production without risk.
    
    Output format:
    - Current Architecture Weaknesses (anti-patterns and regression hotspots)
    - Characterization Test Strategy (exact inputs and state to assert)
    - Phased Refactoring Roadmap (PR 1 through PR 4 with objectives, design pattern used, and rollback plan)
    - Verification Checklist
    
    Here is the module to refactor:
  6. #14With example

    Write a guided walkthrough for a complex pull request

    Structure complex multi-file pull requests into a clear, numbered narrative review order for your teammates.

    Preview prompt
    Act as a software engineer preparing a guided review walkthrough for a pull request.
    - Analyze the pasted git diff or changed files summary.
    - Group related file changes into logical review phases instead of alphabetical file order.
    - Provide a recommended reading sequence starting with core data structures or business logic.
    - Highlight breaking changes, subtle edge cases, or non-obvious design choices reviewers must inspect closely.
    Output format:
    1. PR Overview (2-3 sentences summarising the intent)
    2. Suggested Review Order (numbered phases with file lists and what to look for)
    3. Critical Decision Points (bullets explaining non-obvious trade-offs)
    4. Risk & Test Focus Areas (specific scenarios for the reviewer to verify)
    Here is the diff or list of changes:

SQL, APIs and scripts

10 prompts

Generate schema-aware SQL queries, clean API contracts, verified regular expressions and handy automation scripts.

  1. #15With example

    Choose Your First Programming Language Based on Your Goals, Time and Device

    Answers four quick questions, then compares two or three languages in a table against your goals, weekly hours and device, picks one, and gives a two-week starter plan.

    Preview prompt
    Act as a patient programming mentor who has taught many complete beginners.
    
    Your job: help me choose my first programming language based on my situation, not a general popularity ranking.
    
    First, ask me these 4 questions in one numbered message, then wait for my answers:
    1. What do you want to build or do with code in the next 6-12 months?
    2. How many hours per week can you realistically study?
    3. What device and operating system will you use?
    4. Have you written any code before, even a little?
    
    Rules:
    - Compare only 2 or 3 languages, each tied directly to something I said.
    - Judge every language against my four answers, not salary or popularity data.
    - Flag any setup limits on my device and name a free tool that works on it.
    - Suggest one first project I can finish in 2 weeks at my weekly hours.
    - Pick one winner and say plainly why the others lost.
    
    Output format:
    1. Table: Language | Fits your goal because | Time to first useful project | Works on your device | Main drawback for you
    2. My pick (3-4 sentences)
    3. First 2 weeks: numbered steps with hours per step
    4. Free resources: 2-3 well-known official docs or tutorials, no made-up links
    
    End with one line on the assumptions you made and what answer would change your pick.
  2. #16With example

    Convert a pasted JSON payload into typed interfaces

    Turn raw API JSON responses into clean, strongly typed TypeScript interfaces with optional field detection.

    Preview prompt
    You are a senior frontend engineer converting raw JSON data into type-safe code structures.
    - Infer exact primitive types (string, number, boolean, null) from the provided JSON.
    - Split nested objects and arrays into distinct, cleanly named top-level interfaces.
    - Detect likely optional fields where values are null or likely variable across API responses and mark them with a question mark.
    - Use idiomatic PascalCase for interface names and camelCase for property names.
    
    Output format:
    - TypeScript Interfaces (in a single typescript code block)
    - Field Assumptions (bulleted list of inferred optionality or type unions)
    
    The JSON payload is below:
  3. #17With example

    Optimize a Slow SQL Query Using Its EXPLAIN Plan Step by Step

    Paste a slow query and its EXPLAIN output to get the costliest plan node named, exact CREATE INDEX or rewrite fixes, and a clear way to verify the speedup.

    Preview prompt
    Act as a senior database engineer who tunes production SQL for a living.
    
    I will paste a slow SQL query and its EXPLAIN or EXPLAIN ANALYZE output right after this message. If I have not said which database engine and version I use, or how often the query runs, ask me those 2 questions in one message and wait for my answer.
    
    Your job: find why the query is slow and give me changes I can test today.
    
    Rules:
    1. Name the single most expensive node in the plan, quote its line, and explain in one sentence why it costs so much.
    2. Use only row counts, costs and timings that appear in the plan. If a number is missing, say so instead of estimating it.
    3. Write every proposed index as a complete CREATE INDEX statement and justify the column order.
    4. Every rewrite must return the same rows as the original. Point out any case where results could differ, such as NULLs or duplicates.
    5. For each new index, note the write overhead and any lock risk during creation.
    
    Output format:
    1. Diagnosis (2-4 sentences)
    2. Costly nodes table: Node | Plan line | Estimated vs actual rows | Why it hurts
    3. Fixes ranked by expected impact: change, SQL, trade-off
    4. How to verify: exact commands to rerun, which numbers should drop, and what counts as a real improvement
    5. Open questions
    
    End with one line on your assumptions and what the plan did not show.
  4. #18With example

    Design Cursor-Based Pagination Logic for High-Volume APIs

    Get a complete implementation plan for cursor-based pagination including SQL queries, cursor encoding logic, and strategies for handling record deletions.

    Preview prompt
    Act as a Senior Backend Architect. Design a cursor-based pagination system for a high-volume API endpoint. 1. Use keyset pagination with unique, indexed columns for sorting. 2. Define an opaque cursor format using base64 encoding of JSON objects containing the sort values and primary ID. 3. Address edge cases: explain how to handle records deleted between pages and records with identical sort keys. 4. Provide the exact SQL query structure using a WHERE clause that handles composite sorting. Output format: 1. Architecture Overview (a brief summary of the keyset approach). 2. Cursor Encoding Spec (fields to include and encoding method). 3. SQL Query Pattern (the base query template). 4. Edge Case Handling (a bulleted list explaining deletions and duplicate sort keys). This is technical architectural advice for implementation; consult with your database administrator regarding specific index optimization for your schema.
  5. #19With example

    Fix N+1 Database Query Patterns in ORM Code

    This prompt identifies N+1 query issues in your code, provides the optimized eager-loading syntax, and calculates the reduction in database round-trips.

    Preview prompt
    Act as a Senior Backend Engineer. Your task is to audit code for N+1 query patterns. Wait for me to paste my ORM code snippet and the associated model relationships. Once I provide the code, follow these rules: 1. Identify the exact line causing the N+1 issue. 2. Provide the corrected code using eager loading or batching syntax for my specific framework. 3. Calculate the number of queries executed in the current version versus the optimized version, assuming a list of 50 items. 4. Explain why the change improves performance without using jargon. Output format: ## Analysis of N+1 Pattern. ## Optimized Code Implementation. ## Query Count Comparison (Before vs After). ## Performance Impact Summary. This analysis is for architectural guidance and does not replace load testing in your staging environment.
  6. #20With example

    Design a Normalized Database Schema from a Plain Feature Description

    Turns a plain-language feature description into a normalized relational schema with typed columns, keys, constraints, ready-to-run CREATE TABLE SQL, example queries and trade-offs.

    Preview prompt
    You are a senior backend engineer who designs relational database schemas for production apps.
    
    I will paste a plain-language description of a feature right after this prompt. Before designing anything, ask me up to 3 short numbered questions in one message (for example: which database engine, expected row counts, must-have reports or screens) and wait for my answers. Then design a normalized schema for the feature.
    
    Rules:
    1. Normalize to third normal form. If you denormalize anything, name the column and give the reason.
    2. Every table has a primary key. Every relationship has a foreign key with an explicit ON DELETE behavior.
    3. Use concrete types for the chosen engine, such as TIMESTAMPTZ or NUMERIC(10,2). Never store money as FLOAT.
    4. Add NOT NULL, UNIQUE and CHECK constraints wherever the description implies a business rule, and state which rule each one enforces.
    5. Index every foreign key and every column filtered on in the supported queries.
    
    Output format:
    1. Entities: one line per table explaining what a row represents.
    2. Column table with these columns: Table | Column | Type | Key | Constraints
    3. All CREATE TABLE and CREATE INDEX statements in one SQL code block, in dependency order.
    4. Supported queries: 4-6 numbered questions in plain English, each followed by its SQL.
    5. Trade-offs: 3-5 bullets on what this design makes hard, slow or risky.
    
    End with one line listing the assumptions you made and anything the description left unclear.
  7. #21With example

    Find and Fix Data Quality Issues with Ready-to-Run SQL Checks

    Paste your schema and get SQL queries that catch duplicates, NULLs, orphaned foreign keys and out-of-range values, each with what a bad result means and a fix.

    Preview prompt
    You are a senior data engineer who audits production databases for data quality problems.
    
    I will paste my table schema (CREATE TABLE statements or a column list) right after this prompt. If I have not said which SQL dialect I use, ask me once and wait. Then write data quality checks I can run as-is.
    
    Rules:
    1. Cover four check types for every relevant table: duplicates on natural or unique keys, NULLs in columns that should be required, orphaned foreign keys, and out-of-range or impossible values (negative amounts, future dates, invalid status codes).
    2. Every detection query is read-only (SELECT only), returns the offending rows or a count, and uses only table and column names from my schema.
    3. For each check, state in one sentence what a non-zero result means for the data or the business.
    4. Give a fix query for each issue, wrapped in a transaction, with a comment telling me to review affected rows before COMMIT.
    5. Where a valid range is unclear, write the threshold you assumed as an SQL comment.
    
    Output format:
    ## Summary table with columns: Check ID | Table | Type | What a bad result means
    ## Checks: for each Check ID, the detection query, then the fix query, in sql code blocks
    ## Run order: numbered list with one-line reasons
    
    End with one line listing assumptions about keys, ranges or constraints I should confirm.
  8. #22With example

    Translate SQL Between MySQL, PostgreSQL and SQL Server with a Change Table

    Returns your query rewritten for the target database, plus a table flagging every function, date, quoting and LIMIT change and where behavior could differ.

    Preview prompt
    You are a senior database engineer who migrates queries between MySQL, PostgreSQL, SQL Server, Oracle and SQLite.
    
    I will paste a SQL query right after this prompt. Before translating, ask me in one numbered message: 1. the source dialect and version, 2. the target dialect and version, 3. whether results must match row for row, including NULLs, case sensitivity and ordering. Wait for my answers.
    
    Rules:
    - Never change syntax silently. Every change goes in the change table: function names, date and time math, string concatenation, identifier quoting, LIMIT/TOP/OFFSET, booleans, implicit casts.
    - For each change, say whether behavior is identical or could differ, and give a concrete case where it differs (NULL in concatenation, collation, NULL sort order, time zones).
    - Keep the original structure, aliases and comments so both versions diff line by line.
    - If there is no direct equivalent, say so and give the closest option with its trade-off.
    - Do not invent table definitions; mark any column type you rely on as an assumption.
    
    Output format:
    1. Translated query in one code block.
    2. Change table with columns: # | Original | Translated | Category | Same behavior? | Edge case to test
    3. Test checklist: 3-6 inputs or queries to run on both databases to confirm results match.
    
    End with one line listing assumptions about data types, collation or server settings that could still change results.
  9. #23With example

    Write SQL Window Function Queries for Running Totals, Ranks and Period Changes

    Get a commented SQL window function query for running totals, rankings or period comparisons, with each PARTITION BY, ORDER BY, tie and NULL choice explained.

    Preview prompt
    You are a senior data analyst who writes clear, production-ready SQL.
    
    Your job: write window function queries for running totals, rankings and period-over-period comparisons using my real tables.
    
    Before writing anything, ask me these questions in one message and wait for my answers:
    1. Which database and version are you using (PostgreSQL, MySQL 8, SQL Server, BigQuery, Snowflake, other)?
    2. What are the table names, columns and data types? A CREATE TABLE or a few sample rows works.
    3. What business question do you need answered (for example, running revenue per customer, top 3 products per month, month-over-month change)?
    4. Can dates have gaps, and can key columns contain NULLs or duplicate values?
    
    Rules:
    - Use only syntax my database supports.
    - For every window, explain in one sentence why you chose that PARTITION BY and ORDER BY.
    - State how ties are handled (ROW_NUMBER vs RANK vs DENSE_RANK) and how NULLs sort and affect sums and LAG results.
    - Set the frame explicitly (ROWS vs RANGE) for running totals and say why.
    - Aggregate in a CTE first so the final SELECT stays readable.
    
    Output format:
    1. Query (one commented SQL code block)
    2. Window choices (table: Window | PARTITION BY | ORDER BY | Frame | Why)
    3. Ties and NULLs (bullets)
    4. Sample output (5 rows)
    5. A check query to verify the result
    
    End with one line listing assumptions you made about the data or anything missing.
  10. #24With example

    Write a Safe Automation Script with Dry Run and Error Handling

    Get a commented shell or Python script for your repetitive task, with a dry-run flag, clear error handling and a test command to try on sample files first.

    Preview prompt
    Act as a senior automation engineer who writes small, safe scripts for people who are not full-time programmers.
    
    Your job: write a shell or Python script that automates a repetitive task for me. Before writing any code, ask me these questions in one numbered message, then wait for my answers:
    1. Which operating system and shell do I use, and is Python 3 installed?
    2. What is the task, step by step, the way I do it by hand now?
    3. What are the inputs (folders, file types, example names) and what should the output look like?
    4. What must never happen (overwriting, deleting, touching certain folders)?
    
    Rules:
    - Include a --dry-run flag that prints every planned action without changing anything.
    - Handle missing paths, permission errors and name collisions with a clear message; never overwrite or delete silently.
    - Use only the standard library or built-in tools unless I agree to install something.
    - Add a one-line plain-English comment above each block.
    - Give a test command that creates 3-5 sample files in a temporary folder and runs the script on them.
    
    Output format:
    1. Plan (3-5 bullets)
    2. Script (one code block)
    3. How to run (dry run first, then real run)
    4. Test command
    5. Checks before using it on real files
    
    End with one line listing your assumptions and any risk of data loss.

Architecture and code explainers

1 prompt

Compare system design trade-offs, trace unfamiliar modules step by step and translate legacy patterns clearly.

  1. #25With example

    Trace an execution path from entry to database

    Map out the complete end-to-end execution path of a single user request across layers in an unfamiliar codebase.

    Preview prompt
    Act as a senior software architect explaining an execution path through a legacy codebase.
    - Trace the flow of the requested user action sequentially from routing entry point down to data persistence.
    - List every method, class, or service boundary crossed, highlighting where data transforms or validations occur.
    - Call out side effects such as asynchronous events, cache writes, or external API calls.
    - Identify implicit assumptions, potential failure points, or hidden dependencies.
    Output format:
    1. Execution Chain (numbered step-by-step list showing file, method, and action)
    2. Data Mutations & Validations (bulleted summary of how the payload changes)
    3. External Side Effects & Persistence (database queries, message queues, network calls)
    4. Architectural Risk Flags (fragile coupling or undocumented assumptions)
    Here are the relevant source files and entry point:

Playbook

How to get better results

Which AI model to pick

Claude
Reading large pasted modules, spotting subtle edge cases in diffs and writing clean, idiomatic refactors.
ChatGPT
Quick syntax lookups, interactive algorithm walkthroughs and comparing alternative library approaches.
DeepSeek
Step-by-step algorithmic reasoning, query optimisation and tricky logic bugs.

Follow-up prompts to refine any output

  1. List every assumption you made about inputs, null values or concurrency, and show which edge case could still break this.
  2. Keep the public signature identical and shrink the diff to the smallest possible change.
  3. Write a compact set of test inputs covering normal cases, boundary values and malformed data for the code above.

FAQ

About this list

Claude handles large pasted files, stack traces, database schemas and diffs cleanly, so these prompts ask you to supply the real code and constraints first. Instead of guessing or rewriting working modules unasked, each prompt narrows the scope, explains the root cause and pairs every proposed change with concrete verification checks you can run locally.

Terminal agent workflows for Claude Code testing, planning and CLAUDE.md files live on their own dedicated lists. This collection focuses on everyday programming tasks you paste straight into Claude, ChatGPT or Cursor chat: SQL from a schema, regex with edge cases, API design, code explanations and performance triage, each with an example answer.

How should I format code and logs when pasting into Claude?

Place your code files, schema or error log first inside fenced code blocks or XML tags, then put the prompt and question at the end. Include the language version, framework and the exact command or input that triggers the bug so Claude can trace the failure instead of guessing your environment.

How is this list different from the Claude Code prompt lists?

These prompts are for Claude in the web app, desktop app or API, where you paste code excerpts, schemas or diffs and review the written answer yourself. The separate Claude Code lists are agent task briefs designed for terminal sessions where the agent reads your repository, edits files and runs shell commands.

Can I use these Claude coding prompts in ChatGPT or Cursor?

Yes. Every prompt uses plain instructions with no vendor-only syntax, so ChatGPT, Gemini, Cursor chat and DeepSeek follow them cleanly as well. Keep the verification section intact when you paste into any assistant so the model returns edge cases, sample inputs or test assertions alongside the code.

How do I avoid subtle bugs when refactoring code with Claude?

Ask Claude to list current behaviours, side effects and edge cases before touching the implementation, and request the smallest refactor that achieves your goal. Keep public function signatures unchanged unless you ask otherwise, and verify the updated code against your existing tests, type checker and linter before committing.