Skip to content
Agentic Levels
Start hereLevelsTracksPromptsAbout
Get my levelGet my level

  • Start hereYour first useful task with AI.
  • Level quiz8 questions. No AI needed.
  • Fluency ScoreYour Level and a score, from your own AI.

  • LevelsThe 11 levels, in order.
  • LessonsShort lessons, filter by level.
  • TracksGuided paths by tool, role or goal.
  • Set up your AI tool
  • Starter packFree files that help AI remember.

  • PromptsReady prompts to copy and adapt.
  • ChatGPT vs Claude vs GeminiPick the right one for the job.
  • How-tos
  • ReferenceCommands for Claude Code, Codex, Antigravity.
  • ResourcesHand-picked reading and tools.

  • Your progress
  • Your next moveAn interview that picks your next skill.
  • Your next lessonsThe next lessons at your level.
  • Updates

  • Pricing
  • About
  • FAQ & Feedback
  • Work with us
  • How we handle your data
Sign inPreferences
AboutPricingHow-tosPromptsStarter packMy stackHow we handle your data

© 2026 Fuentes Studio

PrivacyTermsRefundsAccessibilityAI content policyCredits
yourCouncil
Ready to help
✦

What do you want to understand?

Ask anything about what you're learning.

←Claude Code Fundamentals
  1. Tracks
  2. ›Claude Code Fundamentals: Module 1
  3. ›Undo without panic
3

Level 3 · Lesson 4 of 16 · Free

Undo without panic

Esc-Esc, rewind, and what git still owns

Three edits into a session, Claude Code starts changing a file you never meant for it to touch. Your first instinct is to type three more corrections trying to talk it back into place. There was a faster way the whole time: undo it, and go back to before it wandered.

16 min · You'll know exactly what a session's undo can and can't save you from

You'll learn the real undo built into every Claude Code session, exactly what it can and can't take back, and why git still matters even after you've learned to rewind.

Step 1 of 6: The idea

Your steps

Step 1 of 6

The idea

The one idea this lesson is about, and why it matters.

Before you start

Complete Run a first safe session first; this lesson is the safety net for when that first safe session drifts anyway.

Quick recall · Run a first safe session

Last lesson, you learned to isolate risky work in a separate worktree before it starts. From memory, what's the relationship between that habit and this lesson's rewind?

A worktree is prevention, set up before risky work starts, so your main project stays untouched no matter what happens. Rewind is the cure, used after something already went sideways, to get the current session back to a known-good point. You want both: isolate what you can ahead of time, and know how to undo what still goes wrong anyway.

A session going sideways is not an emergency. It is the single easiest thing in Claude Code to take back.

Session rewind (Esc-Esc)Git
Undoes
Claude Code's own file edits, and the conversationAny committed change, to any file, from any source
Lasts
About 30 daysPermanently, across sessions and restarts
Cannot touch
Shell-command changes, or edits from other programsAnything you never committed
Use it for
"That last stretch went wrong, take me back""I want to return to this exact state next month"

Use both. Rewind is the cure for a session gone sideways; git is the memory that outlives the session.

The real mechanic: in the terminal, press Escape twice, with an empty prompt box, and Claude Code opens a rewind menu, a short list of earlier points in this session you can jump back to. Pressing Escape twice with something still typed instead just clears your draft, so the empty-box part matters. From that menu you can restore the conversation and the code together, the conversation alone, or the code alone, back to that point.

Same two key presses. What they do depends on one thing.
Prompt box emptyText still typed
Escape twice does
Opens the rewind menuJust clears your draft

The box has to be empty first. Otherwise Escape twice only clears what you typed.

The Rewind MenuThe whole rewind menu in three steps.
  1. 1
    Press Escape twiceWith the prompt box empty. That opens the rewind menu.
  2. 2
    Pick a pointThe menu lists every prompt from this session. Pick the one right before things went wrong.
  3. 3
    Choose what to restoreCode and conversation together, conversation alone, or code alone.

