Skip to content

Why line-level citations matter in AI answers about code

An answer about code is only as useful as your ability to check it. Why file and line citations change how you read, trust and share AI explanations.

October 13, 2026 · 2 min read · RepoGrasp team

Compare two answers to "where is the order total calculated?"

The order service computes the total by summing line items and applying discounts and tax.
The total is computed in src/services/pricing.ts:22-48: line items are summed at line 27, discounts applied at line 35 by applyDiscounts (src/services/discounts.ts:10), and tax added at line 44.

Both may be correct. Only the second can be checked in seconds, and only the second is useful the moment you need to change something.

Citations make answers checkable

Every explanation of code is a claim. Without citations, checking a claim means repeating the search the tool did: finding the file, then the function, then the line. Most people skip that step, which is how wrong answers end up in pull requests. With citations, checking is one click.

Citations expose hallucinations

A hallucinated claim is hard to cite. If a citation points at a line that doesn't support the claim, or at a file that doesn't exist, you've caught an error immediately. Uncited claims hide errors in vague language.

Citations show the path, not just the destination

For "how does X work?" questions, the useful answer is an ordered list of places in the code. Citations turn an explanation into a route you can walk: open the first cited line, read, open the next.

Citations make answers shareable

An answer with citations can be pasted into a design doc, an issue or a PR description, and readers can verify it without asking you. Uncited answers have to be taken on trust.

What makes a good citation

  • Specific: a line or short range, not just a file.
  • Inline: next to the claim it supports, not in a list at the end.
  • Current: pointing at the code as it is now, at a specific commit or branch.
  • Honest: citing the code that supports the claim, not code that's merely nearby.

How RepoGrasp produces them

RepoGrasp prefixes every line of every source file with its line number before the model sees it, and instructs the model to cite locations inline as path/to/file.ts:12-30. In the answer, citations are highlighted so you can spot them at a glance. Because the repository is read when you ask, citations point at the current state of the branch you linked.

A habit worth building

Whatever tool you use, treat an uncited claim about code as a hypothesis, and a cited one as a pointer to evidence you still need to read. Citations don't make an answer true. They make it quick to find out.

See cited answers in the demo.