Skip to main content

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:
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:
You can also pipe input from stdin:

Positional Arguments

Provide a prompt as positional arguments for one-shot execution:
Use --prompt-interactive to execute a prompt and continue in interactive mode:

Available Commands

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

/auth

Configure authentication settings

/help

Display help information

/clear

Clear conversation history

/compress

Compress conversation context

/model

Switch the active model

/stats

View session statistics

/bug

Submit a bug report

Command-Line Options

Configure Qwen Code behavior with command-line flags:

--prompt

Execute a prompt in non-interactive mode

--model

Specify the AI model to use

--yolo

Auto-approve all actions

--plan

Plan-only mode without execution

--resume

Resume a previous session

--session-id

Specify a custom session ID

Output Formats

Qwen Code supports multiple output formats for different use cases:

Text Format (Default)

Human-readable output suitable for terminal usage:

JSON Format

Structured output for programmatic consumption:

Stream JSON Format

Real-time streaming output with JSON events:

Input Formats

Control how Qwen Code processes input:
  • text: Standard text input (default)
  • stream-json: JSON-formatted streaming input for programmatic control

Session Management

Starting a New Session

Each invocation creates a new session by default:

Resuming Sessions

Resume the most recent session:
Resume a specific session by ID:
Show session picker:

Custom Session ID

Specify a custom session ID:

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

Examples

Code Generation

Code Review

Automated Testing

CI/CD Integration

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 guide for details.

Getting Help

View all available options:
Access help within interactive mode:
Submit bug reports:

Next Steps

Authentication

Set up API keys and OAuth

Configuration

Customize Qwen Code settings

Features

Explore powerful features

IDE Integration

Use Qwen Code in your editor