Read the diff before you accept it
You will learn
How to read an agent's diff against your request and spot a change nobody asked for.
An agent says done and shows a diff: the lines it removed and the lines it added. Read it against what you asked for. If you asked for a change to lines 10 to 20 and the diff also touches line 40, that is a change nobody requested, and now you have to read it. Accept a diff whose every touched line is in the request. Send back one that is not, or ask why. Even a clean diff still goes through the tests.
Try it
Read the two diffs against the request for lines 10 to 20, mark the lines outside it, then accept one diff and send the other back. In the spec, find the line number the sprawling diff touches outside the request.
Two diffs, one request: see which touched lines fall outside what you asked for, and accept one diff and send the other back. Lesson 18 of the vibecoding course.
specs/vibecoding/read_diff.t27
// SPDX-License-Identifier: Apache-2.0
; specs/vibecoding/read_diff.t27 -- vibecoding lesson: read the diff before you accept it
; An agent was asked to change lines 10 to 20 of a file. Its diff lists the lines it touched.
; Before you accept, look for touched lines outside the ask: each one is a change you did
; not request and now have to read. A clean diff has none. outside_the_ask is the check
; written as code; the tests walk the two diffs below line by line.
; phi^2 + 1/phi^2 = 3 | TRINITY
module vibecoding_read_diff;
pub const ASK_FROM : u8 = 10;
pub const ASK_TO : u8 = 20;
pub const CLEAN_DIFF : [4]u8 = [10, 12, 15, 20];
pub const SPRAWLING_DIFF : [4]u8 = [12, 13, 14, 40];
pub fn outside_the_ask(line: u8) -> u8 {
if (line < ASK_FROM) {
return 1;
}
if (line > ASK_TO) {
return 1;
}
return 0;
}
test a_clean_diff_stays_inside_the_ask {
assert CLEAN_DIFF[0] >= ASK_FROM;
assert CLEAN_DIFF[3] <= ASK_TO;
assert CLEAN_DIFF[1] >= ASK_FROM;
assert CLEAN_DIFF[2] <= ASK_TO;
}
test the_edges_of_the_ask_are_inside {
assert ASK_FROM >= ASK_FROM;
assert ASK_TO <= ASK_TO;
assert ASK_FROM - 1 < ASK_FROM;
assert ASK_TO + 1 > ASK_TO;
}
test negative_control_a_sprawling_diff_is_flagged {
assert SPRAWLING_DIFF[3] > ASK_TO;
assert SPRAWLING_DIFF[0] <= ASK_TO;
}
All lessons
Module 1 · What vibecoding is
You describe, an agent writes, you run it and check. What a program is, and five myths put to a test.
Module 2 · Your desk
An editor with an agent beside it, ten terminal commands, and reading an error message.
Module 3 · Save points with git
A commit is a save point, a branch is a safe try, and a key is a pair of which one stays private.
Module 4 · Prompting
The parts of a prompt, an example in place of an adjective, and one small step at a time.
Module 5 · The working loop
Four phases from idea to ship, the loop of ask, run, read and fix, and what to do when it is stuck.
Module 6 · A test as the judge
A test says yes or no, a planted bug shows the test works, and a diff is read before it is accepted.
Module 7 · The parts of an agent
What an agent answers with, what it can do with tools, and what it keeps between messages.
Module 8 · A first bot
A bot is a message loop, a bot comes from a spec, and a secret stays out of the repository and the prompt.
Module 9 · Your own project
A spec for your own idea, one thing measured after it runs, and an honest plan for the next month.