Blog

How to Run Qwen Code in the Terminal and Set Up Edit Mode

Markdown

Installing Qwen Code, launching it in a project, connecting a model through auth, Plan, Auto-Edit, Auto, and YOLO modes, a local model, and project protection.

Read full article

The question sounds like this: how do you get Qwen to work right in the console and write code on its own? Usually, behind it lies disappointment: someone installed Qwen Code, asked a question, got text and a piece of code in reply that they had to copy by hand, even though they were promised an agent that would go into the project and do everything itself.

That’s exactly what Qwen Code is: a full-fledged agent. It can open files, edit them, and run commands on its own. Its behavior depends on the active approval mode: Ask Permissions requests confirmation, while Auto-Edit and Auto permit more independent work. Check the status line rather than assuming that a mode named Default is the out-of-box choice. Below, in order: installation, launching it in a project, connecting a model after the April changes, and switching to a mode where the agent edits code without asking unnecessary questions. Everything was checked against Qwen’s official documentation as of August 30, 2026.

Practical resources on models and agents: Ailoot documentation.

What Does “Qwen Code Writes Code on Its Own” Mean?

Key takeaway

Qwen Code is an AI agent in the terminal. It reads the entire project, opens and edits files on its own, runs commands, and checks the results. A browser chat gives you text that you transfer by hand. The agent works right inside the code folder. The official description is “an open-source AI coding agent that lives in your terminal.”

The difference is simple. A browser chat answers a question with text. You read the answer, copy the code, paste it into your file, run it yourself, catch the error yourself, and take it back to the chat. You’re the courier between the chat and the project.

An agent works differently. You give it a task in plain language: “add a feedback form,” “fix this error.” Then it examines the project structure, finds the relevant files, makes edits, and runs a check. The documentation puts it plainly: the agent creates a plan, writes code, and makes sure it works.

That’s where the confusion in the question comes from. “Qwen doesn’t write code on its own” almost always means one of two things: either the person has a browser chat open instead of the terminal agent, or the agent is running but set to a mode where it asks permission for every edit. The first is solved by installing Qwen Code; the second, by switching modes. Both solutions are covered below.

How Do You Install Qwen Code in the Terminal?

Key takeaway

It installs with one command. On macOS and Linux, use the official Qwen installer or npm (Node.js 22 or later is required). On Windows, use a command in PowerShell. After installation, restart the terminal, or the qwen command might not be found. Installation is free and the same for everyone; costs begin later, when you access a model.

The quick route is the official installer, which selects the version for your system automatically.

On macOS and Linux, open the terminal and paste one line:

curl -fsSL https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen-standalone.sh | bash

On Windows, do the same with this PowerShell command:

irm https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen-standalone.ps1 | iex

The second option is npm, if you already have it installed. This requires Node.js version 22 or later:

npm install -g @qwen-code/qwen-code@latest

After installation, restart the terminal. The installer adds the qwen command to the system paths, and the terminal won’t know about it until you restart—that’s the most common reason for “I installed it, but it can’t find the command.” To check that everything installed, run:

qwen --version

If you see a version number, the agent is installed and ready to launch in your project.

How Do You Run Qwen Code in Your Project?

Key takeaway

Go to the project folder with the cd command, then type qwen. The agent’s terminal interface opens. On the first run, it will ask you to connect a model through the /auth menu. After that, you can write tasks in plain language—the agent will inspect the project and get to work. The key point: launch it from the project folder so the agent can see all your files.

First, go to the folder with your code. This matters: the agent works in the folder it was launched from and sees only its contents.

cd path-to-your-project
qwen

The agent’s interface will open right in the terminal. The first time, it will offer to connect a model; that’s covered in the next section. Once the model is connected, you can give the agent a task in plain language to see what it can access:

what does this project do?

The agent will read the files, understand the structure, and give you a useful answer. Then you can ask it to write and edit code: “add a logout button,” “split this file into two,” “find out why the test is failing.” It finds the relevant places and makes the changes itself.

There’s also a second way to launch it—with a single command, without the interface. It’s useful for scripts and automated tasks:

qwen -p "reread README and update the list of commands"

This runs the task and exits, without a conversation. You don’t need it for the first steps, but it’s useful to know about for later.

Why Is the Agent Running but Not Doing Anything on Its Own?

Key takeaway

If Ask Permissions is active, Qwen Code waits for your confirmation before edits and commands. Plus, a model must be connected before it can make edits: Alibaba closed free access through qwen.ai on April 15, 2026, and without connected model access, the agent simply can’t think through a task. The two common reasons it “just sits there” are that no model is connected or that cautious mode, with confirmation prompts, is enabled.

