Qwen Code
by @userb1ank
Run Alibaba Cloud Qwen Code CLI via background process for task execution, code review, and automation.
clawhub install qwen-code-skillπ About This Skill
name: qwen-code description: Run Alibaba Cloud Qwen Code CLI via background process for task execution, code review, and automation. metadata: {"clawdbot":{"emoji":"π¦","requires":{"anyBins":["qwen"]}}} author: UserB1ank
Qwen Code Skill (background-first)
Use bash background mode for non-interactive coding work with Qwen Code CLI.
The Pattern: workdir + background
# Start Qwen Code in target directory
bash workdir:~/project background:true yieldMs:30000 command:"qwen -p 'Build a Flask API'"
Returns sessionId for tracking
Monitor progress
process action:log sessionId:XXXCheck if done
process action:poll sessionId:XXXSend input (if Qwen asks a question)
process action:write sessionId:XXX data:"y"Kill if needed
process action:kill sessionId:XXX
Why workdir matters: Agent wakes up in a focused directory, doesn't wander off reading unrelated files.
Quick Start
Prerequisites
# Install Qwen Code CLI
npm install -g @qwen-code/qwen-code@latestVerify installation
qwen --versionAuthenticate (Option 1: OAuth)
qwen auth loginOr Option 2: API Key
export DASHSCOPE_API_KEY="sk-xxx"
Basic Usage
# Check status
scripts/qwen-code.js statusRun a task
scripts/qwen-code.js run "Create a Flask API"Code review
scripts/qwen-code.js review src/app.tsHeadless mode (JSON output)
scripts/qwen-code.js headless "Analyze code" -o json
Commands
| Command | Description | Example |
|---------|-------------|---------|
| status | Check Qwen Code status and authentication | scripts/qwen-code.js status |
| run | Execute programming task | scripts/qwen-code.js run "Create REST API" |
| review | Code review and analysis | scripts/qwen-code.js review src/main.py |
| headless | Headless mode (JSON output) | scripts/qwen-code.js headless "Analyze" -o json |
| help | Show help information | scripts/qwen-code.js help |
OpenClaw Integration
Background Execution
# Basic task
bash workdir:~/project background:true yieldMs:30000 \
command:"qwen -p 'Create Python Flask API'"Specify model
bash workdir:~/project background:true yieldMs:30000 \
command:"qwen -p 'Analyze code structure' -m qwen3-coder-plus"YOLO mode (auto-approve)
bash workdir:~/project background:true yieldMs:30000 \
command:"qwen -p 'Refactor this function' -y"
Process Management
# View logs
process action:log sessionId:XXXCheck completion
process action:poll sessionId:XXXSend input (if Qwen asks)
process action:write sessionId:XXX data:"y"
Headless Mode (Automation/CI/CD)
# JSON output
qwen -p "Analyze code structure" --output-format jsonPipeline operations
git diff | qwen -p "Generate commit message"Batch processing
find src -name "*.ts" | xargs -I {} qwen -p "Review {}"
Models
Qwen Code supports Alibaba Cloud models:
qwen3.5-plus - General purpose (default)qwen3-coder-plus - Coding specializedqwen3-coder-next - Latest coding modelqwen3-max-2026-01-23 - Most capableSpecify model:
bash workdir:~/project background:true yieldMs:30000 \
command:"qwen -p 'Refactor this' -m qwen3-coder-plus"
Authentication
OAuth (Recommended)
qwen auth login
Opens browser for OAuth flow. Token auto-refreshes.
API Key
export DASHSCOPE_API_KEY="sk-xxx"
Get key from: https://dashscope.console.aliyun.com/
β οΈ Rules
1. Respect tool choice β if user asks for Qwen, use Qwen. NEVER offer to build it yourself!
2. Be patient β don't kill sessions because they're "slow"
3. Monitor with process:log β check progress without interfering
4. YOLO mode for building β --yolo auto-approves changes (use in workspace only)
5. Review mode for safety β production code should use review mode
6. Parallel is OK β run many Qwen processes at once for batch work
7. NEVER start Qwen in ~/clawd/ β it'll read your soul docs! Use target project dir or /tmp
8. Workspace safety β YOLO mode is safe in agents.defaults.workspace, not elsewhere
For
Not For
Security & Boundaries
| Component | Behavior | Executes Shell Commands? |
|-----------|----------|-------------------------|
| scripts/qwen-code.js | Wraps Qwen Code CLI commands | Yes (via qwen command) |
| references/qwen-cli-commands.md | Command reference documentation | No (plain text) |
| assets/examples/ | Example code files | No (static files) |
β οΈ Security Notes
Examples
See assets/examples/ for complete examples:
| Example | Description |
|---------|-------------|
| basic-task.example.sh | Basic task execution |
| code-review.example.sh | Code review workflow |
| ci-cd.example.yml | GitHub Actions integration |
| headless-mode.example.js | Node.js automation example |
References
Troubleshooting
"qwen: command not found"
npm install -g @qwen-code/qwen-code@latest
"Authentication required"
qwen auth login
Or set API key
export DASHSCOPE_API_KEY="sk-xxx"
Session stuck/waiting for input
# Check what Qwen is asking
process action:log sessionId:XXXSend approval
process action:write sessionId:XXX data:"y"
Kill stuck session
process action:kill sessionId:XXX
*Qwen Code Skill π¦ - Your AI coding partner powered by Alibaba Cloud*
π‘ Examples
See assets/examples/ for complete examples:
| Example | Description |
|---------|-------------|
| basic-task.example.sh | Basic task execution |
| code-review.example.sh | Code review workflow |
| ci-cd.example.yml | GitHub Actions integration |
| headless-mode.example.js | Node.js automation example |
βοΈ Configuration
# Install Qwen Code CLI
npm install -g @qwen-code/qwen-code@latestVerify installation
qwen --versionAuthenticate (Option 1: OAuth)
qwen auth loginOr Option 2: API Key
export DASHSCOPE_API_KEY="sk-xxx"
Basic Usage
# Check status
scripts/qwen-code.js statusRun a task
scripts/qwen-code.js run "Create a Flask API"Code review
scripts/qwen-code.js review src/app.tsHeadless mode (JSON output)
scripts/qwen-code.js headless "Analyze code" -o json
π Tips & Best Practices
"qwen: command not found"
npm install -g @qwen-code/qwen-code@latest
"Authentication required"
qwen auth login
Or set API key
export DASHSCOPE_API_KEY="sk-xxx"
Session stuck/waiting for input
# Check what Qwen is asking
process action:log sessionId:XXXSend approval
process action:write sessionId:XXX data:"y"
Kill stuck session
process action:kill sessionId:XXX
*Qwen Code Skill π¦ - Your AI coding partner powered by Alibaba Cloud*