mcpField
Q
qwen-coder

qwen-coder

github.com/giuseppe-trisciuoglioAgent 工作流3653.3k 次安装7 周前更新
代码仓库

关于 qwen-coder

qwen-coder 是用于将选定任务委派给 Qwen Coder CLI 的 Claude Code Skill。它规范了非交互式命令、模型与审批模式选择、会话续接及结果处理。

主要功能

  1. 01非交互式 CLI 委派
  2. 02选择模型和审批模式
  3. 03续接或恢复会话
  4. 04支持 text、JSON 和 stream-JSON 输出
  5. 05结果汇报与确认流程

适用场景

  1. 01征求 Qwen Coder 的第二意见
  2. 02委派代码分析或文档编写
  3. 03继续之前的 Qwen 会话

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill qwen-coder

安装后在 Claude Code 中输入/qwen-coder确认已加载。

附带文件references/cli-command-reference.md

详细介绍

Qwen Coder CLI 委派

通过非交互式命令、显式选择模型、安全的权限标志以及可分享的输出,将选定任务从 Claude Code 委派给 Qwen Coder CLI。

概述

此技能统一了在 Qwen 的特定优势可能有助于完成任务时,向 Qwen Coder CLI(qwen)委派工作的方式。内容包括:

  • 使用 -p / --prompt 进行非交互式执行
  • 使用 -m / --model 选择模型
  • 控制审批(--approval-mode)
  • 使用 -c / --continue 或 -r / --resume 继续会话
  • 输出格式选项(text、json、stream-json)

仅在用户明确要求委派给 Qwen Coder,或委派显然有益时,才使用此技能。

适用场景

在以下情况下使用此技能:

  • 用户要求将工作委派给 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”

前置条件

委派前,请确认工具可用且已完成身份验证:

# CLI availability
qwen --version

# Authentication status
qwen auth status

如果 qwen 不可用,请告知用户并停止执行,直到安装 Qwen Coder CLI。 如果身份验证无效,请提供身份验证设置说明并停止执行。

参考资料

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

操作说明

1) 确认委派范围

运行 Qwen Coder 前:

  • 明确要委派的具体任务
  • 定义预期输出格式(text、json、stream-json)
  • 确认是否需要恢复会话

如果范围不明确,请先询问并澄清。

2) 用英语编写提示词

所有委派给 Qwen Coder CLI 的提示词都必须使用英语。

根据用户请求编写精确的英文提示词。

提示词质量检查清单:

  • 包含目标和约束
  • 包含相关的项目背景和文件
  • 包含预期的输出结构
  • 要求提供可执行、可验证的结果

提示词模板:

Task: <clear objective>
Context: <project/module/files>
Constraints: <do/don't constraints>
Expected output: <format + depth>
Validation: <tests/checks to run or explain>
3) 选择执行模式和标志

推荐的基础命令:

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> 用于设置输出格式

审批模式:

模式行为推荐用途
plan只读分析,不修改文件仅分析任务、安全审查
default修改前需要确认通用编码任务
auto_edit自动批准编辑操作在监督下进行可信修改
yolo无需确认即可批准所有操作实验性任务(仅限用户明确要求)

安全指南:

  • 只读分析优先使用 --approval-mode plan
  • 通用任务使用 --approval-mode default
  • 仅在用户明确要求时使用 --yolo
4) 执行 Qwen Coder CLI

通过 Bash 运行选定的命令并捕获 stdout/stderr。

示例:

# Default non-interactive delegation
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

# Continue 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
5) 处理结果

本节介绍如何呈现 Qwen Coder 的输出,以及何时需要请求用户确认。

5.1) 呈现输出

报告 Qwen Coder 的输出时:

  • 以清晰易读的格式呈现输出
  • 总结关键发现和置信度
  • 将观察结果与建议操作分开
  • 必要时保留原始输出以供查阅
  • 注明所用模型和采用的审批模式
  • 说明当前生效的权限配置
