Mastering Write SQL query
on Claude 3.5 Sonnet
Stop guessing. See how professional prompt engineering transforms Claude 3.5 Sonnet's output for specific technical tasks.
The "Vibe" Prompt
Optimized Version
Engineering Rationale
The optimized prompt provides clear instructions, defines the persona (expert SQL query generator), and includes a chain-of-thought section. This C-o-T breaks down the problem into logical steps, helping the model understand the exact requirements and thought process, leading to a more accurate and robust SQL query. It guides the model through table identification, filtering, and column selection, reducing ambiguity.
How We Validate This Prompt
Every optimized prompt for Write SQL query on Claude 3.5 Sonnet is scored against a fixed set of evaluation assertions. A revision ships only when it passes all of them, so the 0% token reduction never comes at the cost of output quality.
- The 'optimized_prompt' clearly states the goal of generating an SQL query.
- The 'optimized_prompt' uses a chain-of-thought to guide the model's reasoning.
- The 'optimized_prompt' specifies the target customer ID (123) and table ('orders').
- The 'optimized_prompt' requests all columns ('SELECT *').
- The 'vibe_prompt' is significantly shorter and less detailed than the 'optimized_prompt'.
Related Optimizations
Optimize your own Write SQL query prompt
Run any prompt through the same optimizer that produced this Claude 3.5 Sonnet guide — clarity, structure, and token efficiency in one pass.
Open the Optimizer