Claude Code Keyboard Shortcuts & Commands (27)
Complete collection of 12 Claude Code keyboard shortcuts and commands. Browse all shortcuts organized by category with our interactive search tool.
This page covers the terminal-level surface of Claude Code: the flags you pass when launching claude and the handful of in-session commands that touch files directly. The much larger set of slash commands, hooks and prompt prefixes has its own reference in the Prompts section; keep the two apart in your head, because the flags decide how a session starts and the slash commands decide what happens inside it.
Related Shortcut Pages
Search all Claude Code shortcuts interactively with real-time filtering
Open Interactive Shortcut FinderLooking for slash commands? They moved to the new Claude Code prompt commands reference.
All Shortcuts
File & Code Operations
| Shortcut | Action | Description |
|---|---|---|
| Tab | Autocomplete path | Autocomplete file names and directory paths. |
| /add-dir <path> | Add directory | Add an additional directory to the working context. |
| /diff | Show diff | Display pending file changes as a diff. |
| /undo | Undo last edit | Revert the most recent file modification. |
| /ls | List files | Show files in the current working directory. |
CLI Flags (Startup)
| Shortcut | Action | Description |
|---|---|---|
| claude --print | Print mode (-p) | Non-interactive mode: print response and exit. |
| claude --model <id> | Select model | Specify which Claude model to use. |
| claude --continue | Continue last session | Resume the most recent conversation. |
| claude --resume <id> | Resume by ID | Resume a specific past conversation by session ID. |
| cat file.py | claude | Pipe input | Pipe file or stdin content directly into Claude Code. |
| claude --no-markdown | Plain text output | Disable Markdown formatting in responses. |
| claude --output-format json | JSON output | Return structured JSON output for scripting. |
Launching a session the way you mean to
claude --continue reopens the most recent conversation in the current directory and claude --resume <id> picks a specific one, which is how you carry a half-finished refactor across a lunch break without re-explaining it. claude --model <id> pins a model for the session — handy for pointing cheap models at boilerplate. claude --print (short form -p) runs a single prompt and exits without the interactive UI, and it is the form scripts and CI jobs should use; pair it with claude --output-format json when another program will read the answer, or claude --no-markdown when a human will read plain text in a log.
Piping and directories
Because Claude Code reads standard input, cat file.py | claude hands a file to the model with a prompt attached on the command line, and the same pattern works with a git diff or a log tail. Inside a session, /add-dir <path> widens the working set to a second directory — a shared library next to the app, for example — without restarting. /ls lists what the session can see, and Tab autocompletes paths as it would in a shell.
Checking and undoing edits
Claude Code edits files in place, so two commands matter more than the rest: /diff shows what changed since the last checkpoint, and /undo reverts the most recent edit. Reviewing with /diff before running tests is the habit that catches an over-eager change early; keeping the working tree committed before a session means git is the second safety net when /undo is not enough.
Frequently asked questions
Where are the slash commands like /compact and /clear?
On the Claude Code prompts reference page, which lists the full in-session command set. This page covers the CLI flags and the file-operation commands only.
What is the difference between --continue and --resume?
--continue reopens the last session in the current directory. --resume takes a session ID and reopens that specific one, even if a newer session exists.
How do I use Claude Code in a script?
Run claude --print with the prompt as an argument (or piped in). Add --output-format json if another program parses the result.
How do I revert a change Claude Code made?
/undo reverts the last edit. For anything older, use git — commit before the session so the working tree is recoverable.
🤖 Ask AI about Claude Code shortcuts
Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"