5.2)确认工作流

应用任何建议的修改之前:

  1. 按输出模板格式向用户展示拟议的更改
  2. 请求用户明确确认(例如:“要我应用这些更改吗?”)
  3. 等待用户指示后再继续
  4. 未经用户同意,不要自动应用更改

例外:在 --approval-mode yolo 模式下,如果用户明确提出请求,可以自动进行更改。仍需告知用户已完成的操作。

5.3)结果元数据

每项委派结果都应包含以下元数据:

字段描述
任务摘要委派给 Qwen Coder 的内容
命令执行的 qwen 命令(不含敏感参数)
模型使用的模型(例如 qwen2.5-coder、qwq)
审批模式所采用的审批模式(plan、default、auto_edit、yolo)
关键发现Qwen Coder 的观察结果和结论
建议的后续操作推荐的后续步骤(如适用)

输出模板

返回委派结果时使用以下结构:

## Qwen Coder Delegation Result

### Task
[delegated task summary]

### Command
`qwen ...`

### Key Findings
- Finding 1
- Finding 2

### Suggested Next Actions
1. Action 1
2. Action 2

### Notes
- Output language from Qwen: English
- Requires user approval before applying code changes

示例

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

输入:

Analyze the authentication module and identify security vulnerabilities.

命令:

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

预期行为:

Returns a structured analysis with high-confidence security findings, including severity ratings and specific remediation recommendations.
示例 2:使用 Qwen2.5-Coder 重构代码

输入:

Refactor the payment service to reduce code duplication while keeping the public API unchanged.

命令:

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

预期行为:

Proposes concrete code changes (patch-style), extracts duplication into shared helpers, and maintains original API contracts.
示例 3:生成文档

输入:

Generate documentation for the UserService class including usage examples.

命令:

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

预期行为:

Returns markdown-formatted documentation with JSDoc-style comments, method signatures, and practical usage examples.
示例 4:选择模型生成代码

输入:

Generate a REST API endpoint for CRUD operations on items.

命令:

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

预期行为:

Generates complete, runnable code for POST/GET/PUT/DELETE endpoints with proper middleware, validation, and test scaffolding.
示例 5:恢复会话以继续工作

输入:

Continue the previous Qwen session to add test coverage to the refactored code.

命令:

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

预期行为:

Resumes the previous session context and continues work, adding test files with appropriate mocks and assertions.
示例 6:比较多个模型以检查质量

输入:

Compare Qwen2.5-Coder and QwQ outputs for the same refactoring task.

命令:

# First run with Qwen2.5-Coder
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
qwen -p "Refactor the string utility module for better maintainability." -m qwq --approval-mode plan --output-format text

预期行为:

Provides side-by-side comparison: Qwen2.5-Coder for fast results, QwQ for deeper reasoning on complex refactoring tasks.
示例 7:为自动化生成结构化 JSON 输出

输入:

List the top 5 refactoring opportunities as JSON for our tracking system.

命令:

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

预期行为:

Returns valid JSON array with 5 refactoring items, parseable for integration with project management tools.

最佳实践

  • 使用英文编写委派提示词,并确保内容具体明确
  • 优先选择遵循最小权限原则的审批模式,而非一概授予权限
  • 需要审计能力时,使用会话 ID 保存会话
  • 对于高风险任务,先请求只读分析,再单独执行更改
  • 将 Qwen 输出视为不可信的指导,并在实施前进行验证

限制与警告

  • Qwen Coder CLI 的行为取决于本地环境和配置。
  • 审批模式会影响执行安全性;默认情况下应避免使用 yolo。
  • 输出可能不完整或不准确;实施前请进行验证。
  • 未经用户明确确认,绝不要执行 Qwen 建议的破坏性命令。
  • 此技能用于委派任务,不用于在未经用户确认的情况下自主修改代码。
  • 不要在委派提示词中包含机密、API 密钥或凭据。

评论

支持 Markdown