Vibe Coding
Git, Diffs, and Small Commits
Commit after each working slice. Keep history clean so you can undo a bad generation.
Git is the safety net
Agents can delete files, rewrite tests, and wander into unrelated folders. A commit from ten minutes ago is cheaper than reconstructing from memory.
Rules
- Commit before a risky prompt ("refactor the package layout").
- Commit after tests pass for the slice you asked for.
- One idea per commit: "Add notes export" not "stuff the agent did."
- Do not ask the model to rewrite git history, force-push, or skip hooks.
Never let an agent run destructive git commands. You type git reset and git restore yourself when you mean it.
Undo a bad generation
# Discard uncommitted agent changes (careful)
git restore .
git clean -fd # only if you understand it will delete untracked files
# Or reset the last commit you do not want (not pushed)
git reset --hard HEAD~1Prefer git restore on specific files when you still want other work in the tree.
Commit messages you write
Do not accept "Update files" from the model. You know the intent.
git add notes.py test_notes.py
git commit -m "Add notes search command"How you use Git in a vibe session
- Start clean:
git status. Commit or stash anything you already trust. - After a green slice,
git addonly the files you reviewed. Nevergit add .if the agent created junk. - Write the message yourself: what the slice did, not “update files.”
- If the generation is bad, restore specific files first. Hard reset only when you mean to throw away the whole slice and it is not pushed.
Pull requests stay small
If you work on a branch, open a PR per feature slice, not per afternoon of vibes. Reviewers (including future you) cannot review a 2,000-line agent dump.
Try it yourself
The agent created tmp_server.py you do not want, and improved notes.py that you do. How do you commit?
Show solution
git restore tmp_server.py
# or delete it if it is untracked: remove the file
git add notes.py test_notes.py
git commit -m "Add notes search command"Key takeaways
- Green slice, then commit.
- You own git. The agent owns the draft.
- Small commits make revert a strategy instead of a disaster.
- Never
git add .after a surprise generation.