Vibecosystem cli-reference
Claude Code CLI commands, flags, headless mode, and automation patterns
install
source · Clone the upstream repo
git clone https://github.com/vibeeval/vibecosystem
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/vibeeval/vibecosystem "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/cli-reference" ~/.claude/skills/vibeeval-vibecosystem-cli-reference && rm -rf "$T"
manifest:
skills/cli-reference/SKILL.mdsource content
CLI Reference
Complete reference for Claude Code command-line interface.
When to Use
- "What CLI flags are available?"
- "How do I use headless mode?"
- "Claude in automation/CI/CD"
- "Output format options"
- "System prompt via CLI"
- "How do I spawn agents properly?"
Core Commands
| Command | Description | Example |
|---|---|---|
| Start interactive REPL | |
| REPL with initial prompt | |
| Headless mode (SDK) | |
| Process piped content | |
| Continue most recent | |
| Continue via SDK | |
| Resume session | |
| Update version | |
| Configure MCP servers | See MCP docs |
Session Control
| Flag | Description | Example |
|---|---|---|
| Load most recent conversation | |
| Resume session by ID/name | |
| Use specific UUID | |
| Create new session on resume | |
Headless Mode (Critical for Agents)
| Flag | Description | Example |
|---|---|---|
| Non-interactive, exit after | |
| , , | |
| Limit agentic turns | |
| Full turn-by-turn output | |
| Skip permission prompts | |
| Include streaming events | |
| Input format (text/stream-json) | |
Tool Control
| Flag | Description | Example |
|---|---|---|
| Auto-approve these tools | |
| Block these tools | |
| Only allow these tools | |
Subagent Definition (--agents flag)
Define custom subagents inline via JSON:
claude --agents '{ "code-reviewer": { "description": "Expert code reviewer. Use proactively after code changes.", "prompt": "You are a senior code reviewer. Focus on code quality and security.", "tools": ["Read", "Grep", "Glob", "Bash"], "model": "sonnet" }, "debugger": { "description": "Debugging specialist for errors and test failures.", "prompt": "You are an expert debugger. Analyze errors and provide fixes." } }'
Agent Fields
| Field | Required | Description |
|---|---|---|
| Yes | When to invoke this agent |
| Yes | System prompt for behavior |
| No | Allowed tools (inherits all if omitted) |
| No | , , or |
Key Insight
When Lead uses Task tool, it auto-spawns from these definitions. No manual spawn needed.
System Prompt Customization
| Flag | Behavior | Modes |
|---|---|---|
| Replace entire prompt | Interactive + Print |
| Replace from file | Print only |
| Append to default (recommended) | Interactive + Print |
Use
for most cases - preserves Claude Code capabilities.--append-system-prompt
Model Selection
| Flag | Description | Example |
|---|---|---|
| Set model for session | |
| Fallback if default overloaded | |
Aliases:
sonnet, opus, haiku
MCP Configuration
| Flag | Description | Example |
|---|---|---|
| Load MCP servers from JSON | |
| Only use these MCP servers | |
Advanced Flags
| Flag | Description | Example |
|---|---|---|
| Add working directories | |
| Specify agent for session | |
| Start in permission mode | |
| MCP tool for permissions | |
| Load plugins from directory | |
| Load settings from file/JSON | |
| Which settings to load | |
| Beta API headers | |
| Enable debug mode | |
| Auto-connect to IDE | |
| Enable Chrome integration | |
| Disable Chrome for session | |
| Verbose LSP debugging | |
| Output version | |
Output Formats
JSON (for parsing)
claude -p "query" --output-format json # {"result": "...", "session_id": "...", "usage": {...}}
Streaming (for real-time monitoring)
claude -p "query" --output-format stream-json # Newline-delimited JSON events
Structured Output (schema validation)
claude -p "Extract data" \ --output-format json \ --json-schema '{"type":"object","properties":{...}}'
Headless Agent Pattern (CRITICAL)
Proper headless agent spawn:
claude -p "$TASK_PROMPT" \ --session-id "$UUID" \ --dangerously-skip-permissions \ --max-turns 100 \ --output-format stream-json \ --agents '{...}' \ --append-system-prompt "Context: ..."
Missing any of these causes hangs:
- Track the session--session-id
- Headless requires this--dangerously-skip-permissions
- Prevents infinite loops--max-turns
Common Patterns
CI/CD Automation
claude -p "Run tests and fix failures" \ --dangerously-skip-permissions \ --max-turns 50 \ --output-format json | jq '.result'
Piped Input
cat error.log | claude -p "Find root cause" gh pr diff | claude -p "Review for security"
Multi-turn Session
id=$(claude -p "Start task" --output-format json | jq -r '.session_id') claude -p "Continue" --resume "$id"
Stream Monitoring
claude -p "Long task" \ --output-format stream-json \ --include-partial-messages | while read -r line; do echo "$line" | jq '.type' done
Keyboard Shortcuts (Interactive)
| Shortcut | Action |
|---|---|
| Cancel current |
| Exit |
| Reverse search history |
| Rewind changes |
| Toggle permission mode |
Quick Commands
| Prefix | Action |
|---|---|
| Slash command |
| Bash mode |
| Add to memory |
| File mention |