The first stumbling block is model access. Qwen Code used to offer free access: you logged in with a qwen.ai account, and the agent worked without a card. That access was called Qwen OAuth, and it was discontinued. The authorization documentation says it directly: the free Qwen OAuth tier was discontinued on April 15, 2026; previously saved logins might continue working briefly, but the server rejects new requests. The “sign in with qwen.ai” option was also removed from the menu.

So for the agent to start thinking through a task at all, you need a connected model. The next section covers the connection options, both paid and free local ones.

The second reason is quieter and more frustrating. The model is connected, the agent responds, but it doesn’t edit any files—it only shows what it plans to do and waits. That behavior is expected in Ask Permissions mode, which asks for confirmation before edits and commands; it is not evidence of a universal startup default. To have it work on its own, you need to switch modes. That’s covered two sections below, where you’ll find the answer to the original question.

How Do You Connect a Model Now That Free Access Is Closed?

Key takeaway

On the first run, the /auth command opens a menu with three options. Alibaba ModelStudio is the official paid option (individual users can get a Coding Plan with a weekly quota). Third-party providers connect by key to DeepSeek, Kimi, and others. Custom Provider connects your own or a local model through Ollama and similar tools. Only the last option—a local model—works for free without a card.

In the agent, type the command:

/auth

A menu will open with three main options. Here’s what each one does.

Alibaba ModelStudio is the official option from Qwen’s creators. It offers a Coding Plan with a fixed price and weekly quota for an individual developer, a Token Plan with pay-as-you-go pricing for teams, and the option to connect an existing ModelStudio key. This is paid access to Qwen’s “native” model.

Third-party providers let you choose a built-in provider and connect with a key. The official list includes DeepSeek, Grok, MiniMax, Z.AI, Kimi, ModelScope, and others. Get a key from the provider, enter it, and the agent will use that provider’s model.

Custom Provider connects your own server, proxy, or local engine. This is where you connect a model running on your computer through Ollama. This option supports OpenAI, Anthropic, and Gemini formats, so it works with almost any access method.

You can also enter the key and settings manually in the ~/.qwen/settings.json file. It has the modelProviders field (which models are available), env (the keys themselves), security.auth.selectedType (which protocol to enable on startup), and model.name (the default model). Then qwen will start with those settings and won’t ask anything. For the first time, it’s easier to go through /auth; you can return to the file when you want to save all the settings.

For a look at what remained free after April, see the article about free Qwen Code.

Which Mode Should You Enable So the Agent Edits Code on Its Own?

Key takeaway

Qwen Code’s five-mode documentation labels Auto as the default in its quick reference, while the Ask Permissions section still contains older initial-mode wording. This unversioned page does not establish the default for every installation: check the active mode in your session. Auto uses a classifier to approve or block evaluated actions. If you want it to edit files without prompting, use Auto-Edit. If you’re ready to let it make edits and run commands without asking at all, use YOLO—but only in your own project, and with caution. The mode is the switch between “asks about everything” and “works on its own.”

Here’s the core idea: the access mode determines how independently the agent acts, and there are five modes, from the most cautious to the most permissive.

ModeEdits filesRuns commandsWhat it’s for
Planno, read-onlynoUnderstand the project and make a plan without changing anything
Ask Permissionswith confirmationwith confirmationUnfamiliar or important code, when you want to see every step
Auto-Editon its ownwith confirmationMany small edits, with commands kept under your control
Autobased on safety assessmentbased on safety assessmentLong, independent work with safeguards
YOLOon its ownon its ownYour own project, where you trust the agent with everything

If the agent only shows you edits and waits, it’s probably in Ask Permissions mode (called Default in older versions). Then you have to confirm every edit and command by hand, which makes it feel like the agent isn’t doing anything on its own.

To have it edit files without prompting, switch to Auto-Edit. Edits will happen automatically, but the agent will still ask before running commands—a sensible safeguard against accidentally running rm in the wrong place.

Auto uses an internal evaluator for actions that need assessment. Choose it deliberately after checking the installed version and active status; the word default retained in the Ask Permissions configuration is a compatibility name, not proof that it is the startup mode.

YOLO is the most permissive mode. The agent edits files and runs commands on its own, without asking anything. The documentation says it’s only for trusted personal projects and automated workflows. It’s easy to get an unwanted result in a work project, so enable it only with a clear head and, preferably, on a copy.

How Do You Switch Modes During a Session?

Key takeaway

While staying in the agent, press Shift+Tab (on Windows, Tab), and the mode cycles through: Plan, confirmations, auto-edits, Auto, YOLO, and back to Plan. The current mode is shown in the status line at the bottom of the screen. A useful workflow is to start in Plan, review the task, then switch to Auto-Edit or Auto and let the agent work.

You can switch modes as you go, in the middle of a task. Press Shift+Tab to advance to the next mode. On Windows, the regular Tab key does the same thing. The cycle is: Plan, then confirmations, then auto-edits, then Auto, then YOLO, and back to Plan.

