Claude Code CLI: the commands, flags and shortcuts you'll use every day

Last updated: November 24, 2026
TL;DR
You only need a handful of things to work in the Claude Code CLI every day. Run claude in your project to start, claude -c to pick up where you left off, and claude -p "query" to run it from a script. Inside a session, type / for commands, @ to mention a file and ! to run a shell command. Press Shift+Tab to change the permission mode and Esc twice to rewind. Everything below comes from Anthropic's CLI reference, commands and interactive mode docs.
A note on spelling: long flags take two hyphens before their name, as the CLI reference writes them. Where a long flag has no short form, we name it without the hyphens, so the model flag below is the word model with two hyphens in front.
Start, resume and script a session
Four commands cover how a session begins:
| Command | What it does |
|---|---|
claude | Start an interactive session in the current directory |
claude "explain this project" | Start one with a first prompt |
claude -c | Continue the most recent conversation in this directory |
claude -r "auth-refactor" "Finish this PR" | Resume a session by ID or name |
To name a session so it's easy to find later, start it with claude -n "my-feature-work"; the name shows in /resume and the terminal title. Inside a session, /resume opens the picker.
For scripts and CI, claude -p "query" answers and exits, and it reads piped input too: cat logs.txt | claude -p "explain". Add -c to continue the last conversation from a script, as in claude -c -p "Check for type errors". Our headless guide covers output formats and running it unattended.
A few more subcommands earn a place in muscle memory: claude update updates to the latest version, claude doctor prints install and settings diagnostics without starting a session, and claude mcp configures MCP servers. Installing the CLI itself is covered in our prerequisites guide.
Type less: the prefixes and shortcuts
Three characters at the prompt change what you're typing:
- π
@starts a file path mention with autocomplete, so Claude reads exactly the file you mean. - π
!at the start runs a shell command directly, adds its output to the session, and has Claude respond to it. - βοΈ
/opens the command menu; keep typing to filter it.
And the shortcuts worth learning first:
| Shortcut | What it does |
|---|---|
Shift+Tab | Cycle permission modes: default, acceptEdits and plan, then bypassPermissions and auto where available |
Esc Esc | With text in the prompt, clear it; with the prompt empty, open the rewind menu |
Ctrl+C | Interrupt; with nothing running, clear the input, and press again to exit |
Ctrl+O | Toggle the transcript viewer, with each tool call in detail |
Ctrl+R | Search earlier prompts |
Ctrl+B | Send a running Bash command or agent to the background |
Ctrl+G | Edit your prompt in your default text editor |
Option+P or Alt+P | Switch models without clearing your prompt |
Shift+Enter | New line, natively in iTerm2, WezTerm, Ghostty, Kitty, Warp and Windows Terminal 1.25 or later |
On macOS, the Option shortcuts need Option set as Meta in your terminal; the interactive mode docs show the setting for each terminal.
The slash commands you'll reach for
Claude Code ships many built-in commands. These are the ones that come up most in a working day:
/initcreates aCLAUDE.mdguide for the project, and/memoryedits yourCLAUDE.mdfiles and auto memory./modelswitches the model and saves it as your default; pressson a row in the picker to switch for this session only./configopens settings, and also takeskey=valuepairs such as/config theme=dark./contextshows what fills the context window as a colored grid./compactsummarizes the conversation to free context, with optional focus instructions; our /compact guide covers when to use it./clearstarts a new conversation with empty context, and/resumebrings an old one back./rewind, also/undo, restores code, conversation or both to an earlier prompt./usageshows session cost, plan usage limits and activity;/costis an alias./statusshows version, model, account and connectivity.
If you send a command while Claude is still answering, Claude Code queues it for after the turn, though some, such as /status and /usage, run at once.
Set the session up from the command line
Flags let you start a session already configured, without touching your saved settings:
- The effort flag, with a level such as
high, sets the effort for this session only. Our effort guide explains the levels. - The model flag picks the model for the session, and the fallback-model flag lists models to try in order if the first is overloaded or unavailable.
- The add-dir flag gives Claude access to more directories, as in adding
../apps ../lib. - The append-system-prompt flag adds your own text to the end of the default system prompt for the session.
- The allowedTools and disallowedTools flags set which tools run without a prompt and which are denied; our permissions guide covers the rule syntax.
The CLI's own help output doesn't list every flag, so check the CLI reference before deciding a flag doesn't exist. Settings that should stick across sessions belong in a settings file instead; see our settings guide.
Frequently asked questions
How do I start the Claude Code CLI?
Open a terminal in your project and run claude. Add a prompt in quotes, as in claude "explain this project", to start with a first message. Claude Code asks you to log in on first use.
How do I resume a Claude Code session?
Run claude -c to continue the most recent conversation in the current directory, or claude -r with a session ID or name to resume a specific one. Inside a session, /resume opens a picker of earlier conversations.
How do I run Claude Code from a script?
Use claude -p with a query. It prints the answer and exits, and it accepts piped input, as in cat logs.txt | claude -p "explain". Add -c to continue the last conversation from a script.
How do I change permission modes in Claude Code?
Press Shift+Tab to cycle through default, acceptEdits and plan, then bypassPermissions and auto where they're available. The current mode shows in the mode indicator, where default reads Manual.
How do I undo what Claude Code just did?
Press Esc twice with an empty prompt, or run /rewind, to open the rewind menu. Pick an earlier prompt and restore code, conversation or both. Files changed only by shell commands aren't tracked, so keep using git.
Make every session start smarter
The commands get you moving; what Claude knows when a session starts decides how far it gets. /init gives you a first CLAUDE.md, and our guide to compound engineering with AGENTS.md shows how to keep that file growing with each session, so the next claude starts from more than the last one did.
Stop guessing. Score your first workflow.
Score one workflow in about five minutes. Nine questions, a grade, and the specific gap holding it back - no call required.
Related Posts

Claude Code in VS Code: the extension or the terminal, and how to set up both
Two ways to run Claude Code in VS Code that share one engine: the extension's chat panel with inline diffs and plan review, or the full CLI in the integrated terminal connected with /ide. How to set up each, and switch between them.

Claude Code vs Cursor: how they differ when you work in them
Claude Code is a terminal-first agent that runs on Claude; Cursor is an AI editor with its own agent, Tab autocomplete and models from several labs. Where you work, which models you get, how each reads project rules, how you undo, and how each runs unattended.

Claude Code thinking: turn it on, off, and see what it reasoned
Thinking in Claude Code is the reasoning Claude emits before it responds, and on the newest models it's always on. Which models let you turn it off, the toggle, /config and MAX_THINKING_TOKENS, how to read the reasoning, and what it costs.