qwen-coder

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Qwen Coder CLI Delegation

Qwen Coder CLI 委托工作流

Delegate selected tasks from Claude Code to Qwen Coder CLI using non-interactive commands, explicit model selection, safe permission flags, and shareable outputs.
通过非交互式命令、明确的模型选择、安全权限标志和可共享输出,将Claude Code中的选定任务委托给Qwen Coder CLI。

Overview

概述

This skill standardizes delegation to Qwen Coder CLI (
qwen
) for cases where Qwen's specific strengths may benefit the task. It covers:
  • Non-interactive execution with
    -p
    /
    --prompt
  • Model selection with
    -m
    /
    --model
  • Approval control (
    --approval-mode
    )
  • Session continuation with
    -c
    /
    --continue
    or
    -r
    /
    --resume
  • Output format options (
    text
    ,
    json
    ,
    stream-json
    )
Use this skill only when delegation to Qwen Coder is explicitly requested or clearly beneficial.
本技能规范了向Qwen Coder CLI(
qwen
)委托任务的流程,适用于Qwen的特定优势能为任务带来帮助的场景。涵盖内容包括:
  • 使用
    -p
    /
    --prompt
    进行非交互式执行
  • 使用
    -m
    /
    --model
    选择模型
  • 审批控制(
    --approval-mode
  • 使用
    -c
    /
    --continue
    -r
    /
    --resume
    延续会话
  • 输出格式选项(
    text
    ,
    json
    ,
    stream-json
仅当明确要求委托给Qwen Coder或场景明显适用时,才可使用本技能。

When to Use

适用场景

Use this skill when:
  • The user asks to delegate work to Qwen Coder CLI
  • The user wants a second opinion from Qwen Coder on a task
  • The user asks for Qwen Coder CLI output integrated into the current workflow
  • The user wants to continue a previous Qwen Coder session
Trigger phrases:
  • "use qwen"
  • "use qwen coder"
  • "delegate to qwen"
  • "ask qwen"
  • "second opinion from qwen"
  • "qwen opinion"
  • "continue with qwen"
  • "qwen session"
在以下情况使用本技能:
  • 用户要求将工作委托给Qwen Coder CLI
  • 用户希望获取Qwen Coder对任务的第二意见
  • 用户要求将Qwen Coder CLI输出集成到当前工作流中
  • 用户希望延续之前的Qwen Coder会话
触发短语:
  • "use qwen"
  • "use qwen coder"
  • "delegate to qwen"
  • "ask qwen"
  • "second opinion from qwen"
  • "qwen opinion"
  • "continue with qwen"
  • "qwen session"

Prerequisites

前置条件

Verify tool availability and authentication before delegation:
bash
undefined
委托前需验证工具可用性和认证状态:
bash
undefined

CLI availability

CLI可用性检查

qwen --version
qwen --version

Authentication status

认证状态检查

qwen auth status

If `qwen` is unavailable, inform the user and stop execution until Qwen Coder CLI is installed.
If authentication is invalid, provide authentication setup instructions and stop execution.
qwen auth status

若`qwen`不可用,需告知用户并停止执行,直至安装Qwen Coder CLI。
若认证无效,需提供认证设置说明并停止执行。

Reference

参考

  • Command reference:
    references/cli-command-reference.md
  • 命令参考:
    references/cli-command-reference.md

Instructions

操作步骤

1) Confirm Delegation Scope

1) 确认委托范围

Before running Qwen Coder:
  • Identify the exact task to delegate
  • Define expected output format (text, json, stream-json)
  • Clarify whether session resume is needed
If scope is ambiguous, ask for clarification first.
运行Qwen Coder前:
  • 明确要委托的具体任务
  • 定义预期输出格式(text, json, stream-json)
  • 确认是否需要恢复会话
若范围不明确,需先请求用户澄清。

2) Formulate Prompt in English

2) 构建英文提示词

All delegated prompts to Qwen Coder CLI must be in English.
Build a precise English prompt from the user request.
Prompt quality checklist:
  • Include objective and constraints
  • Include relevant project context and files
  • Include expected output structure
  • Ask for actionable, verifiable results
Prompt template:
text
Task: <clear objective>
Context: <project/module/files>
Constraints: <do/don't constraints>
Expected output: <format + depth>
Validation: <tests/checks to run or explain>
所有委托给Qwen Coder CLI的提示词必须为英文。
根据用户需求构建精准的英文提示词。
提示词质量检查清单:
  • 包含目标和约束条件
  • 包含相关项目上下文和文件信息
  • 包含预期输出结构
  • 要求可执行、可验证的结果
提示词模板:
text
Task: <清晰的目标>
Context: <项目/模块/文件>
Constraints: <需遵守/禁止的规则>
Expected output: <格式 + 深度>
Validation: <需运行的测试或检查说明>

