Skip to content

SOP-002: CLI Commands Reference

DOCUMENT CONTROL

FieldValue
SOP IDSOP-002
Version1.0
StatusActive

Purpose

Complete reference for Claude Code CLI commands, flags, and invocation patterns.

Command Structure

┌─────────────────────────────────────────────────────────────────────┐
│                      CLI COMMAND STRUCTURE                           │
└─────────────────────────────────────────────────────────────────────┘

    claude [options] [prompt]

    ┌──────────────────────────────────────────────────────────────┐
    │  EXECUTION MODES                                              │
    ├──────────────────────────────────────────────────────────────┤
    │                                                              │
    │  claude                    → Interactive REPL mode           │
    │  claude "prompt"           → One-shot execution              │
    │  claude -p "prompt"        → Print mode (no conversation)    │
    │  echo "x" | claude         → Pipe input                      │
    │                                                              │
    └──────────────────────────────────────────────────────────────┘

Core Commands

Starting Claude Code

bash
# Interactive mode (default)
claude

# With initial prompt
claude "explain this codebase"

# In specific directory
claude --cwd /path/to/project

Resume Previous Session

bash
# Continue last conversation
claude --continue

# Resume specific session
claude --resume <session-id>

Command Line Flags

FlagShortDescription
--help-hShow help information
--version-vDisplay version
--print-pPrint mode (non-interactive)
--continue-cContinue last conversation
--resume-rResume specific session
--cwdSet working directory
--modelSpecify model to use
--max-turnsLimit autonomous turns
--verboseEnable verbose output
┌─────────────────────────────────────────────────────────────────────┐
│                       EXECUTION MODES                                │
├────────────────────────────────┬────────────────────────────────────┤
│        INTERACTIVE             │           PRINT MODE               │
├────────────────────────────────┼────────────────────────────────────┤
│  claude                        │  claude -p "prompt"                │
│                                │                                    │
│  • Full REPL interface         │  • Single response only            │
│  • Conversation memory         │  • No conversation state           │
│  • Tool approvals              │  • Output to stdout                │
│  • Multi-turn dialogue         │  • Good for scripts                │
│  • File watching               │  • Pipeable output                 │
└────────────────────────────────┴────────────────────────────────────┘

Input Methods

Direct Prompt

bash
claude "refactor the auth module"

Piped Input

bash
echo "explain this" | claude

cat error.log | claude "what's wrong?"

git diff | claude "review these changes"

File Input

bash
claude < instructions.txt

Output Control

bash
# Quiet mode (minimal output)
claude -p "generate code" --quiet

# JSON output
claude -p "list files" --output-format json

# Stream to file
claude -p "write docs" > output.md

Session Management

bash
# List recent sessions
claude sessions list

# Resume by ID
claude --resume abc123

# Continue last session
claude --continue

Slash Commands (In-Session)

CommandDescription
/helpShow available commands
/configOpen configuration menu
/clearClear conversation
/compactCompact context
/costShow token usage
/doctorRun diagnostics
/initInitialize CLAUDE.md
/memoryManage memory
/modelSwitch model
/quitExit Claude Code

Keyboard Shortcuts

ShortcutAction
Ctrl+CCancel current operation
Ctrl+DExit Claude Code
EscapeInterrupt generation
TabAutocomplete
Up/DownNavigate history

Configuration Commands

bash
# Open settings menu
claude config

# Set specific option
claude config set <key> <value>

# Get current value
claude config get <key>

Verification Checklist

  • [ ] Understand interactive vs print mode
  • [ ] Know how to continue/resume sessions
  • [ ] Familiar with common flags
  • [ ] Know in-session slash commands

Next Steps

Based on Official Claude Code Documentation