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.
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
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