A commit is a save point
You will learn
What a commit keeps, why editing afterwards cannot change it, and when to make one.
Vibecoding means an agent changes your files while you watch, and some changes break things. A commit is a save point: it keeps every file exactly as it was at that moment, and you can edit as much as you like afterwards, the saved copy does not change. In commit.t27 the file said 10 when it was committed; an agent then made it 99; going back returns 10, not 99. Each commit adds one save point to the history and overwrites nothing: after a third commit there are 3. Commit when the program runs, before you ask for the next change.
Try it
In the widget, read the value of the file at the three moments and find the one where the agent's edit is undone; then in the spec frame find RESTORED and say what would change if it were set to EDITED.
A file before and after an agent edits it, and what a commit lets you bring back. Lesson 7 of the course Vibecoding from zero with t27.
specs/vibecoding/commit.t27
// SPDX-License-Identifier: Apache-2.0
; specs/vibecoding/commit.t27 -- lesson "A commit is a save point" of the course "Vibecoding from zero with t27"
; A commit keeps your files exactly as they were at that moment. Edit later as much as you like:
; the saved copy does not change, and you can go back to it. Here a file is one number.
; ASCII only, English only.
module vibecoding_commit;
; The file when you committed, and the file after an agent changed it.
pub const SAVED : u8 = 10;
pub const EDITED : u8 = 99;
; What going back brings you: the saved copy, whatever the file says now.
pub const RESTORED : u8 = 10;
; Each commit adds one save point to the history; nothing is overwritten.
pub const COMMITS_BEFORE : u8 = 2;
pub const COMMITS_AFTER : u8 = 3;
test going_back_returns_the_saved_copy {
assert RESTORED == SAVED;
}
test editing_does_not_touch_the_save {
assert SAVED == 10;
assert EDITED != SAVED;
}
test a_commit_adds_one_save_point {
assert COMMITS_AFTER == COMMITS_BEFORE + 1;
}
; Negative control: plant the bug "going back reads the edit" (RESTORED = 99) and
; two tests turn red; with the line as written they stay green.
test negative_control_a_restore_is_not_the_edit {
assert RESTORED != EDITED;
}
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.