Qwen Code CLI Cheatsheet - Alibaba Qwen AI Coding CLI Full Reference
Qwen Code is Alibaba Qwen open-source AI coding CLI (Claude Code-like, built on Qwen3-Max / Qwen3-Coder), for developers using Tongyi/Qwen models who want terminal-based AI coding, especially those already on Alibaba Cloud DashScope. Usage resembles Claude Code but with different models and pricing, connecting via DASHSCOPE_API_KEY. This sheet covers launch, print mode, slash commands, and MCP.
Install & Auth 5
npm install -g @qwen-code/qwen-codeInstall globally via npm
qwen --versionPrint the version
export DASHSCOPE_API_KEY="sk-..."Set the Tongyi API key
qwen auth loginInteractive sign-in (if supported)
qwen auth statusShow auth status
Launch & Run 5
qwenStart 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 -cContinue the most recent session (--continue)
qwen -m qwen3-max "task"Run with a specified model
Slash Commands 5
/initGenerate project config (QWEN.md)
/clearClear conversation history
/compactSummarize to free context
/modelSwitch the active model
/exitQuit the REPL
MCP & Extensions 5
qwen mcp add <name> <url>Add an MCP server
qwen mcp listList configured MCP servers
qwen mcp remove <name>Remove an MCP server
qwen mcp get <name>Show server config
@./src/utils.tsReference 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.mdBuild/test commands auto-load from QWEN.md
qwen -p --output-format jsonJSON output for scripting
Continue with -cResume context with -c
qwen --permission-mode planRead-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
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
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