Use claude [options] [command] [prompt], how? here are explanation with examples:
Basic prompt (interactive vs. one-shot)
# Start an interactive session
claude
# Start interactive with an initial prompt
claude "explain the architecture of this project"
# One-shot, print result and exit (non-interactive)
claude -p "what does src/main.py do?"
# Pipe input in
cat error.log | claude -p "summarize these errors"
With options
# Pick a model
claude --model claude-opus-4-8 -p "refactor this function"
# Continue the most recent conversation
claude --continue
claude -c -p "now add tests for that change"
# Resume a specific session by ID
claude --resume 550e8400-e29b-41d4-a716-446655440000
# Skip permission prompts (use with care)
claude --dangerously-skip-permissions -p "run the test suite"
# Control allowed tools
claude --allowedTools "Bash(git log:*)" "Read" -p "summarize recent commits"
# JSON output for scripting
claude -p "list the API endpoints" --output-format json
Using a command (subcommands)
# Set up / repair your installation
claude doctor
# Update to the latest version
claude update
# Manage MCP servers
claude mcp list
claude mcp add my-server /path/to/server
# Manage config
claude config list
claude config set -g theme dark
Combining options + command + prompt
# One-shot with a session continue + specific model
claude -c --model claude-sonnet-4-6 -p "fix the failing lint errors"
# Resume, restrict tools, output JSON (good for CI/scripts)
claude --resume <session-id> \
--allowedTools "Read" "Bash(npm test:*)" \
--output-format json \
-p "verify the build passes"
Common options quick reference
| Option | Meaning |
|---|---|
-p, --print |
Print response and exit (non-interactive) |
-c, --continue |
Continue the most recent conversation |
--resume <id> |
Resume a specific session |
--model <name> |
Choose the model |
--output-format <fmt> |
text (default), json, or stream-json |
--allowedTools / --disallowedTools |
Whitelist/blacklist tools |
--add-dir <path> |
Grant access to extra directories |
--dangerously-skip-permissions |
Bypass permission prompts |