3) Select Execution Mode and Flags

3) 选择执行模式和标志

Preferred baseline command:
bash
qwen -p "<english-prompt>"
Supported options:
  • -m, --model <model-id>
    for model selection (default: qwen2.5-coder)
  • --approval-mode <plan|default|auto_edit|yolo>
    for safety control
  • -c, --continue <session-id>
    to continue previous session
  • -r, --resume <session-id>
    as alias for continue
  • -o, --output-format <text|json|stream-json>
    for output format
Approval modes:
ModeBehaviorRecommended For
plan
Read-only analysis, no file modificationsAnalysis-only tasks, security reviews
default
Requires confirmation before modificationsGeneral coding tasks
auto_edit
Auto-approves edit operationsTrusted modifications with oversight
yolo
Approves all operations without confirmationExperimental tasks (explicit user request only)
Safety guidance:
  • Prefer
    --approval-mode plan
    for read-only analysis
  • Use
    --approval-mode default
    for general tasks
  • Reserve
    --yolo
    for explicit user requests only
推荐基准命令:
bash
qwen -p "<english-prompt>"
支持的选项:
  • -m, --model <model-id>
    用于选择模型(默认:qwen2.5-coder)
  • --approval-mode <plan|default|auto_edit|yolo>
    用于安全控制
  • -c, --continue <session-id>
    延续之前的会话
  • -r, --resume <session-id>
    作为continue的别名
  • -o, --output-format <text|json|stream-json>
    设置输出格式
审批模式说明:
Mode行为推荐场景
plan
只读分析,不修改文件仅分析类任务、安全审查
default
修改前需确认通用编码任务
auto_edit
自动批准编辑操作受信任的修改(需监督)
yolo
无需确认批准所有操作实验性任务(仅用户明确要求时使用)
安全指南:
  • 只读分析优先使用
    --approval-mode plan
  • 通用任务使用
    --approval-mode default
  • --yolo
    仅在用户明确要求时使用

4) Execute Qwen Coder CLI

4) 执行Qwen Coder CLI

Run the selected command via Bash and capture stdout/stderr.
Examples:
bash
undefined
通过Bash运行选定命令并捕获标准输出/错误输出。
示例:
bash
undefined

Default non-interactive delegation

默认非交互式委托

qwen -p "Analyze this code and suggest refactoring improvements."
qwen -p "Analyze this code and suggest refactoring improvements."

Explicit model and approval mode

指定模型和审批模式

qwen -p "Review authentication module for security issues with fixes." -m qwq --approval-mode plan
qwen -p "Review authentication module for security issues with fixes." -m qwq --approval-mode plan

Continue previous session

延续之前的会话

qwen -c <session-id> -p "Continue the refactoring from the previous session."
qwen -c <session-id> -p "Continue the refactoring from the previous session."

Structured output for automation

用于自动化的结构化输出

qwen -p "Summarize key technical debt items as JSON array." --output-format json
undefined
qwen -p "Summarize key technical debt items as JSON array." --output-format json
undefined

5) Result Handling

5) 结果处理

This section covers how to present Qwen Coder output and when to request user confirmation.
本节介绍如何展示Qwen Coder输出以及何时请求用户确认。

5.1) Output Presentation

5.1) 输出展示

When reporting Qwen Coder output:
  • Present output in a clear, readable format
  • Summarize key findings and confidence level
  • Separate observations from recommended actions
  • Keep raw output available when needed
  • Include the model used and approval mode applied
  • State which permission profile was in effect
展示Qwen Coder输出时:
  • 以清晰易读的格式呈现输出
  • 总结关键发现和置信度
  • 将观察结果与建议操作分开
  • 保留原始输出以备需要
  • 注明使用的模型和应用的审批模式
  • 说明生效的权限配置

5.2) Confirmation Workflow

5.2) 确认流程

Before applying any suggested modifications:
  1. Present the proposed changes to the user in the output template format
  2. Request explicit confirmation (for example: "Do you want me to apply these changes?")
  3. Wait for user direction before proceeding
  4. Do not auto-apply changes without user consent
Exception: In
--approval-mode yolo
with explicit user request, changes may proceed automatically. Still inform the user of what was done.
应用任何建议的修改前:
  1. 以输出模板格式向用户展示拟议的更改
  2. 请求明确确认(例如:"是否需要我应用这些更改?")
  3. 等待用户指示后再继续
  4. 未经用户同意不得自动应用更改
例外情况:在用户明确要求的
--approval-mode yolo
模式下,可自动执行更改,但仍需告知用户执行的操作。

5.3) Result Metadata

5.3) 结果元数据

