TL;DR
Ctrl+_(alsoCtrl+-,Ctrl+Shift+-andCtrl+Shift+_) undoes the last edit in the input box: up to fifty steps, one per second of pause, with text, cursor and pasted content. Submitting clears it and there is no redo. Whatever Claude already changed in files or in the conversation is/rewind's job.
You're twelve lines into a prompt, you select the wrong span, hit a key, and half a line is gone. In an editor you'd press undo without thinking. In the terminal the usual move is a sigh and retyping it from memory, because "undo" in Claude Code sounds like /rewind, and /rewind is something else.
The input box has an undo of its own. It's in the prompt help (the one you open with ?), listed as undo, and in one row of the docs' shortcut table, with nothing more said.
Result (illustrative; the cursor is ▮):
> review the login and check that the refresh token expires after 15 min▮
...wrong selection, overwritten...
> review the login and c▮
Ctrl+_
> review the login and check that the refresh token expires after 15 min▮
How it works
1. It snapshots as you type. Every change to the input box goes into a buffer of fifty states. Each state carries the text, the cursor position and the pasted content, so stepping back also brings back an image you had pasted. At fifty-one, the oldest one drops off.
2. With a one-second grace period. It doesn't record every keystroke: it groups what you type in a run and takes the snapshot once you've gone one second without touching anything. That's why one Ctrl+_ gives you back a word or a phrase, not a letter. The exception is vim mode: outside INSERT, every operation is recorded on the spot.
3. It goes back, never forward. Each press steps one state back. There is no redo: overshoot and the only way forward is typing it again.
4. It clears on submit. The buffer lives as long as the draft does. The moment you press Enter, or a slash command finishes, it's wiped. It doesn't survive the session either.
The four key combinations
The binary carries four shortcuts pointing at the same action, chat:undo:
ctrl+_ ctrl+- ctrl+shift+- ctrl+shift+_
The docs list two. The other two exist because every terminal sends a different sequence for the same physical key: on some, Ctrl plus the hyphen arrives as ctrl+-, on others as ctrl+_. The help shows you a single one, whichever is bound, though all four work. If none of them responds, your terminal is swallowing it; /keybindings shows you what's bound and lets you remap it:
{
"bindings": [
{ "context": "Chat", "bindings": { "alt+u": "chat:undo" } }
]
}
What you don't want is Ctrl+Z, which is what the hand reaches for: on Unix it suspends the process, and the docs list it among the shortcuts that collide with the terminal. And if you pick one with Alt on macOS, your terminal has to send Option as Meta.
Four keys that look alike and aren't
| You want to | Key | What it touches |
|---|---|---|
| Undo the last thing you typed | Ctrl+_ |
The input box, one step back |
| Clear the box and recall it with the up arrow | Esc Esc |
The input box, whole, into history |
| Park the draft and ask something else | Ctrl+S |
The input box, into a separate slot |
| Undo what Claude changed | /rewind |
Files and conversation, by checkpoint |
The first three never touch a file. The fourth never touches the input box. Esc Esc sends the whole draft to history and you lose the cursor position; Ctrl+S parks it in a slot and hands it back when you submit the next prompt. Ctrl+_ is the only one that goes back one step, not all of them. And /rewind is what comes up when you search "claude code undo": it undoes what Claude did, and knows nothing about what you were typing.
Official docs: Interactive mode: keyboard shortcuts · Keybindings
Requirements
- Checked on Claude Code v2.1.258. The fifty-state buffer and the one-second debounce come from the binary itself; the docs only say it restores text and cursor.