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.
What does each key do in SQL work?
| Key | What it does | Example |
|---|---|---|
| @ | 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 |
| Esc | Stops Claude mid-step | It starts editing the production view: stop, redirect |
| Esc Esc | Opens the rewind menu to go back to an earlier message | Undo a long wrong turn and ask again |
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,
Escearly; 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?
- Claude Code docs: Interactive mode, keyboard shortcuts and shell mode
- Claude Code docs: Checkpointing, the rewind menu
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.