AI Tips, Tricks & Thoughts by Terry Peterson investingengine.ai

Stop AI from Guessing

Sep 9, 2026 · by Terry Peterson · claudeworkflowdatabasescli

Who this is for: People who use Claude Code in the terminal (CLI). Browser-only AI users: the idea carries over, but use your AI to re-write the steps.

Though I’m usually happy to let Claude Code “think” away for minutes after I submit a prompt, sometimes I’ll browse through the “thinking” displayed in the CLI. I kept seeing mention of “I guessed wrong”, or “column name guessed incorrectly”. Since our project includes a database that Claude Code built, I challenged Claude to tell me why there would be any guessing required during thinking sessions. Sure enough, the explanation was that to save effort, queries were written with assumed or guessed column names. I never experienced a major data issue, like writing data to the wrong column or corrupting data, but I can imagine it’s only a matter of time before a column name is guessed wrong during a purge or a write and happens to match a real column. In lighter cases, an analysis could return bad data.

The first time I noticed guessing, I asked Claude to write a rule into its instructions: look at the table before you query it, don’t guess. The second time, I had Claude write and maintain a cheat sheet of column names for the tables it uses most and to check the cheat sheet before queries, don’t guess! I was quite aggravated seeing the same guessing occurring during thinking sessions even after asking for these two rules to be put in place.

Here’s what finally worked:

1. Query tables first, don’t guess. One line in your project instructions: “Before your first query against any table, fetch one row with every column and read the names.” One cheap call instead of a chain of wrong or risky calls.

2. Keep a verified cheat sheet. Another project instruction: “For the handful of tables you touch every day, write the real column names in a markdown file. Read this database cheat sheet at the start of each session. Include a ‘last checked’ date next to each entry.”

3. Move the rule into the tool. This is the one that finally held. First, find out how your AI reads your database. That’s the tool we’re going to make smarter. Prompt:

I’d like for you to add a guard to the script or command you use when you look up something in the database, so that before it sends anything, it must check that the table exists and that every column named in the request is an actual column of that table, using the live database’s own list of tables and columns, not your memory. If anything doesn’t match, refuse the request, print the real column names, and send nothing. Run a test or two with known wrong column names to ensure it works.

A rule the AI has to remember will eventually be forgotten, especially during heavy usage. It’s much harder to bypass a tool the AI utilizes.