Qwen Code CLI Cheatsheet - Alibaba Qwen AI Coding CLI Full Reference

All Qwen Code (Tongyi) AI coding CLI commands in one place — from launch to print mode, slash commands, and MCP — organized by scenario. Copy and go.

AI CLI·25 commands·Last updated 2026-08-21

Install & Auth 5

npm install -g @qwen-code/qwen-code
Install globally via npm
qwen --version
Print the version
export DASHSCOPE_API_KEY="sk-..."
Set the Tongyi API key
qwen auth login
Interactive sign-in (if supported)
qwen auth status
Show auth status

Launch & Run 5

qwen
Start an interactive REPL in the cwd
qwen "Refactor the user module"
Start with an initial prompt
qwen -p "Explain this function"
Print mode: run then exit
qwen -c
Continue the most recent session (--continue)
qwen -m qwen3-max "task"
Run with a specified model

Slash Commands 5

/init
Generate project config (QWEN.md)
/clear
Clear conversation history
/compact
Summarize to free context
/model
Switch the active model
/exit
Quit the REPL

MCP & Extensions 5

qwen mcp add <name> <url>
Add an MCP server
qwen mcp list
List configured MCP servers
qwen mcp remove <name>
Remove an MCP server
qwen mcp get <name>
Show server config
@./src/utils.ts
Reference a file with @ in the prompt

Chinese-Context Tips 5

qwen -p "Explain the architecture in Chinese"
Use Chinese prompts directly
Put conventions in QWEN.md
Build/test commands auto-load from QWEN.md
qwen -p --output-format json
JSON output for scripting
Continue with -c
Resume context with -c
qwen --permission-mode plan
Read-only plan mode

Tips

  • Qwen Code is a domestic vendor CLI; its Chinese context and Qwen3-Coder coding strength make it a necessary pick for the "Chinese AI cheatsheet" track.
  • Put build/test conventions in QWEN.md — auto-loaded each session, more stable than repeating prompts.
  • Print mode `-p --output-format json` drops into CI/scripts just like Claude Code, low migration cost.
  • The CLI asks before exiting the sandbox for network (e.g. npm install); for pure-local inference use Qwen open weights via Ollama.

Official References

Commands are compiled from the official docs below. Click to verify the latest usage.

Maintained by LaoHand

Publicly updated on Aug 21, 2026, continuously proofread against official docs.

Contact Us

Wrong command or description? Send us corrections, business inquiries or product feedback by email.

Contact Us