workflow-authoring
它能做什么
它是一份参考资料,讲解如何编写工作流背后的脚本,涵盖并行与顺序步骤、检查和恢复运行。适合为迁移或审计等大型任务构建可复用智能体工作流的人。
适用场景
- ✓当你在为一个需要把工作分给多个智能体的工作流编写脚本时。
- ✓当迁移或审计等大型任务需要并行步骤和检查时。
- ✓当你需要在并行运行步骤和顺序运行步骤之间做选择时。
技能链接
https://github.com/QwenLM/qwen-code/blob/main/packages/core/src/skills/bundled/workflow-authoring/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我编写一个工作流脚本,并行审计这个仓库中的每个模块,然后把发现的问题合并起来。”
每周 5 个新技能,1 分钟读完。
工作原理
该参考说明如何组织脚本、何时分发工作、如何验证结果,以及如何合并结果。它本身不会启动运行。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Workflow authoring reference
Everything below is about writing the script. Whether a workflow may run at all is decided by the Workflow tool's own opt-in rule — this reference does not authorize a run.
Reach for one to be comprehensive (decompose the work and cover every part in parallel), to be confident (independent perspectives and adversarial checks before an answer is committed to), or to take on scale a single context cannot hold — migrations, audits, broad sweeps. The script is where that structure is encoded: what fans out, what verifies, what synthesizes. Parallelism on its own is not a reason; work that is already one short sequence of edits belongs in the main loop.
Scout first, then orchestrate
The strongest pattern is hybrid: discover the work list in the main loop (list the files, scope the diff, read the failing test), then hand that list to a workflow. You do not need to know the shape of the work before the task — only before the orchestration step. When the work has distinct phases, run several small workflows across turns and read each result before choosing the next, rather than authoring one large script that runs unattended.
Common single-phase shapes: understand (parallel readers over subsystems,
merged into one map), design (independent approaches, judged, then
synthesized), review (dimensions, find, verify each finding), research (broad
sweep, deep read, synthesis), migrate (discover sites, transform each under
isolation: 'worktree', verify).
Script contract
The source is wrapped as an async IIFE, so top-level await and a top-level
return are both legal — and a trailing expression is not a return value.
End every successful path with an explicit return.
It is plain JavaScript, not TypeScript, and it cannot import anything. A
script with a dynamic import() anywhere in it — even in a branch that never
runs — is refused before it starts, so none of its agents runs first; do file,
network, and package work inside an agent instead.
The script may start with a literal export const meta = {...} declaration
with name, description, and optionally whenToUse and
phases: [{ title, detail? }]. It must be a pure literal — no variables,
calls, or interpolation — and it is stripped before execution, so nothing in
the script body can read it. Fields outside that list are dropped. The
approval dialog prints the name, the description, and each phase title with
its detail as a one-line explanation beside it: give every phase a detail,
because for a run that may dispatch hundreds of agents it is what the user
reads before approving. In a workflow an extension ships, whenToUse also lists
the workflow for the model to start when a request matches it; leave it out and
the workflow runs only when someone asks for it by name.
Injected globals, and nothing else:
phase(title)— open a phase. Everything dispatched afterwards is attributed to it in the live phase tree, until the next phase opens.log(msg)— one line into the run log the user watches.agent(prompt, opts?)— dispatch one subagent. See agent() options.parallel(thunks)— run thunks through the shared concurrency window, resolving to a position-aligned array.parallel()itself rejects on invalid arguments.pipeline(items, ...stages)— run each item through the stages independently. See Default topipeline().workflow(nameOrRef, args?, { stepId }?)— run a saved workflow inline. See Saved workflows and workflow().args— the structured value the caller passed, orundefined.budget—{ total, spent(), remaining() }. See Scaling to the token budget.
Pass THUNKS to parallel(), not eager calls: parallel([() => agent(...)]),
not parallel([agent(...)]). The eager form is refused outright: a
non-function element rejects the whole batch, and by then every agent() in it
has already been admitted, counted against the caps, and spent — with its
result discarded.
Each list a single call takes — the thunks of parallel(), and the items and
the stages of pipeline() — holds at most 4096 entries. A longer list rejects
the whole call before any of its thunks or stages runs; it is never truncated.
Like any invalid argument, that rejection can be caught, and inside an outer
parallel()/pipeline() it becomes that slot's null. The limit is per call,
not per run: split a larger input into batches of thunks and await each in
turn. Batching does not
常见问题
阅读它会启动工作流吗?
不会。它只说明如何编写脚本,运行仍需你的批准。
什么时候不应使用工作流?
如果工作只是一小段连续的编辑,就应放在普通的循环中完成。
我可以分阶段运行吗?
可以。该参考建议跨多轮运行小型工作流,并在进入下一步之前阅读每个结果。
详情
作者的原始描述
Reference for writing a Workflow tool script (script API and gotchas, agent() options, pipeline() vs parallel(), verification and convergence patterns, resume, worked example). Load before authoring a script for a workflow the user already opted into; it does not itself authorize running one.
repo: QwenLM/qwen-code
热度
- GitHub 星标
- 29k
- 排名
- #9788
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
codegraph
29k帮你的智能体通过调用图、依赖关系、无用代码、热点和语义搜索来分析已建立索引的代码库。
qwen-code-claw
29k帮你的智能体把编程任务交给 Qwen Code,例如理解代码库、修复缺陷、重构代码或生成新项目。
structured-debugging
29k教你的智能体用一步一步的方法调试疑难缺陷:先提出假设,再添加有针对性的检查,验证后找出真正的原因,然后才修复。
tmux-real-user-testing
29k帮你的智能体在 tmux 中像真实用户一样测试终端应用,并为每一步操作保存带屏幕截图的可读步骤日志。