Qwen Code: Alibaba’s Open Coding Agent CLI
Qwen Code is the Qwen team’s open-source coding agent for the terminal, forked from Gemini CLI and now developed on its own. Its license, how to install it, which models it runs, how sign-in works now that the free Qwen OAuth tier has ended, how it uses MCP, and how it compares with Gemini CLI and Claude Code.
7 min read
Qwen Code is an open-source AI coding agent from the Qwen team at Alibaba. You run qwen in a project folder and it reads the code, edits files, runs commands and plans multi-step changes, much like Claude Code or Gemini CLI. It started as a fork of Gemini CLI, is licensed under Apache 2.0, and speaks the OpenAI, Anthropic, Gemini and Qwen APIs, so it can drive Qwen3-Coder, another vendor’s model or a local one. The main thing that changed in 2026: the free Qwen OAuth sign-in ended on April 15, 2026, so today you connect it with an Alibaba Cloud Model Studio plan, a third-party provider’s API key, or your own endpoint.
What Qwen Code is, and where it came from
The Qwen Code repository (opens in a new tab) says the project was originally based on Google’s Gemini CLI v0.8.2, and that from Qwen Code v0.1 it stopped syncing with upstream and began independent development as a multi-protocol, multi-platform agent. That history explains the familiar shape: a terminal UI, slash commands, a settings.json in ~/.qwen, and a project instruction file. It also explains why the two have drifted since, so Gemini CLI guides only partly apply.
The terminal is one of several surfaces. The same agent runs in a desktop app for macOS, Windows and Linux, in editor plugins for VS Code, Zed and JetBrains, in an experimental browser UI started with qwen serve --open, and headless as qwen -p "..." for scripts and CI. There are SDKs for TypeScript, Python and Java, and chat connectors for Telegram, DingTalk, WeChat and Feishu.
License
Qwen Code is licensed under Apache 2.0, the same license as Gemini CLI. You can read the code that decides what runs on your machine, fork it or patch it. The Qwen3-Coder model weights published on Hugging Face also carry an Apache 2.0 license. Using a hosted model is a separate matter: you accept the terms of whichever provider serves it, whether that is Alibaba Cloud or a third party.
Install
# Linux or macOS: standalone installer curl -fsSL https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen-standalone.sh | bash # Windows (PowerShell) irm https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen-standalone.ps1 | iex # npm (needs Node.js 22 or later) npm install -g @qwen-code/qwen-code@latest # Homebrew brew install qwen-code # then, in your project cd /path/to/your-project qwen
Restart the terminal after the standalone installer so the path change takes effect. Inside a session, /auth sets up a provider and /model switches between the models you have configured.
Models: Qwen3-Coder and everything else
Qwen3-Coder is the Qwen team’s family of coding models, and the reason most people search for Qwen Code in the first place. The Qwen3-Coder repository (opens in a new tab) lists three sizes: Qwen3-Coder-480B-A35B-Instruct, Qwen3-Coder-30B-A3B-Instruct, and Qwen3-Coder-Next, an open-weight model built for coding agents and local development on top of Qwen3-Next-80B-A3B-Base. All three list a native context of 256K tokens, and the Qwen team lists Qwen3-Coder-Next as working in agents such as Qwen Code, Cline and Claude Code.
Qwen Code itself is not tied to them. It configures models through modelProviders in ~/.qwen/settings.json, keyed by protocol: openai for any OpenAI-compatible endpoint (OpenAI, Azure OpenAI, OpenRouter, Alibaba Cloud and self-hosted servers such as Ollama or vLLM), anthropic for Claude, gemini for Google’s API and vertex-ai for Vertex AI. You can switch between configured models at runtime with /model.
Signing in after Qwen OAuth ended
Older tutorials say you can sign in with a qwen.ai account and use Qwen Code for free. That is no longer true. Qwen Code’s authentication guide (opens in a new tab) says the Qwen OAuth free tier was discontinued on April 15, 2026, that cached tokens may work briefly but new requests are rejected, and that Qwen OAuth is no longer offered in the /auth menu. The menu now has three options:
- Alibaba ModelStudio: the recommended route, with a Coding Plan for individual developers, a usage-billed Token Plan for teams, or a standard Model Studio API key. Each has a Beijing and an international endpoint.
- Third-party Providers: built-in presets for providers such as DeepSeek, Kimi, MiniMax, Z.AI, OpenRouter and ModelScope, each connected with an API key.
- Custom Provider: any OpenAI, Anthropic or Gemini-compatible endpoint, including a local server or a company proxy.
For CI or a container, where a browser flow is impossible anyway, set the provider in settings.json or with environment variables. Qwen Code reads keys from the shell first, then from the first .env file it finds, preferring .qwen/.env; the docs warn that a key placed in the env block of settings.json is stored in plain text.
export OPENAI_API_KEY="sk-..." export OPENAI_BASE_URL="https://your-provider.example.com/v1" export OPENAI_MODEL="qwen3-coder-plus" qwen -p "Summarize what changed in the last commit and list any failing tests"
Permissions and project instructions
Qwen Code has five approval modes, cycled with Shift+Tab (Tab on Windows): Plan, which only reads; Ask Permissions, which asks before every edit and command and was previously called Default; Auto-Edit, which allows edits but asks before commands; Auto, the default, where a model-based classifier approves safe actions and blocks risky ones; and YOLO, which approves everything. On Linux there is also an optional tool sandbox built on Bubblewrap.
Standing instructions go in QWEN.md, either ~/.qwen/QWEN.md for you or QWEN.md in the project root for the team. Qwen Code also reads an existing AGENTS.md, so a repository that already keeps one for other agents does not need a second copy.
MCP in Qwen Code
Qwen Code loads MCP servers from mcpServers in settings.json, user scope by default or project scope in .qwen/settings.json, and qwen mcp add writes the entries for you. The MCP guide (opens in a new tab) recommends the http transport for remote servers, keeps sse for older ones and uses stdio for local processes. Remote servers can send custom headers or use OAuth, /mcp opens a management dialog, and includeTools or excludeTools trims what a server exposes.
One detail matters for anything that writes: after a dropped connection, Qwen Code replays a tool call only if the server is marked trust: true, the workspace is trusted, and the tool declares itself idempotent or read-only through MCP annotations. Otherwise it reports that the result is unknown and asks you to check before trying again. The docs are clear that annotations are hints, not permissions.
Qwen Code, Gemini CLI and Claude Code
- Lineage: Qwen Code forked from Gemini CLI and has developed separately since v0.1. Claude Code is Anthropic’s own agent.
- License: Qwen Code and Gemini CLI are Apache 2.0. Claude Code is distributed under Anthropic’s commercial terms.
- Models: Qwen Code runs Qwen, Claude, Gemini, OpenAI-compatible and local models through one configuration. Gemini CLI is built around Gemini models, and Claude Code around Claude models.
- Instruction files:
QWEN.mdplusAGENTS.md,GEMINI.md, andCLAUDE.mdrespectively. - Shared ground: all three support MCP, plan-first work, subagents, headless runs and editor plugins.
Qwen Code suits you if you want an open-source agent with a free choice of model, or you already use Qwen3-Coder through Alibaba Cloud. If you want the agent and model from one vendor with the least setup, Claude Code or Gemini CLI is simpler. The wider field, with Codex CLI, OpenCode, Aider and others, is in Claude Code alternatives, and Google’s agent gets its own comparison in Gemini CLI vs Claude Code.
Giving Qwen Code a task board
A Qwen Code session remembers its own conversation, not what the rest of the team is doing. fenbs is a board where AI assistants are members: each feature, enhancement or bug is a task with a note saying what and why, a plan, and a test status, in lanes To Do, Next Up, In Progress and Completed. Issue a token under Settings with a name, scopes and an optional expiry, add https://fenbs.ai/api/mcp as an http server with that token as a bearer header, and Qwen Code can pick up the next task, move it along and comment with what it changed. Every change lands in History under the assistant’s name, and revoking the token ends its access. fenbs sets no tool annotations yet, so under the replay rule above an interrupted fenbs call is reported as unknown rather than retried; check the task before running it again.
qwen mcp add --transport http fenbs https://fenbs.ai/api/mcp \ --header "Authorization: Bearer YOUR_FENBS_TOKEN"
Related
Choosing among agents: Claude Code alternatives and the best AI coding agents. Instruction files across tools: AI context files compared. Running models locally: MCP with Ollama. Connecting a board: the MCP docs and assistant tokens and scopes.