Lesson 4 of 8 · 14 min · Checked on 10 October 2026
When it goes wrong: undo, restart and understand the error
By the end of this lesson you will be able to:
- Undo unwanted changes with the agent's checkpoints, a copy or Git
- Restart with a new conversation and a smaller request when the agent keeps repeating the same mistake
- Ask the agent to explain an error without fixing it
- Recognise when to stop and ask a person for help
You asked the agent to change only Saturday's opening hours on the bakery page. It changed the hours, yes. But it also swapped the colours, deleted the address and added an order form that nobody asked for. And you, in a hurry, accepted.
It happens to everyone. Here are the three commonest cases and what to do.
This is how it looks on 6 October 2026; your screen may differ. Look for the button with the same name.
Case 1: it changed what you did not want, and you want to go back
Claude Code has automatic restore points. Each request you make creates one. To go back:
- Type
/rewind, or pressEsctwice with the text box empty. - In the list, choose the request before which you want to go back.
- Choose Restore code (puts the files back and keeps the conversation), Restore conversation (only the conversation) or Restore code and conversation (both).
Guide: Claude Code checkpointing.
There are limits. Changes made by terminal commands (deleting, moving or copying files) are not recorded. And restore points are no substitute for Git: they are kept for a while, then disappear.
Codex has no equivalent button for files. The documentation itself advises you to create restore points with Git before and after each task (Codex CLI).
With Git (in both agents), the folder must be in Git with an earlier commit: the subject of lesson 1/05. Keep three things apart:
- Look, changing nothing:
git statussays which files changed andgit diffshows the lines. - Save a point, with
git addandgit commit: lesson 1/05. - Go back: the only step that wipes work.
Watch out
Going back with Git wipes the unsaved changes in that file, and no /rewind brings them back. First make a copy of the folder (as in the tip below) and check with git diff HEAD -- index.html what you will lose: git diff on its own does not show what you already marked with git add.
To put the file back as it was at the last commit:
git restore --source=HEAD index.html
Without --source=HEAD, git restore takes the version from the staging area (what you marked with git add), which may already have the changes you wanted to undo. And with --source=HEAD the marked version stays there anyway; to drop it too, git restore --source=HEAD --staged --worktree -- index.html.
Without any of this, you can still ask the agent:
Undo the changes you made to index.html in the last request. Show me the diff before you apply it.
It often works, but it depends on the conversation's memory: don't count on it for anything important.
Tip
Before a bigger task, copy the folder in the file explorer, with another name such as experiencias-copia. It is the simplest restore point there is, and it works with any agent.
Case 2: the agent insists on the same mistake
You ask, it fails. You explain, it fails the same way. You explain better: same again.
The conversation fills up with failed attempts, and the agent keeps leaning on them. The fix is a clean sheet:
- Claude Code:
/clearstarts a new conversation. - Codex:
/newstarts a new conversation (/cleardoes too, and clears the screen).
And the new request should be smaller, with what you have learned:
In the file index.html, change only Saturday's opening hours to 7:00–13:00. Do not touch the colours, the address or anything else. Last time, when changing the hours, the address was deleted; check that it stays the same.
A rule that works well: two failed attempts at the same point, new conversation with a smaller request.
Tip
If the task is big, split it. “Make the whole page” fails more often than “make the header”, then “now the opening hours”, then “now the address”. Each small step has a small diff, which you read in a moment.
Case 3: a red error appeared
First understand, only then fix. Copy the error and ask:
Explain this error to me without fixing it. Tell me in plain English what it means, which file and which line it is in, and what you think caused it. Do not change any file.
[paste the error here]
Why not ask for “fix” straight away? Because the agent sometimes “solves” the error by deleting the part that causes it, and the problem just moves elsewhere. Use what you learned in lesson 0/03: the last line says what, and the file and line say where.
To keep it from changing files, ask this in plan mode (Claude Code) or with /permissions on Read Only (Codex). If it still asks to change something, say no.
When to stop and ask a person for help
Stop and ask someone who knows when:
- the agent wants to use
sudo, delete things outsideexperiencias, change system settings or switch off the antivirus; - the error talks about passwords, keys, payments or other people's data;
- something changed outside the
experienciasfolder; - three new conversations gave the same problem;
- you are already accepting without reading, because you are tired. That counts.
Watch out
When it goes wrong, the temptation is to give the agent more power so it can “sort it out for good”: switch on the mode that does not ask, accept everything, run the command with sudo. Do the opposite. The more confusing the problem, the slower you go, with more permission prompts, not fewer.
Mistakes here are cheap
The experiencias folder exists for this. If everything gets tangled, you delete the folder in the file explorer, create another and start again. You lose nothing important; you only spend agent usage, which counts towards your account's limits or your API key's bill. Every mistake here is one you will not make on the real bakery page or the parish council site. Try things, break them, go back: that is how you learn when to trust the agent.
Exercise
How I know it worked after step 5, the page has the colours it had before the request, and the address and the opening hours are the same.
If it didn't work
Esctwice does not open the list: the text box has to be empty. Clear it and try again, or type/rewind.- Only the option to restore the conversation appears: at that point the agent made no changes to files. Choose an earlier request.
- You went back in the conversation but the page is still blue: you chose Restore conversation. Repeat with Restore code.
- The page did not change in the browser: press
F5(orCmd + Ron a Mac) to reload. - Nothing worked: delete the
experienciasfolder and rename the copy toexperiencias.
Videos
Shows how to undo a commit with git revert, the basic way to roll back; the video is from 2022, but the concept has not changed.
An official Anthropic video on managing context in Claude Code: when to use /compact and when to use /clear to start again.
Test what you learned
Corrections to this lesson (2)
- : Second external review: the `git diff` before going back is now `git diff HEAD -- index.html`, which also shows what you already marked with `git add`; and the lesson gives the command to drop the staged version at the same time.
- : After an external review: the undo command is now `git restore --source=HEAD`, with the note that without that option the file comes from the staging area; viewing, saving and undoing are separated; the warning and the folder copy come before the command; the last section is now «Mistakes here are cheap», with a note that it uses up agent usage. Quiz options were reordered.