Qwen Code is an open-source AI agent for the terminal, optimized for Qwen3-Coder. It helps developers understand large codebases, automate tedious work, and ship faster.
This project is based on Google Gemini CLI with adaptations to better support Qwen-Coder models.
- OpenAI-compatible, OAuth free tier: Use an OpenAI-compatible API, or sign in with Qwen OAuth to get 1,000 free requests/day
- Agentic workflow, feature-rich: Rich built-in tools (Skills, SubAgents, Plan Mode) for a full agentic workflow
- Terminal-first, IDE-friendly: Built for developers who live in the command line, with optional integration for VS Code, Zed, and JetBrains IDEs
- Runtime: Node.js 20+
- Language: TypeScript 5.3+
- Package Manager: npm with workspaces
- Build Tool: esbuild
- Testing: Vitest
- Linting: ESLint + Prettier
- UI Framework: Ink (React for CLI)
- React Version: 19.x
├── packages/
│ ├── cli/ # Command-line interface (main entry point)
│ ├── core/ # Core backend logic and tool implementations
│ ├── sdk-java/ # Java SDK
│ ├── sdk-typescript/ # TypeScript SDK
│ ├── test-utils/ # Shared testing utilities
│ ├── vscode-ide-companion/ # VS Code extension companion
│ ├── webui/ # Web UI components
│ └── zed-extension/ # Zed editor extension
├── scripts/ # Build and utility scripts
├── docs/ # Documentation source
├── docs-site/ # Documentation website (Next.js)
├── integration-tests/ # End-to-end integration tests
└── eslint-rules/ # Custom ESLint rules
The main CLI package providing:
- Interactive terminal UI using Ink/React
- Non-interactive/headless mode
- Authentication handling (OAuth, API keys)
- Configuration management
- Command system (
/help,/clear,/compress, etc.)
Core library containing:
- Tools: File operations (read, write, edit, glob, grep), shell execution, web fetch, LSP integration, MCP client
- Subagents: Task delegation to specialized agents
- Skills: Reusable skill system
- Models: Model configuration and registry for Qwen and OpenAI-compatible APIs
- Services: Git integration, file discovery, session management
- LSP Support: Language Server Protocol integration
- MCP: Model Context Protocol implementation
- Node.js: ~20.19.0 for development (use nvm to manage versions)
- Git
- For sandboxing: Docker or Podman (optional but recommended)
# Clone and install
git clone https://github.com/QwenLM/qwen-code.git
cd qwen-code
npm install# Build all packages
npm run build
# Build everything including sandbox and VSCode companion
npm run build:all
# Build only packages
npm run build:packages
# Development mode with hot reload
npm run dev
# Bundle for distribution
npm run bundle# Start interactive CLI
npm start
# Or after global installation
qwen
# Debug mode
npm run debug
# With environment variables
DEBUG=1 npm start# Run all unit tests
npm run test
# Run integration tests (no sandbox)
npm run test:e2e
# Run all integration tests with different sandbox modes
npm run test:integration:all
# Terminal benchmark tests
npm run test:terminal-bench# Run all checks (lint, format, build, test)
npm run preflight
# Lint only
npm run lint
npm run lint:fix
# Format only
npm run format
# Type check
npm run typecheck- Strict TypeScript: All strict flags enabled (
strictNullChecks,noImplicitAny, etc.) - Module System: ES modules (
"type": "module") - Import Style: Node.js native ESM with
.jsextensions in imports - No Relative Imports Between Packages: ESLint enforces this restriction
tsconfig.json: Base TypeScript configuration with strict settingseslint.config.js: ESLint flat config with custom rulesesbuild.config.js: Build configurationvitest.config.ts: Test configuration
// Within a package - use relative paths
import { something } from './utils/something.js';
// Between packages - use package names
import { Config } from '@qwen-code/qwen-code-core';- Unit tests co-located with source files (
.test.tssuffix) - Integration tests in separate
integration-tests/directory - Uses Vitest with globals enabled
- Mocking via
mswfor HTTP,memfs/mock-fsfor filesystem
All tools extend BaseDeclarativeTool or implement the tool interfaces:
- Located in
packages/core/src/tools/ - Each tool has a corresponding
.test.tsfile - Tools are registered in the tool registry
Task delegation framework:
- Configuration stored as Markdown + YAML frontmatter
- Supports both project-level and user-level subagents
- Event-driven architecture for UI updates
Hierarchical configuration loading:
- Default values
- User settings (
~/.qwen/settings.json) - Project settings (
.qwen/settings.json) - Environment variables
- CLI flags
- Qwen OAuth (recommended): Browser-based OAuth flow
- OpenAI-compatible API: Via
OPENAI_API_KEYenvironment variable
Environment variables for API mode:
export OPENAI_API_KEY="your-api-key"
export OPENAI_BASE_URL="https://api.openai.com/v1" # optional
export OPENAI_MODEL="gpt-4o" # optionalPress F5 to launch with debugger attached, or:
npm run debug # Runs with --inspect-brkDEV=true npm start
npx react-devtools@4.28.5DEBUG=1 qwen-
User documentation: https://qwenlm.github.io/qwen-code-docs/
-
Local docs development:
cd docs-site npm install npm run link # Links ../docs to content npm run dev # http://localhost:3000
See CONTRIBUTING.md for detailed guidelines. Key points:
- Link PRs to existing issues
- Keep PRs small and focused
- Use Draft PRs for WIP
- Ensure
npm run preflightpasses - Update documentation for user-facing changes
- Follow Conventional Commits for commit messages
| Command | Description |
|---|---|
npm start |
Start CLI in interactive mode |
npm run dev |
Development mode with hot reload |
npm run build |
Build all packages |
npm run test |
Run unit tests |
npm run test:e2e |
Run integration tests |
npm run preflight |
Full CI check (clean, install, format, lint, build, typecheck, test) |
npm run lint |
Run ESLint |
npm run format |
Run Prettier |
npm run clean |
Clean build artifacts |
/help- Display available commands/clear- Clear conversation history/compress- Compress history to save tokens/stats- Show session information/bug- Submit bug report/exitor/quit- Exit Qwen Code