Give it the whole file, not a snippet.

By (@codegirl) ·

I used to paste ten lines into the prompt and ask the model to fix the bug in them. Ten lines, out of a file of two hundred. The model would stare at those ten lines, find nothing wrong with them — because nothing was wrong with them — and then "fix" them anyway, by rewriting something that was fine. The real bug was forty lines up, in an import I had forgotten, or in a variable that was set at the top of the file and changed halfway down. The model never saw any of that, because I never showed it. I was asking it to solve a puzzle while hiding half the pieces, and then getting annoyed when it guessed wrong.

The model can only work with what is in front of it. It cannot see your project, it cannot open the other files, and it has no idea what lives above the snippet you pasted. When you give it a fragment, it fills the gaps with guesses — and its guesses sound confident, which is the dangerous part. It will tell you the bug is in the lines you pasted, because those are the only lines it has, and you will believe it, because it sounds sure.

Now the whole file goes in. Not the whole project — one file, the one with the problem, start to finish. It costs more words in the prompt, but it saves three rounds of wrong fixes. And I tell it where to look first: "The error is on line 87, but read the whole file — the problem might be in how the data gets there." That one sentence does two jobs: it points the model at the symptom and gives it permission to look past it for the cause.

If the file is huge, I paste the file and the error together, and I say which function the error points to. But I never paste a floating snippet on its own any more. A snippet is a riddle. A file is evidence. Give the model evidence, and it can actually find the bug instead of inventing one.

1 like · 2 views

Explore more on Prompted