INTRODUCTION
When it goes wrong
Agents make mistakes. Git can roll them back.
press Enter ↵
Coding agent (pretend: scripted, not a real AI)

The agent waits for your prompt.

📁 Documents\my-site

No files yet.

Lesson 74: When it goes wrong

Level 9, Be the Boss: Review, Approve, Plan. Stay calm, see what changed, roll back with Git. The new word: roll back. It follows lesson 73, House rules for your agent. Next comes lesson 75, Test it yourself.

What the lesson explains

When it goes wrong. Agents make mistakes. Git can roll them back.

Oops!. Someone allowed a change too fast. The page broke! stay calm; look what changed; roll back with Git.

What you do first

Save first. Save all your work in one new save point. Starting at PS C:\Users\you\Documents\my-site>, one way takes 2 commands: git add .; git commit -m "Checked agent work" (par: 2).

The files on the practice computer

This lesson works in one folder. At the start, Documents\my-site holds images\, .gitignore, CLAUDE.md, done.txt, footer.txt, games.html, ideas.txt, index.html, keys.env, secrets.txt, style.css, todo.txt.

Along the way you type git add ., type git commit -m "Checked agent work", save index.html in Documents\my-site and type git restore index.html. Lesson 75 opens with the files just as you leave them.

What you practise

Try it, "Save first": Save all your work in one new save point. Starting at PS C:\Users\you\Documents\my-site>, one way takes 2 commands: git add .; git commit -m "Checked agent work" (par: 2).

Try it, "What changed?": In the practice terminal, type git diff at the prompt PS C:\Users\you\Documents\my-site> and the computer answers: diff --git a/index.html b/index.html / --- a/index.html / +++ b/index.html / @@ -8,13 +8,5 @@ / <h1>Hi, I am Sam</h1> / <p>I like coding, cats and football.</p> / - <img src="images/cat.png" alt="My cat Mittens asleep on a book"> / - <h2>My favourite things</h2> / - <ul> / - <li>Pizza</li> / - <li>Football</li> / - <li>Space</li> / - <li>Cats</li> / - </ul> / - <footer><b>Made by Sam</b></footer> / + <footer style="color: purple"><b>Made by Sam</b></footer> / </body> / </html>.

Fix it, "Roll it back": Roll back index.html to your last save point. Starting at PS C:\Users\you\Documents\my-site>, one way takes 1 command: git restore index.html (par: 1).

In your head, "Why was it easy?": Why could you roll back so fast? The answer: "I made a save point first".

What PlayBuddy and PlayType say

PlayBuddy: "Uh-oh, the agent broke the page! No panic. Git can roll it back."

PlayType: "Stay calm. Look at what changed, then roll it back with Git."

Help in every lesson

Everything happens on a pretend computer in your browser, so nothing touches your real files. PlayBuddy and PlayType stand beside the board, cheer you on and say when it is your turn.

A green ring shows where to click the first time. After that you do it on your own, and if you slip twice the ring comes back.

Stars

The lesson has 4 things to do. Up to one slip in ten gives three stars, up to one in four gives two, and finishing always gives at least one. Stars and progress are saved in this browser only; there is no account.

About DayOneCode

DayOneCode is an independent learning site, not affiliated with or endorsed by Anthropic. Claude and Claude Code are trademarks of Anthropic.