What it actually undoes, said plainly: rewind tracks edits Claude Code made through its own file-editing tool. It does not track changes from shell commands it ran (commands typed to the computer itself, like rm to delete a file or mv to move one), and it does not track edits any other program made to your files. If a step in your session ran a command that touched files directly, rewind may not be able to put those back.

This is not a small footnote, it is the one thing worth remembering before you trust it.

Session undo and git are two different safety nets, not one. Rewind lives inside a Claude Code session and is cleared out after about 30 days, though a session you come back to and resume can still rewind to its earlier points. Git, your project's own saved history, the record of every version you have chosen to keep, is your project's permanent history, the one that survives closing the terminal, restarting your computer, or coming back next week.

Committing just means telling git "save this version," a habit worth building even if Claude Code does it for you when you ask. Rewind is for "that last stretch went wrong, take me back." Git is for "I want to be able to return to this exact state a month from now."

Use rewind for the first, and keep committing to git for the second. Neither one replaces the other.

Set up git once, by asking. Paste this into Claude Code: Is this folder in git? If not, turn it into a git project, then save everything as the first commit with the message "first save". It tells you the answer and does the setup. To save again later, say: Commit my changes with a short message that says what changed. To check it worked, ask: Show me the last three commits.

Getting a deleted file back. Say: The file [name] was deleted. Restore it from the last saved commit, then show me that it is back. That works only if the file was saved in a commit before it was deleted.

If it was never committed, git has no copy, so it is gone. That is why you commit before risky work.

Rewind per surface. In the terminal, press Esc twice with an empty prompt box, or type /rewind (/undo does the same). Anthropic's docs describe both for Claude Code sessions in general, but they do not say where the desktop app or the web version shows the rewind menu.

So if you are in the desktop app, ask: Undo the last change you made, then show me the file so I can check it. To tell it worked, open the file yourself and look. The change should be gone. If it is not, restore the file from your last commit (see above).

To bring back an older session, type /resume in the terminal and pick it from the list.

Worked example. Three edits into a session, Claude Code starts refactoring a file you never asked it to touch.

claude

Claude Code v0.0.0

Sonnet (200K context) · Claude Pro

~/project

rewind·effort: high
›
Refactoring UserSettings.tsx to use the new hook pattern...
Rewind menu, your prompts this session:
  3. Fix the settings toggle
  2. Add a test for the toggle
  1. Set up the project
Pick a point, then choose: Restore code and conversation
Escape twice, with an empty prompt, opens the rewind menu.

Instead of arguing it back into place, you open the rewind menu (Escape twice in the terminal, or an ask to undo in the desktop app), see the point right before it wandered, and restore the conversation and code together. You are back to the known-good state, and you re-brief it with the boundary you forgot to name the first time.

claude

Claude Code v0.0.0

Sonnet (200K context) · Claude Pro

~/project

rewind·effort: high
›
Restored. UserSettings.tsx and the conversation are back to right before the refactor started.
You pick Restore code and conversation. One known-good point, restored, and now you re-brief it with the boundary you forgot the first time.

It is also completely normal to just throw a session away. Many practitioners restart a good share of their sessions, not because something broke, but because starting clean was faster than untangling where it drifted. That is routine, not a sign you did something wrong.

Rewind is the undo for the session you are in right now. Git is the memory that outlives it. Know which one you need before you need it.

That is the idea. Next you watch it work.

Step 2 of 6

Watch it

See one real prompt do one real job, then see which part of it made that work.

You type this

Claude Code just started refactoring a file that has nothing to do with what I asked. Undo the changes it made to that file since my last prompt, then show me the file so I can check the refactor is gone.

Claude Code does this

Claude Code goes next.

Step 3 of 6

Your turn

Write one part of the prompt yourself, then compare with one good answer.

What actually gets that file back

