Explain, debug, or speed up a SQL, Python, or DAX snippet
Explains what an existing query or script does, fixes errors, and optimizes it.
The prompt
Role: Act as a senior data analyst reviewing analytical code.
Context: The code (SQL / Python / DAX): [CODE]. What it is supposed to produce: [INTENT]. Schema / data model context: [DATA_CONTEXT]. Environment and data volume: [ENV_VOLUME]. Symptoms if any (wrong numbers, slow, errors): [SYMPTOMS].
Task: Produce: (1) a step-by-step plain-English explanation of what the code actually does; (2) correctness issues - logic errors, wrong joins/filters, grain/fan-out problems, null handling, timezone or type issues - each with the effect on the result and a fix; (3) performance suggestions ranked by expected gain vs risk (only if performance is a stated concern); (4) readability/maintainability notes.
Format: Sections: What it does | Correctness issues (each: problem / effect / fix) | Performance (if relevant) | Readability. Reference lines.
Verification: For each correctness issue give a concrete input/scenario where the output is wrong; if unsure it is a bug vs intended, label it a question.
Validation: Re-check the top issue: does it actually change the numbers given the real data context, and would the fix change any downstream consumer? Note it.
Highlighted [brackets] are blanks to replace with your own details.
Fill in the blanks and use this promptMore Data & Analysis prompts
What to fill in
- CODE
- INTENT
- DATA_CONTEXT
- ENV_VOLUME
- SYMPTOMS
How this prompt is built
This prompt follows the RCTFVV structure (Role, Context, Task, Format, Verification, Validation). RCTFVV extends RCTF with two checking steps. Verification asks the model to review its own draft against your requirements; Validation asks it to flag assumptions and gaps you should confirm.
Related prompts
- Analyze my clinic's claim denials and revenue cycle KPIsTurns denial and A/R data into root causes, benchmark gaps, and a prioritized fix list for the front end, coding, and billing teams.
- Trace data lineage across SQL scripts and stored proceduresMap where each table's data comes from and goes to, so you can see what breaks before you change a table.
- Audit and retire unused or duplicate dashboardsA plan to inventory BI content, find what's unused or redundant, and retire it safely without breaking anyone's workflow.
- De-identify a dataset before sharing itA plan to remove or mask personal data in a dataset while keeping it useful for analysis, including re-identification risk checks.