> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/QwenLM/qwen-code/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI Overview

> Comprehensive guide to Qwen Code CLI commands and options

## Introduction

Qwen Code is an AI-powered coding assistant that runs directly in your terminal. The CLI supports both interactive and headless modes, making it suitable for development workflows, automation, and CI/CD pipelines.

## Basic Usage

### Interactive Mode

Launch Qwen Code in interactive mode for a conversational coding experience:

```bash theme={null}
qwen
```

This opens an interactive terminal interface where you can chat with the AI, execute commands, and work on your code.

### Headless Mode

Use the `--prompt` flag to run Qwen Code in non-interactive mode:

```bash theme={null}
qwen --prompt "Create a Python function to calculate fibonacci numbers"
```

You can also pipe input from stdin:

```bash theme={null}
echo "Explain this code" | qwen --prompt
```

### Positional Arguments

Provide a prompt as positional arguments for one-shot execution:

```bash theme={null}
qwen "Write unit tests for my authentication module"
```

Use `--prompt-interactive` to execute a prompt and continue in interactive mode:

```bash theme={null}
qwen --prompt-interactive "Setup a React project with TypeScript"
```

## Available Commands

Qwen Code provides slash commands that you can use within interactive mode or with the `--prompt` flag:

<CardGroup cols={2}>
  <Card title="/auth" icon="key" href="/cli/auth">
    Configure authentication settings
  </Card>

  <Card title="/help" icon="circle-question" href="/cli/help">
    Display help information
  </Card>

  <Card title="/clear" icon="broom" href="/cli/clear">
    Clear conversation history
  </Card>

  <Card title="/compress" icon="compress" href="/cli/compress">
    Compress conversation context
  </Card>

  <Card title="/model" icon="brain" href="/cli/model">
    Switch the active model
  </Card>

  <Card title="/stats" icon="chart-simple" href="/cli/stats">
    View session statistics
  </Card>

  <Card title="/bug" icon="bug" href="/cli/bug">
    Submit a bug report
  </Card>
</CardGroup>

## Command-Line Options

Configure Qwen Code behavior with command-line flags:

<CardGroup cols={2}>
  <Card title="--prompt" icon="message" href="/cli/options/prompt">
    Execute a prompt in non-interactive mode
  </Card>

  <Card title="--model" icon="microchip" href="/cli/options/model">
    Specify the AI model to use
  </Card>

  <Card title="--yolo" icon="forward-fast" href="/cli/options/yolo">
    Auto-approve all actions
  </Card>

  <Card title="--plan" icon="list-check" href="/cli/options/plan">
    Plan-only mode without execution
  </Card>

  <Card title="--resume" icon="clock-rotate-left" href="/cli/options/resume">
    Resume a previous session
  </Card>

  <Card title="--session-id" icon="fingerprint" href="/cli/options/session-id">
    Specify a custom session ID
  </Card>
</CardGroup>

## Output Formats

Qwen Code supports multiple output formats for different use cases:

### Text Format (Default)

Human-readable output suitable for terminal usage:

```bash theme={null}
qwen --prompt "Hello"
```

### JSON Format

Structured output for programmatic consumption:

```bash theme={null}
qwen --prompt "Analyze this code" --output-format json
```

### Stream JSON Format

Real-time streaming output with JSON events:

```bash theme={null}
qwen --prompt "Generate a report" --output-format stream-json
```

## Input Formats

Control how Qwen Code processes input:

* **text**: Standard text input (default)
* **stream-json**: JSON-formatted streaming input for programmatic control

```bash theme={null}
qwen --input-format stream-json
```

## Session Management

### Starting a New Session

Each invocation creates a new session by default:

```bash theme={null}
qwen
```

### Resuming Sessions

Resume the most recent session:

```bash theme={null}
qwen --continue
```

Resume a specific session by ID:

```bash theme={null}
qwen --resume <session-id>
```

Show session picker:

```bash theme={null}
qwen --resume
```

### Custom Session ID

Specify a custom session ID:

```bash theme={null}
qwen --session-id my-custom-session
```

## Approval Modes

Control how Qwen Code handles tool execution:

* **default**: Prompt for approval before executing tools
* **yolo**: Auto-approve all tool executions
* **plan**: Generate plans without executing
* **auto-edit**: Auto-approve edit operations only

```bash theme={null}
qwen --approval-mode yolo
```

## Examples

### Code Generation

```bash theme={null}
qwen --prompt "Create a REST API with Express.js"
```

### Code Review

```bash theme={null}
git diff | qwen --prompt "Review these changes"
```

### Automated Testing

```bash theme={null}
qwen --yolo --prompt "Add unit tests to all functions in src/"
```

### CI/CD Integration

```bash theme={null}
qwen --prompt "Run linter and fix all issues" --output-format json
```

## Environment Variables

Configure Qwen Code using environment variables:

* `QWEN_CODE_NO_RELAUNCH`: Disable automatic memory reconfiguration
* `NO_COLOR`: Disable colored output
* `DEBUG`: Enable debug logging
* `SANDBOX`: Indicates running inside sandbox

## Configuration Files

Qwen Code reads configuration from:

* Global settings: `~/.qwen/settings.json`
* Project settings: `.qwen/settings.json`
* Project config: `.qwen.config.js`

See the [Configuration](/configuration/settings) guide for details.

## Getting Help

View all available options:

```bash theme={null}
qwen --help
```

Access help within interactive mode:

```bash theme={null}
/help
```

Submit bug reports:

```bash theme={null}
/bug "Description of the issue"
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Authentication" icon="key" href="/authentication">
    Set up API keys and OAuth
  </Card>

  <Card title="Configuration" icon="gear" href="/configuration/settings">
    Customize Qwen Code settings
  </Card>

  <Card title="Features" icon="sparkles" href="/features/interactive-mode">
    Explore powerful features
  </Card>

  <Card title="IDE Integration" icon="window" href="/ide-integration/overview">
    Use Qwen Code in your editor
  </Card>
</CardGroup>
