Command history
Claude Code keeps a history of the prompts you type, and Up-arrow recall reaches prompts from past sessions of the same project:
- Input history is stored per working directory
- Running
/clearstarts a new session: recall then lists the new session's prompts first, with earlier sessions' prompts after them. The previous session's conversation is preserved and can be resumed. - Submitting the same prompt twice in a row records one history entry, so pressing Up steps to the previous distinct prompt
- When you recall a prompt that included pasted text, Claude Code sends the full pasted content again when you resubmit. If the content has since been cleaned up, Claude Code doesn't send the literal
[Pasted text #N]string; see Paste large content for what happens to the prompt - History expansion with
!is disabled by default
Reverse search with Ctrl+R
Press Ctrl+R to interactively search through your command history. In fullscreen rendering, Ctrl+R opens a search dialog instead: type to filter, press Up and Down to move through matches, and press Ctrl+S to cycle the scope through this session, this project, and all projects. Press Enter or Tab to place a match in the prompt input, or Esc to cancel. The steps below describe the classic renderer's inline search:
- Start search: press
Ctrl+Rto activate reverse history search - Type query: enter text to search for in previous commands. The search term is highlighted in matching results
- Navigate matches: press
Ctrl+Ragain to cycle through older matches - Search scope: the inline search always searches prompts from all projects
- Accept match:
- Press
TaborEscto accept the current match and continue editing - Press
Enterto accept and execute the command immediately
- Press
- Cancel search:
- Press
Ctrl+Cto cancel and restore your original input - Press
Backspaceon empty search to cancel
- Press
The inline search scans your full prompt history, newest first, with duplicates collapsed to the newest occurrence. The fullscreen dialog searches your whole prompt history in the selected scope, newest first, with duplicates collapsed to the newest occurrence: the most recent prompts appear immediately, and matches from older prompts fill in as Claude Code loads the rest. Matching prompts display with the search term highlighted, so you can find and reuse previous inputs.
Accepting a match or canceling the search takes effect immediately, even while Claude Code is still loading the history.