Skip to content
InnovateTechie
Claude Code

Claude Code CLI Documentation: Commands, Flags & Config

InnovateTechieBy InnovateTechie10 min read
Share
Claude Code CLI Documentation: Commands, Flags & Config

Part ofWhat Is Claude Code? The Complete Guide

Claude Code CLI documentation in one page: install, core commands, flags, slash commands, settings.json hierarchy and a practical cheatsheet.

The Claude Code CLI documentation covers a single tool: claude, Anthropic's agentic coding agent that lives in your terminal. You launch it by typing claude, steer each run with flags like --model and --permission-mode, and drive a live session with slash commands such as /init and /compact. Installing it needs no admin rights.

We build and maintain this site with Claude Code every day, and the questions we field most are never conceptual — they're "what's the flag for that again?" This Claude Code CLI documentation is the crib sheet we wish we'd had: the commands, flags, slash commands, and configuration that actually come up in daily work, cross-checked against the official CLI reference. New to the tool itself? Start with our pillar, What Is Claude Code?, then keep this open in a second tab.

What the Claude Code CLI is

Claude Code is a command-line agent, not a chat box bolted onto an editor. You run claude inside a project, and it reads your files, edits them, runs shell commands, and handles git through plain-English requests — pausing to ask permission before anything destructive. There's no separate GUI to learn; the terminal is the interface. The whole of the Claude Code CLI documentation fits that shape: a few commands to start and manage sessions, a set of flags that tune each run, and slash commands you type mid-conversation.

Install Claude Code (Node.js optional)

Installation is one line and needs no administrator rights. Pick the method that matches your shell:

  • macOS, Linux, WSL: curl -fsSL https://claude.ai/install.sh | bash
  • Windows PowerShell: irm https://claude.ai/install.ps1 | iex
  • npm (any OS): npm install -g @anthropic-ai/claude-code

The native installer bundles its own runtime, so it needs no Node.js at all — only the npm route requires Node.js 18 or later. On native Windows, install Git for Windows so Claude Code can use its Bash tool; without it, the agent falls back to PowerShell. The system requirements are modest: Windows 10 (1809+), macOS 13+, or a mainstream Linux, 4GB of RAM, and an internet connection, per Anthropic's setup guide. Confirm the install with claude --version, and run claude doctor if anything looks off.

On first launch, claude opens your browser to sign in. You can also manage authentication from the shell: claude auth login signs in or switches accounts, claude auth status reports whether you're logged in, and claude auth logout clears stored credentials.

Claude Code CLI install and first-run authentication flow across Windows, macOS, and Linux terminals

Core Claude Code commands

Most of the Claude Code CLI documentation you'll ever need reduces to a dozen commands. These are the ones we type without thinking:

CommandWhat it does
claudeStart an interactive session in the current directory
claude "query"Launch straight into a first prompt
claude -p "query"Headless (print) mode: answer, then exit — for scripts and pipes
claude -cContinue the most recent conversation here
claude -r "<id>"Resume a session by ID or name
claude updateUpdate to the latest version
claude mcpAdd and manage MCP servers
claude doctorDiagnose installation and config problems
claude auth loginSign in or switch Anthropic accounts

Two of these do the heavy lifting. claude -c picks up yesterday's thread without re-explaining anything, and claude -p turns the agent into a Unix citizen you can pipe into: cat error.log | claude -p "explain the root cause" prints an answer and exits.

Essential Claude Code flags

Flags modify a single launch. claude --help deliberately doesn't list every one — a flag's absence from --help doesn't mean it's gone — which is exactly why a written reference earns its keep here.

FlagPurpose
--model <alias>Set the model: sonnet, opus, haiku, or a full ID
--permission-mode <mode>Start in plan, acceptEdits, auto, or another mode
--print, -pNon-interactive output for scripts and CI
--output-format <fmt>text, json, or stream-json (print mode)
--continue, -cReload the latest conversation in this directory
--resume, -rResume a specific session, or open the picker
--add-dir <path>Grant read and write access to extra directories
--fallback-model <list>Fail over to another model when the primary is overloaded
--dangerously-skip-permissionsSkip every permission prompt (use with care)
--verboseShow full turn-by-turn output

The --model aliases resolve to the current release — opus to Claude Opus 4.8, sonnet to Claude Sonnet 5, haiku to Claude Haiku 4.5 — so you rarely type a full model ID. When a model is overloaded, --fallback-model sonnet,haiku keeps the run alive by trying each in order. Which model to reach for is its own decision; our Claude models guide breaks down the trade-offs.

Slash commands: driving a live session

Once a session is running, you steer it with slash commands typed at the prompt — the layer of the Claude Code CLI documentation you'll touch most. Type / alone to see every one available to you. These are the essentials:

CommandWhat it does
/initGenerate a starter CLAUDE.md for the project
/clearStart a fresh conversation, keeping project memory
/compactSummarize the conversation to reclaim context
/resumeReturn to an earlier session
/modelSwitch models mid-session
/configOpen settings (theme, model, output style)
/permissionsManage allow, ask, and deny rules
/mcpConnect and authenticate MCP servers
/contextVisualize what's filling the context window
/doctorDiagnose installation and configuration

/init is where every project should start — it writes a CLAUDE.md the agent reads on every future session (more on that file below). For a big change, /plan drops into read-only plan mode, which we cover in depth in Claude Planner. And /skills lists the reusable instruction folders that extend the agent — see Claude Code Skills for building your own.

