Four Claude Code keys that make SQL work faster

@ points Claude at a file, ! runs a command yourself, Esc stops it, and Esc twice rewinds. How each one helps when the work is queries and schemas: point at the right table, run the query yourself, stop a wrong join early.

Short answer: type @ to point Claude at the exact file (@schema/sales.sql), so it reads your real table definitions instead of guessing. Start a line with ! to run a command yourself (! sqlcmd -i check_totals.sql), and Claude sees the output. Press Esc to stop it the moment it heads for the wrong table, and Esc twice on an empty prompt to rewind to an earlier message and try again.

SQL work goes wrong in quiet ways: a column name that almost exists, a join on the wrong key, a filter on the wrong date. These four keys keep you steering instead of waiting for a long answer that started wrong.

Nothing loads from YouTube until you press play. Then Google receives your IP address and may set its own storage. Narrated with an AI-generated voice. Privacy

What does each key do in SQL work?

KeyWhat it doesExample
@Points Claude at a file"Use @schema/orders.sql and @schema/customers.sql to write the join"
!Runs a command yourself; Claude sees the output! python run_query.py top_customers.sql
EscStops Claude mid-stepIt starts editing the production view: stop, redirect
Esc EscOpens the rewind menu to go back to an earlier messageUndo a long wrong turn and ask again
Four keys, used on a data project

Why is @ the most useful one for data?

Because the most common AI SQL mistake is an invented column. With @ the table definition is in the conversation, so Claude writes OrderDate because that is the column, not order_date because that is common. Point at the schema file, the view you are changing and the test query, and leave the rest out.

When should you run a command yourself with !?

When you want to see the result before Claude acts on it: row counts, a quick total, a dry run. It is also how you show Claude a real error message instead of describing it.

What goes wrong?

  • No schema in the folder. Export your table definitions to files first, so there is something to point at.
  • Letting it run long. If the first step is wrong, Esc early; every later step builds on it.
  • Rewinding without saying why. After a rewind, add one sentence about what was wrong.

Where can you check this?

Where do you start?

Write the queries Claude checks with SQL window functions explained, and plan a bigger change with the workflow for a pipeline change.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.