A blazing-fast terminal AI coding agent written in Rust.
qcr is a single-binary, low-footprint AI pair programmer for your terminal. Built from the ground up in Rust (edition 2024), it ships with 45+ built-in tools, multi-provider LLM support, parallel tool execution, prompt caching, file checkpointing, a session-scoped cron scheduler, and a plugin system compatible with the Claude Code ecosystem — all in a ~15 MB binary that boots in milliseconds.
Bring your own key. Point it at OpenAI, Anthropic, Gemini, DashScope (Qwen), GitHub Copilot, Azure, Ollama, MiniMax, OpenRouter or any OpenAI-compatible endpoint. Use it interactively in a TUI, headless in CI, or as an ACP backend for Zed/JetBrains.
cargo install --git https://github.com/hscale/qwen-code-rust qcr-cli
export DASHSCOPE_API_KEY=sk-...
qcr "refactor src/auth.rs to remove the static mutex"qcr (Rust) |
Typical Node agents | |
|---|---|---|
| Cold start | ~15 ms | 300–800 ms |
| Idle RSS | ~18 MB | 150–400 MB |
| Binary | single static ~15 MB | npm tree (100+ MB, Node runtime) |
| Parallel tools | up to 10 concurrent, Tokio-driven | sequential or limited |
| Streaming | zero-copy SSE, incremental TUI paint | JSON buffered |
| Prompt cache hit | automatic (Anthropic + OpenAI) | manual |
| Crash safety | unsafe-free core, file checkpointing, undo stack |
varies |
No Node runtime. No Python. No Docker. Just a binary.
- Written in Rust — edition 2024, MSRV 1.85,
unsafe-free core - Tokio-powered parallel tool execution — independent tool calls dispatched concurrently (up to 10), with concurrency groups for safe ordering
- Zero-copy SSE streaming — text and tool-call deltas rendered incrementally in the TUI
- Multi-level context compaction — micro (every turn, free) + auto (LLM summary at threshold) + reactive (on context overflow + retry)
- Prompt caching built-in — Anthropic
cache_control: ephemeraland OpenAI structured prefix caching; saves 15–25K tokens/turn - Lazy skill loading & deferred MCP tools — schemas fetched on-demand via
ToolSearchto keep the system prompt small - 9 criterion benchmarks cover SSE parsing, session serialization, glob search, skill loading, i18n lookup, agent loop, tool execution, config loading, and the provider pipeline
- Interactive TUI built with ratatui — conversation history, spinner, slash commands, approval dialog
- Headless and
--printmodes for scripting and CI pipelines - ACP (Agent Client Protocol) —
qcr --acpexposes a full ndjson JSON-RPC 2.0 stdio transport for IDE integration (Zed, JetBrains) - File checkpointing &
/rewind— SHA-256 deduplicated snapshots before each modification; restore files to any previous turn - Per-file LIFO undo stack for all write operations (
/undo) - Session persistence &
/fork— save, resume, or branch conversations from~/.qcr/sessions/ - Chat recording — JSONL transcripts on disk per session
- Tool approval system —
suggestmode shows an interactive y/n/a dialog;automode includes a 2-stage LLM safety classifier (fast 256-token + deep 4096-token check) - Agent loop with plan mode, loop detection, and configurable turn limits
- Rich git context — full
git statusand recent commits auto-injected into the system prompt - i18n — embedded locale support (
en/vi/zh)
- 45+ built-in tools — read / write / edit / undo / format / find-and-edit, shell, glob, grep, ls, web fetch, web search, LSP, skills, memory, sub-agents, mermaid, oracle, todo, now, thinking, create / copy / move / delete paths, cron scheduling, agent teams, tool search, browser automation
- Multi-provider LLM support — OpenAI, Anthropic, Google Gemini, DashScope (Qwen), Azure, GitHub Copilot, Ollama, MiniMax, OpenRouter, or any OpenAI-compatible proxy
- MCP (Model Context Protocol) — connect external tool servers over stdio or HTTP
- Plugin system — Claude Code-compatible plugins with slash commands, skills, agents, MCP servers, and lifecycle hooks
- Built-in skills —
spec-driven-development,batch,simplify,verifyand more ship with the binary - Steering files —
.qcr/steering/*.mdautomatically injected into every system prompt - Persistent memory —
QCR.mdfiles (with@include) for pinned notes + memorix integration for automatic semantic recall - Session-scoped cron scheduler —
/loopslash command +CronCreate/CronList/CronDeletetools for recurring prompts, polling, and one-shot reminders - Sub-agents via
Task— spawn isolated agent loops for parallel work - Layered config — global
~/.qcr/settings.json+ project.qcr/settings.json+ env vars
git clone https://github.com/hscale/qwen-code-rust
cd qwen-code-rust
cargo build --release
# Binary at: target/release/qcr
cp target/release/qcr ~/.local/bin/qcrjust release- Rust 1.85+ (edition 2024)
- macOS or Linux (Windows builds available via CI)
# Bring your own key — pick any provider
export DASHSCOPE_API_KEY=sk-...
export QCR_MODEL=qwen3-coder
export QCR_PROVIDER=dashscope
# Interactive TUI
qcr
# Single-turn print mode
qcr --print "Explain the borrow checker"
# Pipe a file for review
cat src/main.rs | qcr --print "Review this code for bugs"
# Auto-approve all tools (CI / headless)
qcr --approval-mode never --print "Create hello.txt with 'Hello World'"export DASHSCOPE_API_KEY=sk-...
qcr --provider dashscope --model qwen3-coderexport ANTHROPIC_API_KEY=sk-ant-...
qcr --provider anthropic --model claude-3-5-sonnet-20241022ollama run llama3.2
OPENAI_API_BASE=http://localhost:11434/v1 OPENAI_API_KEY=ollama \
qcr --provider openai --model llama3.2OPENAI_API_BASE=https://aiproxies.win/v1 OPENAI_API_KEY=YOUR_PROXY_KEY \
qcr --provider openai --model minimax-m2.5 "refactor this module"| Provider | --provider |
API key env var |
|---|---|---|
| OpenAI | openai |
OPENAI_API_KEY |
| Anthropic | anthropic |
ANTHROPIC_API_KEY |
| Google Gemini | gemini |
GEMINI_API_KEY |
| DashScope (Qwen) | dashscope |
DASHSCOPE_API_KEY |
| GitHub Copilot | copilot |
GH_COPILOT_TOKEN (or auto from ~/.config/github-copilot/hosts.json) |
| Azure OpenAI | azure |
AZURE_OPENAI_API_KEY |
| MiniMax | openai + OPENAI_API_BASE |
proxy key |
| OpenRouter | openai + OPENAI_API_BASE |
OPENROUTER_API_KEY |
| Ollama (local) | openai |
any non-empty string |
Switch models per session without changing settings:
qcr --model gemini-2.5-flash "summarize this PR"
qcr --model minimax-m2.5-highspeed "quick review"Config is layered in this order (later wins):
- Built-in defaults
~/.qcr/settings.json— global.qcr/settings.json— project-local- Environment variables
Minimal ~/.qcr/settings.json:
{
"model": { "model_id": "qwen3-coder", "provider": "dashscope" },
"providers": {
"dashscope": { "api_key": "sk-..." }
},
"approval_mode": "suggest"
}Key environment variables:
| Variable | Description |
|---|---|
QCR_MODEL |
Model ID |
QCR_PROVIDER |
Provider name |
OPENAI_API_KEY |
API key for OpenAI-compatible providers |
OPENAI_API_BASE |
Override base URL (proxies, local LLMs) |
QCR_APPROVAL_MODE |
always / never / suggest |
QCR_MAX_TURNS |
Max agent loop iterations |
QCR_MEMORIX_URL |
Memorix API base URL (default http://localhost:8420) |
QCR_DISABLE_CRON |
Set to 1 to disable the session-scoped cron scheduler |
QCR_SAFETY_CLASSIFIER |
true / false — enable/disable safety classifier in auto mode |
QCR_SAFETY_CLASSIFIER_MODEL |
Override model for safety classifier |
See docs/configuration.md for the full reference.
| Tool | Description | Approval |
|---|---|---|
ReadFile |
Read file contents with optional line range | auto |
WriteFile |
Create or overwrite a file | prompt |
EditFile |
Find-and-replace with unified diff output | prompt |
UndoEdit |
Revert a file to its previous state (per-file undo stack) | prompt |
FormatFile |
Auto-format with rustfmt / prettier / ruff / gofmt / … | prompt |
FindAndEdit |
Regex find-and-replace across a directory tree | prompt |
Mermaid |
Validate and write a Mermaid diagram to .md or .mmd |
prompt |
CreateDirectory |
mkdir -p |
auto |
CopyPath / MovePath / DeletePath |
Safety-first path ops with deny-list, dry-run | prompt |
CronCreate / CronList / CronDelete |
Session-scoped cron scheduling | auto |
Shell |
Run a shell command | prompt |
Glob / Grep / ListDirectory |
File search & listing | auto |
WebFetch / WebSearch |
Fetch URL / DuckDuckGo search | auto |
Lsp |
One-shot LSP hover / definition / references | auto |
GetSkill |
Load a skill by name (built-ins + disk + plugins) | auto |
Memory |
Read/write/append QCR.md persistent notes |
auto |
Now |
Current datetime (RFC 3339) | auto |
Thinking |
Visible chain-of-thought scratchpad | auto |
Task |
Spawn a sub-agent for a focused task | prompt |
TodoWrite |
Structured task list for the session | auto |
Oracle |
Second-opinion LLM | auto |
ToolSearch |
Search deferred tools and fetch schemas on-demand | auto |
SpawnTeammate / SendMessage |
Team-based multi-agent work | prompt / auto |
ConfigTool |
Read or modify qcr config at runtime | auto |
AskUserQuestion |
Prompt the user mid-conversation | auto |
Browser |
Browser automation (navigate, click, screenshot, extract) | prompt |
| Command | Description |
|---|---|
/help |
Show available commands |
/clear |
Clear conversation history |
/model <name> |
Switch model mid-session |
/plan |
Toggle plan mode (describe without executing) |
/compact |
Compress older turns to save context |
/undo |
Revert the last file edit |
/spec <feature> |
Start a spec-driven workflow (EARS → design → tasks) |
/sessions / /resume <id> / /title <text> |
Session management |
/loop [interval] <prompt> |
Schedule a recurring prompt (default every 10 m) |
/batch <instruction> |
Decompose changes into parallel worktree agents |
/simplify |
3-agent parallel code review (reuse, quality, efficiency) |
/verify |
Adversarial verification (PASS / FAIL / PARTIAL verdict) |
/fork |
Branch the current conversation |
/insights |
Session analytics |
/rewind [turn] |
Restore files to a previous checkpoint |
/think <mode> |
Set thinking mode (off / budget / adaptive / ultra) |
/usage |
Show token usage, cost estimate, cache hit rate |
qcr [OPTIONS] [PROMPT]
Options:
-m, --model <MODEL> LLM model ID
--provider <PROVIDER> Provider name
-p, --print One turn, output to stdout, exit
--headless No TUI, plain text streaming
--approval-mode <MODE> always | never | suggest [default: suggest]
-P, --plan-mode Start in plan mode
--max-turns <N> Max agent loop turns [default: 20]
--resume <SESSION_ID> Resume a saved session
-f, --output-format <FORMAT> text | json | jsonl [default: text]
--system-prompt <TEXT> Override system prompt
-v, --verbose Enable debug logging
-h, --help Print help
Subcommands:
info Print version info
config show|get|set|edit|path Manage configuration
session list|resume|delete|clear Manage sessions
mcp list List MCP servers
plugin list|install|remove Manage plugins
qcr integrates with memorix for automatic cross-session semantic memory. When enabled, qcr searches memorix at session start for relevant context and stores a session summary at session end — invisible to the user and LLM.
Enable in .qcr/settings.json:
{ "memorix": { "enabled": true } }All fields are optional with sensible defaults. If memorix is unreachable, qcr continues normally with no errors.
Add external tool servers in your settings:
{
"mcp_servers": {
"my-server": {
"transport": "stdio",
"command": "/usr/local/bin/my-mcp-server",
"args": [],
"auto_approve": false
}
}
}MCP tools are registered as deferred — only their names appear in the system prompt. Use the ToolSearch tool to fetch full schemas on-demand, saving tokens when many MCP tools are registered.
See docs/architecture.md for the full MCP integration details.
qcr automatically caches the static portion of the system prompt to reduce per-turn token cost:
| Provider | Cache Support |
|---|---|
| Anthropic | cache_control: ephemeral on system blocks + anthropic-beta header |
| OpenAI / Azure / Copilot | Structured system message with cache_control + automatic prefix caching |
| Gemini | Not supported |
Skills are listed as name + description only (lazy loading); full instructions fetched via GetSkill on demand. MCP tools are deferred; schemas fetched via ToolSearch on demand. Combined savings: ~15–25K tokens per turn.
See docs/prompt-architecture.md.
# Build
cargo build
# Test (1948+ tests)
cargo test --workspace
# Lint
cargo clippy --workspace -- -D warnings
# Format
cargo fmt --all
# Benchmarks (9 criterion benchmarks)
cargo bench --no-run # compile check
cargo bench # run all
# Run CLI directly
cargo run --package qcr-cli -- --print "hello"See docs/development.md for a full guide on adding tools and providers.
qwen-code-rust/
├── crates/
│ ├── qcr-core/ # Core library: agent loop, tools, LLM clients, config, plugins, skills
│ └── qcr-cli/ # CLI + TUI binary (produces `qcr` executable)
├── docs/ # Architecture, prompts, tools, providers, plugins, config
├── examples/ # Usage examples (including a web UI with AG-UI adapter)
├── scripts/ # Utility scripts
└── .qcr/ # Project-local settings, plugins, skills, steering files
| Doc | Description |
|---|---|
| docs/architecture.md | Crate layout, data flow, SSE pipeline, module map |
| docs/acp.md | ACP protocol reference — IDE integration over ndjson stdio |
| docs/cli.md | Full CLI reference |
| docs/configuration.md | Config schema, all fields, env vars, MCP |
| docs/providers.md | Provider setup, proxy config, troubleshooting |
| docs/tools.md | Tool schemas, approval behaviour, custom tool guide |
| docs/prompt-architecture.md | System prompt assembly, caching, lazy skills, deferred tools |
| docs/scheduled-tasks.md | Session-scoped cron scheduling |
| docs/plugins.md | Plugin system — slash commands, skills, hooks, MCP |
| docs/auto-mode.md | Auto mode & safety classifier |
| docs/skills-reference.md | Built-in skills reference |
| docs/session-management.md | Sessions, fork, insights |
| docs/parallel-tools.md | Parallel tools & compaction |
| docs/development.md | Build, test, lint, adding tools/providers, CI |
qcr draws inspiration from and is compatible with the Claude Code plugin ecosystem, the Agent Client Protocol (ACP), the Model Context Protocol (MCP), and the AG-UI runtime. Originally developed as an internal project; this repository is a clean-room Rust implementation optimized for speed, memory footprint, and hackability.
Qwen and Qwen Code are trademarks of Alibaba Group. This project is an independent open-source Rust implementation; not officially affiliated with Alibaba.
Apache-2.0 — see LICENSE (or the license field in Cargo.toml).
Copyright 2026 Qwen Code Rust Contributors.