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:Headless Mode
Use the--prompt flag to run Qwen Code in non-interactive mode:
Positional Arguments
Provide a prompt as positional arguments for one-shot execution:--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: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 reconfigurationNO_COLOR: Disable colored outputDEBUG: Enable debug loggingSANDBOX: 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
Getting Help
View all available options: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
