A Prompt the Model Can Cite
numbered lines and overlapping chunks
Part of: AI Code Reviewer
The schema from lesson 1 asks the model for a line number. Models are bad at counting lines in a block of code. Ask one to review 60 unnumbered lines and the line numbers it returns will drift by a few, which sends the user to the wrong place. The fix is simple. Put the numbers in the prompt. Number every line. Prefix each line with its number and a separator before it goes into the prompt. Now the model copies a number it can see instead of counting. The right-aligned number and the make the boundary between the label and the code obvious, so the model doesn't confuse 12 with part of the code. Long files go in chunks. A 2,000 line file is too much for one review call. It is slow, expensive, and models review the end of a long input less carefully than the start. Split it into chunks of at most size lines. Plain back-to-back chunks cut functions in half, and a bug that spans the cut is invisible to both calls. So chunks overlap . Each new chunk starts overlap lines before the previous one ended. Each chunk keeps the file's real line numbers instead of restarting at 1, so findings from every chunk point at the same file. The overlap must be smaller than the chunk size, or the start
Challenge: Chunk and Number