Skip to content
Qwen Code logo

Qwen Code cheat sheet

$ qwen Alibaba Official docs

Every command, flag and slash command for qwen — Alibaba's terminal agent — forked from Gemini CLI but now its own tool, with ~60 slash commands. 17+ commands, verified July 2026.

Qwen Code hard-forked from Gemini CLI at its own v0.1 and diverged: the --all-files / -a flag is gone (use --include-directories), and the Qwen free tier was discontinued 2026-04-15 — use any OpenAI-compatible key or the Alibaba Cloud Coding Plan.

Install
npm install -g @qwen-code/qwen-code@latest   # npm (needs Node 22+)
brew install qwen-code                        # Homebrew
npx @qwen-code/qwen-code                       # run without installing
Start & run
qwen                              # interactive terminal UI
qwen -p "fix the failing tests"   # headless
qwen -m qwen3-coder-plus -p "…"   # pick the model
qwen --include-directories src,tests -p "…"   # add dirs to context
qwen sessions list                # list recent sessions

Key flags

FlagWhat it does
-m, --model <id>Model (e.g. qwen3-coder-plus)
-p, --prompt <text>Headless one-shot prompt
-i, --prompt-interactiveInteractive with an initial prompt
-y, --yoloAuto-approve all actions
--approval-mode <m>plan · default · auto-edit · auto · yolo
-s, --sandboxSandbox (docker / podman / sandbox-exec)
--include-directories <a,b>Extra dirs (the --all-files replacement)
-o, --output-format <fmt>text · json · stream-json
-c, --continue / -r, --resumeResume sessions

Slash · @file · !shell

CommandWhat it does
/help · /clear (/new)Help · clear context
/compress (/summarize)Summarize history to save tokens
/stats · /contextUsage · context-window breakdown
/memory · /remember · /forgetMemory manager
/model [id] · /approval-modeSwitch model · change approval mode
/initAnalyze the dir and create a QWEN.md
/review [PR]Code review with parallel agents
@file · !cmdInject a file · run a shell command
Config
~/.qwen/settings.json   ·   ./.qwen/settings.json     # user / project
QWEN.md                          # project context (/init to scaffold)

export OPENAI_API_KEY="…"                             # any OpenAI-compatible provider
export OPENAI_BASE_URL="https://openrouter.ai/api/v1" # e.g. OpenRouter / Ollama / vLLM
export OPENAI_MODEL="qwen3-coder-plus"
Common one-liners
qwen -p "Write a concise commit message" --output-format json | jq -r '.result'
OPENAI_BASE_URL="http://localhost:11434/v1" OPENAI_API_KEY="ollama" \
  qwen -p "refactor utils.py"                          # local Ollama, one run
qwen -m qwen3-coder-plus --include-directories src,tests -p "fix the flaky test"
git diff origin/main...HEAD | qwen -p "Review these changes for bugs"

More CLI cheat sheets

Stop memorizing flags

Run Qwen Code — and every other agent — from one app

TheVibeFather orchestrates Qwen Code alongside every other coding CLI in one native macOS app. Bring the models you already pay for; keep your keys.