Blog
 » 

Claude

 » 
Claude Code CLI: Every Command and Shortcut You Need to Know

Claude Code CLI: Every Command and Shortcut You Need to Know

Discover all essential Claude Code CLI commands and shortcuts to boost your productivity and streamline your workflow effectively.

Jesus Vargas

By 

Jesus Vargas

Updated on

Apr 10, 2026

.

Reviewed by 

Why Trust Our Content

Claude Code CLI: Every Command and Shortcut You Need to Know

Claude Code CLI commands span five distinct categories: startup flags, keyboard shortcuts, slash commands, context commands, and headless flags. Most users discover only half of them by accident.

This guide maps all of them in one place. You get the complete command surface without stopping a session to check documentation.

 

Key Takeaways

  • claude with no flags starts interactive mode: The simplest invocation is also the most common. All flags modify specific behaviours from this baseline.
  • Three keyboard shortcuts change everything: Shift+Tab toggles plan mode, Ctrl+C cancels execution, and Ctrl+R searches session history.
  • Slash commands run inside active sessions: /clear, /undo, /compact, and /plan are the most-used and take effect immediately without restarting.
  • --print is the headless gateway: It runs Claude Code non-interactively and outputs to stdout. This is the foundation for all CI/CD and automated pipeline use.
  • Plan mode works three ways: Set it at startup with --plan, toggle it mid-session with Shift+Tab, or activate it in-session with /plan.
  • --model selects the Claude version: The default is Claude Sonnet. Specify Opus for complex tasks or Haiku for speed-focused work.

 

AI App Development

Your Business. Powered by AI

We build AI-driven apps that don’t just solve problems—they transform how people experience your product.

 

 

Getting Started: How Do You Run Claude Code?

claude with no arguments starts an interactive session in the current directory. Claude Code reads your project files and any CLAUDE.md automatically on launch. Four core invocations cover the majority of real-world use.

Before running any command, cd into your project folder. Claude Code uses the current directory as its working context.

  • claude: Starts an interactive session immediately. Claude Code reads the directory and any CLAUDE.md file on launch.
  • claude "your prompt": Starts an interactive session and immediately submits the quoted string as the first message.
  • claude --version: Prints the installed version. Use this to confirm a successful install or check whether an update is needed.
  • claude --help: Prints all available flags and brief descriptions. The fastest way to check flag syntax without leaving the terminal.
  • New installs: For setup steps if Claude Code is not found after install, refer to the installation guide.
  • Choosing a tier or model: For available access tiers and model options, the Claude Code channels guide explains the differences.

 

What Are the Core Startup Flags?

Startup flags modify Claude Code's behaviour at launch. Set them before an interactive session begins. They control the model used, the execution mode, output format, and the scope of files Claude Code can access.

These flags are set at the command line when you invoke claude. You can combine multiple flags in one command.

  • --model [model-name]: Specifies which Claude model to use. Default is Claude Sonnet. Use claude-opus-4-5 for maximum capability or claude-haiku-4-5 for speed.
  • --plan: Starts the session in plan mode. Claude Code proposes a plan and waits for your approval before taking any action.
  • --print / -p: Runs Claude Code non-interactively. Sends the prompt, prints output to stdout, and exits. Covered in detail in the headless flags section.
  • --output-format [format]: Used with --print. Formats output as text (default), json, or stream-json for real-time pipeline processing.
  • --max-turns [n]: Limits the number of agentic turns before Claude Code pauses for input. Prevents runaway execution on complex tasks.
  • --no-stream: Disables streaming output. Claude Code waits until the full response is ready before printing. Useful when piping output to another command.
  • --verbose: Shows full tool call details during execution. Use this when debugging unexpected file changes or actions.
  • --add-dir [path]: Adds an additional directory to the working context. Useful for monorepos where the project spans multiple folders.

 

What Keyboard Shortcuts Work in an Interactive Session?

Seven keyboard shortcuts control an active Claude Code session without typing commands. The three most important are Shift+Tab for plan mode, Ctrl+C to cancel execution, and Ctrl+R to search session history.

