Back to Blog

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

Alex Kim
7 min read
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:

CommandWhat it does
claudeStart an interactive session in the current directory
claude "explain this project"Start one with a first prompt
claude -cContinue 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:

ShortcutWhat it does
Shift+TabCycle permission modes: default, acceptEdits and plan, then bypassPermissions and auto where available
Esc EscWith text in the prompt, clear it; with the prompt empty, open the rewind menu
Ctrl+CInterrupt; with nothing running, clear the input, and press again to exit
Ctrl+OToggle the transcript viewer, with each tool call in detail
Ctrl+RSearch earlier prompts
Ctrl+BSend a running Bash command or agent to the background
Ctrl+GEdit your prompt in your default text editor
Option+P or Alt+PSwitch models without clearing your prompt
Shift+EnterNew 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:

  • /init creates a CLAUDE.md guide for the project, and /memory edits your CLAUDE.md files and auto memory.
  • /model switches the model and saves it as your default; press s on a row in the picker to switch for this session only.
  • /config opens settings, and also takes key=value pairs such as /config theme=dark.
  • /context shows what fills the context window as a colored grid.
  • /compact summarizes the conversation to free context, with optional focus instructions; our /compact guide covers when to use it.
  • /clear starts a new conversation with empty context, and /resume brings an old one back.
  • /rewind, also /undo, restores code, conversation or both to an earlier prompt.
  • /usage shows session cost, plan usage limits and activity; /cost is an alias.
  • /status shows 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.

#claude-code#CLI#Terminal#Keyboard Shortcuts#ai-agents
Free assessment

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.