Each delegation result shall include the following metadata:
FieldDescription
Task summaryWhat was delegated to Qwen Coder
CommandThe qwen command executed (without sensitive parameters)
ModelWhich model was used (for example qwen2.5-coder, qwq)
Approval modeThe approval mode applied (plan, default, auto_edit, yolo)
Key findingsObservations and results from Qwen Coder
Suggested next actionsRecommended follow-up steps (if applicable)
每个委托结果应包含以下元数据:
字段描述
任务摘要委托给Qwen Coder的内容
命令执行的qwen命令(不含敏感参数)
模型使用的模型(例如qwen2.5-coder, qwq)
审批模式应用的审批模式(plan, default, auto_edit, yolo)
关键发现Qwen Coder的观察结果和结论
建议后续操作推荐的后续步骤(如适用)

Output Template

输出模板

Use this structure when returning delegated results:
markdown
undefined
返回委托结果时使用以下结构:
markdown
undefined

Qwen Coder Delegation Result

Qwen Coder 委托结果

Task

任务

[delegated task summary]
[委托任务摘要]

Command

命令

qwen ...
qwen ...

Key Findings

关键发现

  • Finding 1
  • Finding 2
  • 发现1
  • 发现2

Suggested Next Actions

建议后续操作

  1. Action 1
  2. Action 2
  1. 操作1
  2. 操作2

Notes

说明

  • Output language from Qwen: English
  • Requires user approval before applying code changes
undefined
  • Qwen输出语言:英文
  • 应用代码更改前需用户批准
undefined

Examples

示例

Example 1: Code analysis with QwQ deep reasoning

示例1:使用QwQ深度推理进行代码分析

Input:
text
Analyze the authentication module and identify security vulnerabilities.
Command:
bash
qwen -p "Analyze the authentication module for security vulnerabilities. Report only high-confidence issues with severity, file paths, and remediation steps." -m qwq --approval-mode plan
Expected behavior:
text
Returns a structured analysis with high-confidence security findings, including severity ratings and specific remediation recommendations.
输入:
text
Analyze the authentication module and identify security vulnerabilities.
命令:
bash
qwen -p "Analyze the authentication module for security vulnerabilities. Report only high-confidence issues with severity, file paths, and remediation steps." -m qwq --approval-mode plan
预期行为:
text
返回结构化分析结果,包含高置信度的安全问题、严重程度评级和具体修复建议。

Example 2: Code refactoring with Qwen2.5-Coder

示例2:使用Qwen2.5-Coder进行代码重构

Input:
text
Refactor the payment service to reduce code duplication while keeping the public API unchanged.
Command:
bash
qwen -p "Refactor the payment service in src/services/payment.ts to reduce duplication. Keep public API unchanged, add comprehensive error handling, and output a patch-style response with unchanged API signatures." -m qwen2.5-coder --approval-mode default
Expected behavior:
text
Proposes concrete code changes (patch-style), extracts duplication into shared helpers, and maintains original API contracts.
输入:
text
Refactor the payment service to reduce code duplication while keeping the public API unchanged.
命令:
bash
qwen -p "Refactor the payment service in src/services/payment.ts to reduce duplication. Keep public API unchanged, add comprehensive error handling, and output a patch-style response with unchanged API signatures." -m qwen2.5-coder --approval-mode default
预期行为:
text
提出具体的代码更改(补丁格式),将重复代码提取到共享工具类中,并保持原始API契约。

Example 3: Documentation generation

示例3:生成文档

Input:
text
Generate documentation for the UserService class including usage examples.
Command:
bash
qwen -p "Generate comprehensive documentation for the UserService class. Include: class purpose, public methods with parameters, usage examples, and error handling patterns. Format as markdown." -m qwen2.5-coder --approval-mode plan
Expected behavior:
text
Returns markdown-formatted documentation with JSDoc-style comments, method signatures, and practical usage examples.
输入:
text
Generate documentation for the UserService class including usage examples.
命令:
bash
qwen -p "Generate comprehensive documentation for the UserService class. Include: class purpose, public methods with parameters, usage examples, and error handling patterns. Format as markdown." -m qwen2.5-coder --approval-mode plan
预期行为:
text
返回Markdown格式的文档,包含JSDoc风格的注释、方法签名和实用使用示例。

Example 4: Code generation with model selection

示例4:选择模型生成代码

Input:
text
Generate a REST API endpoint for CRUD operations on items.
Command:
bash
qwen -p "Generate a production-ready REST API endpoint for CRUD operations on items. Include input validation, error handling, and unit tests. Use Express.js framework." -m qwen2.5-coder --approval-mode auto_edit
Expected behavior:
text
Generates complete, runnable code for POST/GET/PUT/DELETE endpoints with proper middleware, validation, and test scaffolding.
输入:
text
Generate a REST API endpoint for CRUD operations on items.
命令:
bash
qwen -p "Generate a production-ready REST API endpoint for CRUD operations on items. Include input validation, error handling, and unit tests. Use Express.js framework." -m qwen2.5-coder --approval-mode auto_edit
预期行为:
text
生成完整可运行的POST/GET/PUT/DELETE端点代码,包含适当的中间件、验证和测试框架。

