Core CLI Usage
Session Modes
Section titled “Session Modes”# Interactive mode (default)claude
# One-shot mode — exits after task completesclaude -p "write a hello world function"
# Pipe mode — reads from stdincat app.log | claude -p "analyze this error"git diff | claude -p "review these changes"Sessions
Section titled “Sessions”claude --resume # pick from session list (or --resume <name>)claude --continue # resume the most recent session hereclaude -n auth-refactor # start a named sessionclaude --continue --fork-session # branch off the last sessionclaude --from-pr 142 # resume the session that created PR #142claude --teleport # pull a web/mobile session into this terminalDetails: 08-sessions-and-checkpointing.md
Key Flags
Section titled “Key Flags”Model & Reasoning
Section titled “Model & Reasoning”claude --model fable # most capable (Fable 5)claude --model opus # complex reasoning (Opus 4.8)claude --model sonnet # daily coding (Sonnet 5)claude --model haiku # fast/cheapclaude --model opusplan # Opus plans, Sonnet executesclaude --effort high # more reasoning (low/medium/high)Output & Logging
Section titled “Output & Logging”claude --verbose # show full tool inputs/outputsclaude --output-format json # full JSON at endclaude --output-format stream-json # streaming JSONclaude --output-format md # markdown only (no UI)Permissions & Safety
Section titled “Permissions & Safety”claude --permission-mode plan # read-only / plan modeclaude --permission-mode acceptEdits # auto-approve file editsclaude --dangerously-skip-permissions # skip all prompts (sandboxes/containers only!)claude --allowedTools "Bash(npm *),Read,Edit"claude --disallowedTools "Bash(rm *),Bash(sudo *)"Context & Scope
Section titled “Context & Scope”claude --max-turns 10 # max interactions before exitclaude --add-dir /another/path # grant access to additional directoryclaude --no-files-in-context # don't load project files at startclaude --cwd /path/to/project # set working directorySystem Prompt Customization
Section titled “System Prompt Customization”# Replace the system prompt entirelyclaude --system-prompt "You are a security auditor. Find vulnerabilities."
# Append to the default system promptclaude --append-system-prompt "Always use pnpm, not npm."Integrations
Section titled “Integrations”claude --chrome # browser automation (see 39-slack-chrome-channels.md)claude --channels plugin:telegram@claude-plugins-official # push events inclaude --teammate-mode auto # agent team display modeclaude mcp list # manage MCP servers from the shellclaude update # update Claude Codeclaude doctor # diagnosticsCommon One-Liners
Section titled “Common One-Liners”# Fix lint errors non-interactivelyclaude -p "fix all lint errors" --permissions acceptEdits
# Analyze logstail -100 app.log | claude -p "what went wrong?"
# Review a PR diffgit diff main | claude -p "code review" --output-format md
# Generate JSON listclaude -p "list all exported functions in src/" --output-format json | jq '.[]'🧠 Quick Recall
Section titled “🧠 Quick Recall”- Trick: “p prints, c continues, r resumes, n names.”
- Pipes work both ways: logs in → insight out.
👨🏫 Teach It
Section titled “👨🏫 Teach It”- Show:
git diff | claude -p "review this"— one line, real value. - They’ll trip on: flag names — it’s
--permission-mode, and bypass is--dangerously-skip-permissions.
Learning path: ⬅ 02-quickstart-first-session.md · Index · ➡ 04-slash-commands.md
Written by Fenil Patel