The current mode is always shown in the status line at the bottom of the interface. Get used to checking it before giving the agent a big task, so you don’t launch YOLO when you only meant to look at a plan.

A beginner-friendly workflow takes three steps:

  1. Launch the agent in Plan mode and ask it to analyze the task and suggest a plan. It won’t touch anything; it will only read the code and describe what it intends to do.
  2. Read the plan, and if you agree, switch to Auto-Edit or Auto by pressing Shift+Tab.
  3. Tell it to proceed. The agent will now edit files on its own while you monitor the results.

This approach removes a beginner’s main fear—that the agent will immediately break everything. First, you review the plan in a safe mode, and only then let it proceed.

A Local Model Without a Card

Key takeaway

Yes, you can use a local model. Qwen Code can work with a model running right on your computer through Ollama or a similar program—you connect it from the menu as a Custom Provider. You don’t need Alibaba’s cloud for this. Open models can be downloaded for free, no card is needed, and your project data doesn’t leave your machine. The tradeoff is that you need a powerful computer, or the agent will think slowly.

Install an open model on your computer through Ollama or vLLM, then connect it as a Custom Provider from the /auth menu. After that, the agent uses a model on your own machine instead of Alibaba’s cloud. No card or keys are needed, and there’s no request limit. For a look at which open models can handle coding, see this review of free coding models.

The tradeoff is hardware. A model that writes code reasonably well takes up a lot of video memory. It’s feasible on a gaming computer with a powerful graphics card, but on a regular laptop the model might not fit, or it might take so long to think through each response that it’s easier to look for another option.

Another benefit of running locally is data privacy. All your code stays on your computer; nothing is sent to someone else’s server. For a sensitive project, that matters more than saving on a subscription.

What Can You Do to Keep the Agent from Breaking the Project?

Key takeaway

Three things. Keep the project under git version control so you can undo any agent edit with one command. Start tasks in Plan mode and read the plan before letting the agent proceed. Don’t enable YOLO on a work project—save it for copies and small experiments. That way, the agent’s independence works in your favor.

An independent agent is convenient as long as it does what you wanted. To keep a misstep from costing you, follow three habits.

First, use git. If the project is under version control, you can see every agent edit and undo any of them. An independent agent really is risky without git: it changes something, and there’s no way to restore the previous version. With git, reverting takes one short command.

Second, start in Plan mode. Before letting the agent take on a big task, ask it to make a plan in a mode where it won’t touch anything. Read it and understand what the agent intends to do, then switch to edits.

Third, be careful with YOLO. In this mode, the agent runs commands on its own, including commands that delete files. That’s too much for a work project. Save YOLO for rough copies and small tasks where it won’t matter if something goes wrong.

These three habits address the main fear—“I vibe-coded it and broke it.” For more about reverting changes in vibe coding, see this separate review. It’s about Claude Code, but the principle of using git is exactly the same.

Where Should You Start for Your Task?

Key takeaway

Install Qwen Code, go to your project folder, run qwen, and connect a model through /auth—a paid model or a local one through Ollama. Then start in Plan mode, read the plan, switch to Auto-Edit by pressing Shift+Tab, and let the agent work. Keep the project under git. The whole setup takes about twenty minutes the first time.

Here’s the whole process as a short list. Follow it from top to bottom:

  1. Install Qwen Code with one command and restart the terminal.
  2. Go to the project folder with cd and run qwen.
  3. Connect a model through /auth: a paid plan or a local model through Ollama if paying by card isn’t an option.
  4. Give the agent a task in Plan mode and read its plan.
  5. Switch to Auto-Edit or Auto with Shift+Tab and let it work.
  6. Keep the project under git so you can undo any edit.

In short, “Qwen doesn’t write code on its own” almost always means either no model is connected or the agent is in confirmation mode. Fix the first in the /auth menu, and the second by pressing Shift+Tab until you reach Auto-Edit. After that, the agent really does work on its own in the terminal.

If you want to compare Qwen with other agents for your task, see this review of Claude Code alternatives. Qwen appears alongside the others, so you can see which one is right for what.

Sources

Practical resources: Ailoot documentation.

More resources and tools: Ailoot.

More details

Questions about How to Run Qwen Code in the Terminal and Set Up Edit Mode | Ailoot

Why does Qwen Code show proposed changes and wait?

Check the active mode in the status line. Ask Permissions waits for confirmation; Plan is for analysis. Auto-Edit permits edits while retaining command approval, and model access must also be configured.

Does a mode called Default prove which mode a fresh installation starts in?

No. The older Default name is retained for Ask Permissions compatibility, while the documentation’s quick reference labels Auto as the default. Inspect your installed version and active session mode instead of inferring it from the name.

All articles