Qwen Code CLI - Install, Slash Commands & MCP
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-codeqwen --versionexport DASHSCOPE_API_KEY="sk-..."qwen auth loginqwen auth statusLaunch & Run 5
qwenqwen "Refactor the user module"qwen -p "Explain this function"qwen -cqwen -m qwen3-max "task"Slash Commands 5
/init/clear/compact/model/exitMCP & Extensions 5
qwen mcp add <name> <url>qwen mcp listqwen mcp remove <name>qwen mcp get <name>@./src/utils.tsChinese-Context Tips 5
qwen -p "Explain the architecture in Chinese"Put conventions in QWEN.mdqwen -p --output-format jsonContinue with -cqwen --permission-mode planTips
- 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 jsondrops 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.
FAQ
What should go into QWEN.md?
Project conventions and commands, auto-loaded each session so it stops guessing: how to build, how to run tests, code style rules, directories to avoid. The highest-value entry is how to verify a change — otherwise it may claim success without running tests. Keep it short; long documents dilute attention rather than help.
Is it better to prompt in Chinese for Chinese tasks?
Usually. Prompting in Chinese and getting Chinese back removes a translation round-trip and keeps terminology stable. Switch to explicitly requesting English when you need English docs or code comments, and give an example of the style you want — for example "for an English audience, technical writing style" — rather than relying on the default.
How do I attach an MCP server to Qwen Code?
Add one with qwen mcp add <name> <url>, list with qwen mcp list, inspect with qwen mcp get <name> and remove with qwen mcp remove <name>. MCP grants access to external tools and data sources. In prompts, @./src/utils.ts references a specific file precisely, avoiding a full repository scan.
How do I make Qwen Code emit JSON for scripts?
Use qwen -p --output-format json to get structured output that a downstream program can consume directly. Continue prior context with -c instead of restating the background. For planning tasks add --permission-mode plan to stay read-only.
Which slash commands are worth knowing in Qwen Code?
/init generates a QWEN.md config in the project root — put build and test commands there and they load automatically. /clear wipes conversation history, which is right when switching tasks. /compact summarizes the conversation to free context in long sessions. /model switches the active model and /exit leaves the REPL.
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