Short answer: save a Git checkpoint before Codex starts, so any change can be undone. Say what done looks like in a way Codex can check: "done when the reconciliation query returns the same monthly totals as before". Run /review and read the changes before you keep them. For SQL, the second habit matters most: a query that runs is not a query that is right.
Agents are good at making code that runs. They cannot know that revenue for March must still be 412,880 unless you tell them. The "done" line turns your knowledge into a check the agent can run itself.
What does each habit look like for SQL?
- git commit before the task
- one task per commit
How do you write a good "done when"?
| Weak | Strong |
|---|---|
| "Make it faster" | "Done when it runs under 10 s on the test database and the result has the same 1,284 rows" |
| "Fix the revenue view" | "Done when March revenue equals the finance figure of 412,880" |
| "Add the region column" | "Done when every row has a region and the monthly totals are unchanged" |
The numbers here are made up. Use a figure you trust, from finance or a past run.
What does /permissions add?
/permissions sets what Codex may do without asking. For SQL work, let it run your tests and the read-only checks freely, and keep it asking before anything that writes to a database.
Where can you check this?
- Codex docs: Best practices, the parts of a prompt and reviewing work
- Codex docs: Codex CLI, Git checkpoints and
/review
Where do you start?
Try it on a first task with your first Codex task on a data repository. For checks you run before any query, see a skill that checks SQL.