# Workflow Authoring

Reference for writing a Workflow tool script (script API and gotchas, agent() options...

- Repository: https://github.com/QwenLM/qwen-code (28858 stars)
- Category: AI and agents
- License: Apache-2.0
- Last updated: 2026-11-01
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add QwenLM/qwen-code --skill workflow-authoring -g -a claude-code -y`
Codex: `npx skills add QwenLM/qwen-code --skill workflow-authoring -g -a codex -y`
Cursor: `npx skills add QwenLM/qwen-code --skill workflow-authoring -g -a cursor -y`
Gemini CLI: `npx skills add QwenLM/qwen-code --skill workflow-authoring -g -a gemini-cli -y`

## Description

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.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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`.

The rest: https://github.com/QwenLM/qwen-code/blob/HEAD/packages/core/src/skills/bundled/workflow-authoring/SKILL.md
