All Shortcuts

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

ChatGPT OpenAI Codex CLI OpenClaw Gemini Midjourney Perplexity
📄 View Printable Cheat Sheet — Download as PDF or print · 🧩 Combine with other tools

Search all Claude Code shortcuts interactively with real-time filtering

Open Interactive Shortcut Finder

Looking for slash commands? They moved to the new Claude Code prompt commands reference.

All Shortcuts

File & Code Operations

ShortcutActionDescription
TabAutocomplete pathAutocomplete file names and directory paths.
/add-dir <path>Add directoryAdd an additional directory to the working context.
/diffShow diffDisplay pending file changes as a diff.
/undoUndo last editRevert the most recent file modification.
/lsList filesShow files in the current working directory.

CLI Flags (Startup)

ShortcutActionDescription
claude --printPrint mode (-p)Non-interactive mode: print response and exit.
claude --model <id>Select modelSpecify which Claude model to use.
claude --continueContinue last sessionResume the most recent conversation.
claude --resume <id>Resume by IDResume a specific past conversation by session ID.
cat file.py | claudePipe inputPipe file or stdin content directly into Claude Code.
claude --no-markdownPlain text outputDisable Markdown formatting in responses.
claude --output-format jsonJSON outputReturn structured JSON output for scripting.
📜 Source: Claude Code documentation — CLI reference. Flags and file commands from Anthropic's CLI reference; the in-session slash command set is documented separately and covered on the prompts page. Checked 2026-09-04. How we verify ›

Browse shortcuts for 268 platforms

Explore All Platforms Practice Shortcuts
🔧 Spotted an error or a missing shortcut? Suggest an edit on GitHub — every accepted fix goes live on this page, the API and the CLI.

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?"

ChatGPT Claude Perplexity Gemini Grok