CLAUDE.md and the config hierarchy

The other half of the Claude Code CLI documentation is configuration — where settings live and which file wins. Start with CLAUDE.md: a plain Markdown file at your project root that Claude Code reads at the top of every session. Your stack, conventions, and rules stay in context automatically. Run /init to generate one, then edit in what matters. It's the single highest-leverage file in the whole setup.

Settings themselves live in settings.json files, and four scopes stack in a fixed order. When two files set the same key, the higher one wins:

  1. Managed — IT-deployed policy (managed-settings.json); cannot be overridden.
  2. Command-line flags--settings, --model, and friends; this run only.
  3. Local.claude/settings.local.json; personal and gitignored.
  4. Project.claude/settings.json; committed and shared with the team.
  5. User~/.claude/settings.json; your defaults across every project.

The pattern we use: commit team conventions to project settings, keep personal keys — a custom model, extra permissions.allow rules — in local settings, and let managed settings enforce whatever security requires.

Claude Code config hierarchy — managed, local, project, and user settings.json precedence order

Permission modes, from plan to bypass

Every session runs in a permission mode, set with --permission-mode at launch or cycled with Shift+Tab mid-session. Six exist:

  • default — asks before each edit or command.
  • acceptEdits — auto-approves file edits, still asks for commands.
  • plan — read-only; researches and proposes, changes nothing.
  • auto — a classifier approves safe actions and asks on risky ones.
  • dontAsk — runs without prompts inside your allowlist.
  • bypassPermissions — skips every check; identical to --dangerously-skip-permissions.

We live in plan mode for anything unfamiliar and auto for well-scoped work. --dangerously-skip-permissions earns its scary name, so we reserve it for throwaway sandboxes where nothing important can break.

Power-user commands worth knowing

A few corners of the Claude Code CLI documentation reward the minute it takes to find them:

  • /rewind rolls both code and conversation back to an earlier checkpoint — the undo button for a run that went sideways.
  • --worktree (-w) starts the session in an isolated git worktree, so a risky change never touches your main checkout.
  • --agents '{...}' defines a custom subagent inline as JSON, with no config file to create.
  • claude --bg "task" launches a background agent and hands your terminal straight back.
  • --append-system-prompt "..." bolts one extra rule onto the default system prompt for a single run.
  • claude setup-token mints a long-lived token for CI, where nobody can sit through a browser login.

Claude Code CLI documentation cheat sheet

Here's the one-screen version — the commands we reach for most, worth pinning next to the terminal. Bookmark the full Claude Code CLI documentation for the long tail.

TaskCommand
Install (Windows)irm https://claude.ai/install.ps1 | iex
Install (macOS/Linux)curl -fsSL https://claude.ai/install.sh | bash
Start a sessionclaude
One-shot / headlessclaude -p "query" --output-format json
Continue last sessionclaude -c
Plan mode from launchclaude --permission-mode plan
Pick a modelclaude --model opus
Generate CLAUDE.md/init
Reclaim context/compact
Diagnose problemsclaude doctor

Keep those ten within reach and you can run most of a working day without touching a menu. Everything else is one / away.

Claude pricing at a glance

PlanPrice
Free$0
Pro$20 / month
Maxfrom $100 / month
APIPay per token

For the full breakdown of every plan, see our how much Claude costs guide.

Frequently Asked Questions

Claude Code CLI is an agentic coding tool that lives in your terminal. You run the claude command inside a project, and it reads your codebase, edits files, runs shell commands, and handles git through plain-English requests — pausing to ask permission before anything destructive, rather than only answering questions like a chat window.

Run the native installer from PowerShell with irm https://claude.ai/install.ps1 | iex, or from CMD, with no administrator rights required. You can also install through npm or inside WSL. Installing Git for Windows is recommended so Claude Code can use its Bash tool instead of falling back to PowerShell.

Not for the native installer — it bundles its own runtime and needs neither Node.js nor npm. Only the npm install method (npm install -g @anthropic-ai/claude-code) requires Node.js 18 or later. For most people the native installer is simpler, and it skips the Node dependency entirely.

The CLI itself is free to install, but it needs a paid Claude subscription — Pro at $20, Max at $100 or $200 a month — or Anthropic API credits to run. Free routes exist by pointing it at local models through Ollama or a free model router, with reduced capability.

The ones you'll use daily: /init generates a CLAUDE.md, /clear resets the conversation, /compact shrinks a long context, /resume returns to an earlier session, /model switches models, and /help prints the full reference. Type / alone at the prompt to browse every command available to you.

Use the --print (-p) flag, for example claude -p "review this file" --output-format json. It answers once and exits, so you can pipe input in and parse structured output in scripts or CI. For unattended runs, set the ANTHROPICAPIKEY environment variable first so no browser login is needed.

The official Claude Code CLI documentation lives at code.claude.com/docs/en/cli-reference, with companion pages for setup, settings, and commands. Inside a running session, type /help for the current command list or / to browse interactively — that list always matches the exact version you have installed.
InnovateTechie

Written by

InnovateTechie

Writing about Claude and the Anthropic toolkit — models, Claude Code, pricing, features, and fixes, in clear, practical, hands-on guides tested by daily use.

View all posts →