Skip to content

CLI Reference

Usage

q [query] [options]

Arguments

ArgumentDescription
queryThe question or prompt (optional in interactive mode)

Options

OptionAliasDescription
--interactive-iOpen interactive TUI mode
--execute-xEnable agent tools (Read, Glob, Grep, Bash, Write, Edit)
--dry-runShow tools without executing (use with -x)
--resume <id>-rResume a previous session ("last" for most recent)
--continue-cContinue last session (shortcut for -r last)
--model <model>-mModel to use: sonnet, opus, haiku
--file <path>-fInclude file(s) as context (can be repeated)
--quiet-qMinimal output (response only)
--verbose-vShow token/cost stats
--stream-sEnable streaming (default: true, use --no-stream to disable)
--rawRaw output without markdown formatting
--jsonOutput response as JSON
--sessionsList recent sessions
--no-configSkip loading config files (security)
--color <mode>Color mode: auto, always, never
--shell-initOutput shell integration script (bash, zsh, fish)
--versionShow version number
--helpShow help

Shell Integration

Output shell integration scripts for your shell:

bash
# Add to your shell config
eval "$(q --shell-init zsh)"   # For Zsh
eval "$(q --shell-init bash)"  # For Bash
q --shell-init fish | source   # For Fish

This provides commands like qq, qctx, qerr, qx, qr and the Ctrl+Q hotkey. See Shell Integration for details.

Examples

Quick Query

bash
q "what does this error mean"
q "how do I rebase onto main"

Pipe Mode

bash
cat error.log | q "explain this"
git diff | q "summarize these changes"
pbpaste | q "review this code"

Pipe Mode Behavior When stdout is piped, q automatically enables --quiet, --raw, and

--color never for clean machine-readable output. :::

Interactive Mode

bash
q          # Opens TUI
q -i       # Explicit flag

Execute Mode

bash
q -x "find all TODO comments"
q --execute "run tests and fix failures"

Tool Availability Execute mode enables: Read, Glob, Grep (auto-approved), plus

Bash, Write, Edit (require approval). :::

Resume Session

bash
q -c           # Continue last session
q -r last      # Equivalent to -c
q -r abc123    # Resume specific session

Dry Run

bash
q -x --dry-run "refactor this"  # See what tools would run

Include Files

bash
q -f src/app.ts "explain this"
q -f src/*.ts "review these files"

Output Formats

bash
q --json "query"       # JSON output
q --raw "query"        # No markdown formatting
q -q "query"           # Minimal output
q --no-stream "query"  # Wait for complete response

Model Selection

bash
q -m opus "complex question"    # Most capable
q -m sonnet "general question"  # Balanced (default)
q -m haiku "quick question"     # Fastest, cheapest

Exit Codes

CodeMeaning
0Success
1Error (invalid args, API error, etc.)
130Interrupted (Ctrl+C)

Environment Variables

VariableDescription
ANTHROPIC_API_KEYYour Anthropic API key (required)
NO_COLORDisable colors when set to any value
DEBUGEnable debug output when set to 1
Q_QUIETSuppress shell integration init message

Released under the Apache-2.0 License.