ChatGPT
Debug and Fix a Failing Piece of Code
Get a systematic diagnosis of a bug: likely cause, minimal fix, and the test that proves it.
SQL
Turn a reporting question into correct SQL, then optimise it with indexes and an execution plan review.
Act as a database engineer fluent in {{database}}. Schema (tables, columns, keys, approximate row counts): {{schema}} Question to answer with data: {{question}} Performance constraints: {{constraints}} Provide: 1. The query, formatted and commented 2. A plain-language explanation of how it produces the answer 3. Edge cases: nulls, duplicates, time zones, soft deletes 4. Expected execution plan shape and where the cost sits 5. Index recommendations, with the trade-off on writes 6. An alternative formulation (CTE vs subquery vs window function) and when it would be faster 7. How to verify correctness with a small sanity-check query Use only tables and columns present in the schema. If something is missing, ask instead of assuming.
Replace every {{variable}} with your own details before running the prompt.
4 variables
Get a systematic diagnosis of a bug: likely cause, minimal fix, and the test that proves it.
Review code for correctness, security, performance and readability with severity-ranked findings.
Understand inherited code fast: what it does, why, its dependencies and where it breaks.