CLI Cheatsheet

March 5, 2026 · View on GitHub

Every CLI flag and keyboard shortcut organized by workflow.

Startup Flags

Session Management

claude                       # New session
claude --continue            # Continue last session
claude --resume              # Pick from recent sessions
claude --from-pr 123         # Start from a PR's context
claude --session-id <id>     # Resume specific session
claude --fork-session <id>   # Fork an existing session

System Prompt

claude --system-prompt "You are a Go expert"
claude --system-prompt-file ./prompts/go.md
claude --append-system-prompt "Also run tests after changes"

Agent & Subagent Control

claude --agent researcher        # Run with specific agent
claude --agents '{"name":"researcher","tools":["Read","Grep"]}'
claude --teammate-mode           # Launch as a teammate in agent teams

Permission Control

claude --permission-mode plan    # Force plan mode
claude --allowedTools Read,Grep  # Whitelist specific tools
claude --disallowedTools Bash    # Blacklist tools

Output & Scripting

claude --print "explain this code"      # One-shot, no interactive
claude --output-format json             # JSON output for scripting
claude --json-schema '{"type":"object"}'  # Structured output
claude --verbose                        # Debug output

Budget & Limits

claude --max-budget-usd 5.00    # Cap spending
claude --max-turns 50           # Limit conversation turns

Workspace

claude --worktree        # or -w: auto-create git worktree
claude --add-dir ../lib  # Add extra directory to context

MCP & Plugins

claude --mcp-config ./mcp.json     # Load MCP config
claude --strict-mcp-config         # Fail if MCP server errors
claude --plugin-dir ./my-plugin    # Load a plugin directory

Integration

claude --chrome           # Enable Chrome integration
claude --no-chrome        # Disable Chrome integration
claude --ide vscode       # Set IDE context

Keyboard Shortcuts

During Prompting

KeyAction
EnterSubmit prompt
Shift+TabCycle modes (Normal > Auto > Plan)
Ctrl+CCancel current generation
Ctrl+LClear screen
Ctrl+BSend current task to background
Ctrl+FKill all background agents (two-press)
Up/DownNavigate prompt history
Esc EscRewind to last checkpoint

Agent Teams

KeyAction
Shift+DownNavigate between teammates (wraps)
Shift+TabToggle delegate mode

Slash Commands

Session

CommandPurpose
/clearReset conversation
/compactCompress context (do at task boundaries)
/contextShow context window usage
/resumeResume a previous session
/renameRename current session
/costShow session cost (API key users)
/usageCheck plan limits
/extra-usagePay-as-you-go overflow billing

Modes & Models

CommandPurpose
/modelSwitch model or effort level
/fastToggle fast mode
/voiceToggle voice mode (hold spacebar to talk)

Project

CommandPurpose
/permissionsManage tool permissions
/agentsCreate and manage subagents
/memoryView/edit auto memory
/doctorDiagnose configuration issues

Configuration

CommandPurpose
/configOpen settings
/terminal-setupConfigure terminal
/statuslineCustomize status bar
/keybindingsCustomize keyboard shortcuts
/sandboxConfigure sandboxing
/vimToggle vim keybindings

Export & Debug

CommandPurpose
/exportExport conversation
/debugToggle debug mode
/rewindRewind to checkpoint

Scripting Patterns

One-Shot Execution

echo "explain this error" | claude --print

Capture Session ID

SESSION_ID=$(claude --output-format json --print "fix the bug" | jq -r '.session_id')
claude --session-id "$SESSION_ID" --print "now add tests"

Budget-Controlled CI

claude --max-budget-usd 2.00 --max-turns 20 --print "review this PR"

Pro Tips

  • ultrathink in your prompt triggers maximum reasoning effort
  • /doctor diagnoses config issues — run when things feel off
  • Manual /compact at 50% prevents the "agent dumb zone" near capacity
  • /rename your sessions — easier to find with /resume later
  • claude -w is faster than manually creating worktrees
  • Voice mode (/voice) — hold spacebar, speak, release to transcribe