Skip to content

Core CLI Usage

Terminal window
# Interactive mode (default)
claude
# One-shot mode — exits after task completes
claude -p "write a hello world function"
# Pipe mode — reads from stdin
cat app.log | claude -p "analyze this error"
git diff | claude -p "review these changes"
Terminal window
claude --resume # pick from session list (or --resume <name>)
claude --continue # resume the most recent session here
claude -n auth-refactor # start a named session
claude --continue --fork-session # branch off the last session
claude --from-pr 142 # resume the session that created PR #142
claude --teleport # pull a web/mobile session into this terminal

Details: 08-sessions-and-checkpointing.md

Terminal window
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/cheap
claude --model opusplan # Opus plans, Sonnet executes
claude --effort high # more reasoning (low/medium/high)
Terminal window
claude --verbose # show full tool inputs/outputs
claude --output-format json # full JSON at end
claude --output-format stream-json # streaming JSON
claude --output-format md # markdown only (no UI)
Terminal window
claude --permission-mode plan # read-only / plan mode
claude --permission-mode acceptEdits # auto-approve file edits
claude --dangerously-skip-permissions # skip all prompts (sandboxes/containers only!)
claude --allowedTools "Bash(npm *),Read,Edit"
claude --disallowedTools "Bash(rm *),Bash(sudo *)"
Terminal window
claude --max-turns 10 # max interactions before exit
claude --add-dir /another/path # grant access to additional directory
claude --no-files-in-context # don't load project files at start
claude --cwd /path/to/project # set working directory
Terminal window
# Replace the system prompt entirely
claude --system-prompt "You are a security auditor. Find vulnerabilities."
# Append to the default system prompt
claude --append-system-prompt "Always use pnpm, not npm."
Terminal window
claude --chrome # browser automation (see 39-slack-chrome-channels.md)
claude --channels plugin:telegram@claude-plugins-official # push events in
claude --teammate-mode auto # agent team display mode
claude mcp list # manage MCP servers from the shell
claude update # update Claude Code
claude doctor # diagnostics
Terminal window
# Fix lint errors non-interactively
claude -p "fix all lint errors" --permissions acceptEdits
# Analyze logs
tail -100 app.log | claude -p "what went wrong?"
# Review a PR diff
git diff main | claude -p "code review" --output-format md
# Generate JSON list
claude -p "list all exported functions in src/" --output-format json | jq '.[]'
  • Trick:p prints, c continues, r resumes, n names.”
  • Pipes work both ways: logs in → insight out.
  • 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