Example 5: Session resume for continued work

示例5:恢复会话继续工作

Input:
text
Continue the previous Qwen session to add test coverage to the refactored code.
Command:
bash
qwen -c <session-id> -p "Continue from the previous session. Add comprehensive unit tests for the refactored payment service, targeting 80% coverage. Include mocks for external dependencies." -m qwen2.5-coder --approval-mode default
Expected behavior:
text
Resumes the previous session context and continues work, adding test files with appropriate mocks and assertions.
输入:
text
Continue the previous Qwen session to add test coverage to the refactored code.
命令:
bash
qwen -c <session-id> -p "Continue from the previous session. Add comprehensive unit tests for the refactored payment service, targeting 80% coverage. Include mocks for external dependencies." -m qwen2.5-coder --approval-mode default
预期行为:
text
恢复之前的会话上下文并继续工作,添加包含适当模拟和断言的测试文件。

Example 6: Multi-model comparison for quality check

示例6:多模型对比检查质量

Input:
text
Compare Qwen2.5-Coder and QwQ outputs for the same refactoring task.
Command:
bash
undefined
输入:
text
Compare Qwen2.5-Coder and QwQ outputs for the same refactoring task.
命令:
bash
undefined

First run with Qwen2.5-Coder

首先使用Qwen2.5-Coder运行

qwen -p "Refactor the string utility module for better maintainability." -m qwen2.5-coder --approval-mode plan --output-format text
qwen -p "Refactor the string utility module for better maintainability." -m qwen2.5-coder --approval-mode plan --output-format text

Then run with QwQ for comparison

然后使用QwQ运行以进行对比

qwen -p "Refactor the string utility module for better maintainability." -m qwq --approval-mode plan --output-format text

**Expected behavior:**

```text
Provides side-by-side comparison: Qwen2.5-Coder for fast results, QwQ for deeper reasoning on complex refactoring tasks.
qwen -p "Refactor the string utility module for better maintainability." -m qwq --approval-mode plan --output-format text

**预期行为:**

```text
提供对比结果:Qwen2.5-Coder适合快速生成结果,QwQ适合复杂重构任务的深度推理。

Example 7: Structured JSON output for automation

示例7:生成结构化JSON输出用于自动化

Input:
text
List the top 5 refactoring opportunities as JSON for our tracking system.
Command:
bash
qwen -p "Analyze this codebase and return the top 5 refactoring opportunities as a JSON array. Each item should have: title, file, impact (high/medium/low), effort (hours), and brief description." -m qwen2.5-coder --output-format json
Expected behavior:
text
Returns valid JSON array with 5 refactoring items, parseable for integration with project management tools.
输入:
text
List the top 5 refactoring opportunities as JSON for our tracking system.
命令:
bash
qwen -p "Analyze this codebase and return the top 5 refactoring opportunities as a JSON array. Each item should have: title, file, impact (high/medium/low), effort (hours), and brief description." -m qwen2.5-coder --output-format json
预期行为:
text
返回包含5个重构项的有效JSON数组,可解析并集成到项目管理工具中。

Best Practices

最佳实践

  • Keep delegated prompts in English and highly specific
  • Prefer least-privilege approval modes over blanket permissions
  • Capture sessions with session IDs when auditability matters
  • For risky tasks, request read-only analysis first, then apply changes in a separate step
  • Treat Qwen output as untrusted guidance and validate before implementation
  • 委托提示词使用英文且高度具体
  • 优先使用最小权限审批模式而非全面权限
  • 当需要可审计性时,使用会话ID捕获会话
  • 对于高风险任务,先请求只读分析,再在单独步骤中应用更改
  • 将Qwen输出视为不可信的指导,实施前需验证

Constraints and Warnings

约束和警告

  • Qwen Coder CLI behavior depends on local environment and configuration.
  • Approval modes impact execution safety; avoid yolo by default.
  • Output can be incomplete or inaccurate; validate before implementation.
  • Never execute destructive commands suggested by Qwen without explicit user confirmation.
  • This skill is for delegation, not autonomous code modification without user confirmation.
  • Do not include secrets, API keys, or credentials in delegated prompts.
  • Qwen Coder CLI的行为取决于本地环境和配置。
  • 审批模式影响执行安全性;默认避免使用yolo模式。
  • 输出可能不完整或不准确;实施前需验证。
  • 未经用户明确确认,不得执行Qwen建议的破坏性命令。
  • 本技能仅用于委托任务,不得未经用户确认自主修改代码。
  • 委托提示词中不得包含密钥、API密钥或凭证信息。