These shortcuts work from within any active interactive session. None of them require restarting.

  • Shift+Tab: Toggles plan mode on and off. The most important shortcut for controlling whether Claude Code acts or proposes before acting.
  • Ctrl+C: Cancels the current task mid-execution. It stops the current action but does not exit the session or revert completed steps.
  • Ctrl+R: Searches through command history for the current session. Re-run or modify a previous prompt without retyping it.
  • Ctrl+L: Clears the terminal display without clearing conversation context. Session memory is preserved even though the screen is cleared.
  • Ctrl+D: Exits the Claude Code session cleanly. Use this instead of closing the terminal window to ensure session state is written correctly.
  • Up/Down arrow keys: Navigate through previous inputs in the current session. Same behaviour as standard shell history navigation.
  • Escape: Cancels the current input line without submitting. Clears what you have typed so you can start the prompt again.

 

What Slash Commands Are Available Inside a Session?

Slash commands run inside an active Claude Code session without restarting. The most-used are /clear to reset conversation context, /undo to revert the last file change, and /compact to extend session length.

Type any slash command at the prompt during a live session. They take effect immediately.

  • /help: Displays all available slash commands with descriptions. Run this in any new session to see what is available.
  • /clear: Clears the current conversation context. Claude Code starts fresh in the same session. Use when long sessions produce degraded output.
  • /undo: Reverts the most recent file change Claude Code made. Works only for the immediately preceding action. For multi-step rollback, use git.
  • /compact: Compresses conversation history and replaces the full context with a summary. Extends how long a session runs before hitting context limits.
  • /plan: Toggles plan mode on. Same effect as pressing Shift+Tab.
  • /logout: Clears the stored authentication token. Use when switching accounts or when an auth token has expired.
  • /exit or /quit: Closes the Claude Code session cleanly.

For the complete slash command reference including less-common commands and argument syntax, the full slash commands reference covers every available command.

 

How Do Plan Mode and Auto Mode Work From the CLI?

Plan mode makes Claude Code propose a plan and wait for approval before acting. Auto mode executes immediately without a plan step. Plan mode is set with --plan at startup or toggled mid-session. Auto mode is the default.

You can switch between them in the same session without restarting.

  • Plan mode activation: Use --plan at startup, Shift+Tab mid-session, or /plan inside the session. All three toggle the same behaviour.
  • Auto mode is the default: Without --plan, Claude Code executes immediately. Best for well-understood tasks, scripted workflows, and CI/CD use.
  • Switching mid-session: Shift+Tab toggles between plan and auto within the current session. No restart required.
  • --max-turns as an auto-mode safety control: Set --max-turns 5 when running auto mode on unfamiliar or higher-risk tasks to limit autonomous steps.
  • When to use each: Plan mode for first sessions on unfamiliar codebases, destructive operations, and tasks touching multiple files. Auto mode for everything else.

For a deeper treatment of when plan mode prevents mistakes and the specific use cases that justify it, the plan mode vs auto mode breakdown covers the decision in full.

 

What Flags Are Used for Headless and Non-Interactive Mode?

--print (or -p) is the core headless flag. It runs Claude Code with a prompt, outputs to stdout, and exits. No interactive session. This is the foundation for all CI/CD automation and scripted workflows.

Headless mode requires the ANTHROPIC_API_KEY environment variable to be set before the command runs.

  • --print / -p: Core headless flag. Example: claude -p "review this file for bugs" --output-format json.
  • --output-format: Used with --print. Options are text (plain output), json (structured response object), and stream-json (streaming JSON events).
  • ANTHROPIC_API_KEY: Required for headless mode. Inject as a CI secret in GitHub Actions and equivalent systems.
  • --dangerously-skip-permissions: Bypasses permission prompts for fully unattended CI runs. Use only in isolated containers or controlled environments. For full guidance on when to use this and safer alternatives, see the skip-permissions flag guide.
  • GitHub Actions and Docker setup: For a complete setup guide including environment variable injection patterns, the running Claude Code in CI/CD guide covers all headless deployment scenarios.
  • End-to-end pipeline integration: For PR review automation, test generation workflows, and full pipeline configuration, the CI/CD pipeline setup guide covers the complete integration.

 