Now a different moment. Earlier in this same session, Claude Code ran a shell command that deleted a file you needed. You want that file back. Rewind or ?

Rewind only tracks edits made through Claude Code's own file-editing tool. A deleted-by-command file is a different kind of problem.

Your answer is saved with your progress, so leave out anything private.

Try it before you go on.

Getting it wrong first is what makes it stick.

Step 4 of 6

On your own

Do the task on your own work, in your own tool.

Think of one real Claude Code session that went sideways recently, even a small one. Write three lines: what went wrong, whether rewind alone would have fixed it or you needed git too, and one habit you'll change (committing more often, or reaching for rewind sooner) because of it.

  • Breaks when you trust rewind to undo a shell command's side effects, because it only tracks Claude Code's own file edits.
  • Breaks when nothing was ever committed to git, because a closed session takes its rewind history with it.

Go do it for real.

Come back with a result.

Leave out anything private. This uses one of your Course Council messages.

Step 5 of 6

Your takeaway

Fill in your own card, then save it to your workbook.

Your takeaway

Loading your card…

Agentic Levels

Session-Gone-Sideways Rescue Card

From “Undo without panic” · agenticlevels.com

A pocket rescue card for the moment a session drifts: when to rewind, when to restart, and when only git can save you.

1. What went sideways
 
2. Your restore point
 
3. Did a shell command run
 
4. Rewind or restart
 
5. Committed to git
 
6. Your own rule for choosing rewind versus just restarting the whole session
 
7. The first thing you'll do differently the next time a session drifts
 
8. One sentence on why you'll still commit to git, even now that you know rewind exists
 

Keep this for your next project. The habit is the point.

agenticlevels.com · claude-code-m1-04 · Nov 22, 2026

Save your card before you go on. It goes in your workbook.

Step 6 of 6

Remember it

Say it from memory first, then check it.

Try it from memory

Pulling this out of your own head now is the part that actually moves it into long-term memory. Re-reading only feels like it does.

From memory, name the keybinding that opens the rewind menu, and the one category of change it cannot undo.

Escape twice, with the prompt box empty. It cannot undo changes made by shell commands, like rm or mv, or by any program other than Claude Code's own file-editing tool. That gap is exactly why git still matters even after you've learned to rewind.

You can now

✓

You can open the rewind menu and choose what to restore

  • ✓You can say what rewind does not cover, specifically
  • ✓You can tell session-level undo apart from git's permanent history
  • ✓You do not treat restarting a session as a personal failure

Key takeaways

Esc-Esc opens a real undo for this session's conversation and code. It cannot undo shell commands or other programs, and it clears out after about 30 days, so git still owns your permanent history.

  1. 1In the terminal, Escape twice with an empty prompt (or /rewind) opens the rewind menu. In the desktop app, ask Claude Code to undo, then open the file to check.
  2. 2Rewind only tracks edits Claude Code made through its own file-editing tool, not shell commands or other programs.
  3. 3Session undo is temporary. Git is permanent. Use both, for different reasons.
  4. 4Restarting a session that went sideways is routine, not a mistake.

AI can help with this

You do not have to argue a session back on track. In the terminal, clear the prompt box, press Escape twice, and pick the point right before things went wrong. In the desktop app, ask Claude Code to undo its last change, then open the file to check. Either way going back is one step away, not a crisis.

Go deeper

  • Claude Code interactive modecode.claude.com (opens in a new tab) ↗
  • Claude Code common workflowscode.claude.com (opens in a new tab) ↗

That is the lesson. Mark it complete, and its question comes back to you in three days.

Was this helpful?

Up nextbecause you now know how to recover when a session goes sideways. Next you write down the repo rules that keep it from wandering off course in the first place.Write CLAUDE.md for the repo→

Related lessons

Move context without driftWrite a task brief Codex can finishWhat Claude Code actually is: one tool, several surfaces
← Back to Claude Code Fundamentals