Before you begin: Make sure you’ve installed Qwen Code.
Start Your First Session
Launch Qwen Code
Open your terminal and navigate to your project directory:On first launch, you’ll be prompted to authenticate. You can choose between:
- Qwen OAuth (recommended): Free tier with 1,000 requests/day
- API Key: Use OpenAI, Anthropic, Gemini, or other compatible providers
Authenticate
Run the auth command to set up your authentication:For Qwen OAuth:
- Select “Qwen OAuth” from the menu
- A browser window will open
- Sign in with your qwen.ai account
- Return to the terminal - you’re ready to go!
- Select “API Key” from the menu
- Choose your provider (OpenAI, Anthropic, Gemini, etc.)
- Enter your API key when prompted
Essential Commands
Learn the key commands to navigate your Qwen Code session./help - Show all available commands
/help - Show all available commands
Display a list of all available commands and their descriptions.
/clear - Clear conversation history
/clear - Clear conversation history
Start a fresh conversation while keeping your configuration.
/model - Switch AI model
/model - Switch AI model
Change to a different model mid-session.Select from your configured models or add a new one.
/stats - View session statistics
/stats - View session statistics
See token usage, costs, and other session metrics.
/exit or /quit - Exit Qwen Code
/exit or /quit - Exit Qwen Code
Save your session and exit the CLI.
Keyboard Shortcuts
Make your workflow faster with these keyboard shortcuts:| Shortcut | Action |
|---|---|
Ctrl+C | Cancel current operation |
Ctrl+D | Exit (on empty line) |
Up/Down | Navigate command history |
Headless Mode
Run Qwen Code in non-interactive mode for scripts and automation:Reference Files
You can reference specific files in your prompts using the@ syntax:
Common Use Cases
Code Explanation
Code Generation
Debugging
Refactoring
Advanced Features
Once you’re comfortable with the basics, explore these powerful features:Approval Modes
Control how Qwen Code executes commands with different permission levels
Subagents
Delegate complex tasks to specialized AI agents
Skills
Extend Qwen Code with reusable skill modules
MCP Integration
Connect to Model Context Protocol servers
Session Management
Save and Resume Sessions
Your session history is automatically saved. To resume a previous session:Clear History
If you want to start fresh while keeping your configuration:Configuration
Customize Qwen Code to fit your workflow:Model Selection
Set your preferred model in~/.qwen/settings.json:
Approval Mode
Choose how Qwen Code handles command execution:- Plan: Review plan before execution
- Default: Approve each command
- Auto-edit: Auto-approve file edits
- YOLO: Auto-approve everything
Troubleshooting
Authentication fails
Authentication fails
If OAuth fails:
- Make sure you have a browser available
- Try clearing your credentials:
rm -rf ~/.qwen/credentials - Use API key authentication instead in headless environments
- Verify your API key is correct
- Check that the provider is properly configured
- Ensure you have network access to the API endpoint
Command not found
Command not found
If you get “qwen: command not found”:
- Make sure you’ve installed Qwen Code globally
- Restart your terminal after installation
- Check that npm global bin is in your PATH
Slow responses
Slow responses
If responses are slow:
- Check your internet connection
- Try a different model (some are faster)
- Use
/compressto reduce context size - Check API service status for your provider
Unexpected behavior
Unexpected behavior
If Qwen Code behaves unexpectedly:
- Run
/clearto reset context - Check approval mode settings
- Verify your configuration in
~/.qwen/settings.json - Use
/bugto report issues with system info
Next Steps
Explore Interactive Mode
Learn all the features of the interactive terminal UI
Configure Providers
Set up multiple AI providers and models
Integrate with Your IDE
Use Qwen Code inside VS Code, Zed, or JetBrains
Advanced Features
Explore subagents, skills, and more