How Do CLAUDE.md and Context Commands Work?

CLAUDE.md is placed in the project root and read automatically at session start. No flag needed. It is the primary mechanism for giving Claude Code persistent project context that applies across every session.

CLAUDE.md rules persist across sessions. In-session context commands like /clear and /compact affect only the current conversation.

  • CLAUDE.md placement: Place the file in the project root. Claude Code reads it automatically on every session start. No flag or command required.
  • /clear: Clears conversation context without affecting CLAUDE.md. Use when a long session produces degraded output due to context overload.
  • /compact: Compresses conversation history to extend session length. CLAUDE.md content is not affected by this command.
  • --add-dir: Adds a second directory to the working context at startup. Useful when your project references shared libraries outside the main folder.
  • Nested CLAUDE.md files: A CLAUDE.md in a subdirectory adds context specific to that folder. Claude Code reads both the root and subdirectory CLAUDE.md when working in that subdirectory.

For CLAUDE.md structure, what to include, and how to use it effectively across large codebases and teams, the CLAUDE.md complete guide covers all patterns.

 

Conclusion

Claude Code CLI commands group into five categories: startup flags, keyboard shortcuts, slash commands, context commands, and headless flags.

Mastering the 10-12 most-used commands from each category covers the majority of real-world sessions. The rest are available when you need them.

 

AI App Development

Your Business. Powered by AI

We build AI-driven apps that don’t just solve problems—they transform how people experience your product.

 

 

Want to Put These Commands to Work on a Real Development Problem?

Knowing the commands is step one. The harder question is how to combine them into a structured workflow that produces consistent results across a development team.

At LowCode Agency, we are a strategic product team, not a dev shop. We help teams move from individual CLI use to production-level Claude Code workflows, including CI/CD integration and agentic pipelines built on the commands in this guide.

  • Workflow design: We structure Claude Code commands and flags into repeatable development workflows that work consistently across your team.
  • CI/CD integration: We configure headless mode, environment variable injection, and pipeline triggers so Claude Code runs reliably in your automated systems.
  • CLAUDE.md setup: We write your project-level configuration so every session starts with the right context, constraints, and oversight rules already in place.
  • Plan mode rollout: We configure plan mode defaults and team conventions so your developers use the right execution mode for the right tasks by habit.
  • Subagent orchestration: We design orchestrator prompts and permission models for teams running Claude Code on complex multi-workstream tasks.
  • Permission and safety configuration: We set tool restrictions and approval gates appropriate for your codebase, team size, and risk tolerance.
  • Full product team: Strategy, UX, development, and QA from a single team that treats Claude Code as a production-grade tool, not a developer toy.

We have built 350+ products for clients including Coca-Cola, American Express, and Medtronic.

If you want Claude Code working at a production level across your team, talk to our team.

Last updated on 

April 10, 2026

.

Jesus Vargas

Jesus Vargas

 - 

Founder

Jesus is a visionary entrepreneur and tech expert. After nearly a decade working in web development, he founded LowCode Agency to help businesses optimize their operations through custom software solutions. 

Custom Automation Solutions

Save Hours Every Week

We automate your daily operations, save you 100+ hours a month, and position your business to scale effortlessly.

FAQs

What is the Claude Code CLI used for?

How do I start a new project using Claude Code CLI?

Are there shortcuts to speed up common tasks in Claude Code CLI?

Can I customize commands or shortcuts in Claude Code CLI?

What are common errors when using Claude Code CLI and how to fix them?

Is Claude Code CLI compatible with all operating systems?

Watch the full conversation between Jesus Vargas and Kristin Kenzie

Honest talk on no-code myths, AI realities, pricing mistakes, and what 330+ apps taught us.
We’re making this video available to our close network first! Drop your email and see it instantly.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Why customers trust us for no-code development

Expertise
We’ve built 330+ amazing projects with no-code.
Process
Our process-oriented approach ensures a stress-free experience.
Support
With a 30+ strong team, we’ll support your business growth.