AI & LLMs

What is a diff?

A diff is a record of exactly what changed between two versions of a file: the lines added, the lines removed, and nothing else.

New to Bolt? Sign up free.

Technical definition

A diff is the computed difference between two versions of a text file, expressed as a set of line-level additions and deletions with surrounding context. Diffs underpin version control review, merges, and patch application.

In AI coding, diffs serve a second purpose. Instead of regenerating an entire file to change part of it, a model emits a diff describing the specific edit. The platform applies it. Output length drops from the size of the file to the size of the change.

In plain terms

A diff is a change list. Rather than handing you a new copy of a document and letting you find what moved, it tells you: this line went away, this line arrived.

Why it matters

For anyone paying for AI by usage, diffs are a cost mechanism.

Every token a model writes is billed. Changing one line in a 500-line file by rewriting the file spends 500 lines of output. Changing it with a diff spends a few. On a project you edit dozens of times, the difference compounds.

There is a quality effect too. A regenerated file is a chance for the model to alter something you did not ask about. A targeted edit leaves the rest of the file untouched.

And diffs make review possible. Reading a change list takes seconds. Comparing two versions of a whole file does not.