using-workflows

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

using-workflows

使用工作流

You pick which recipe the situation needs, fill its args, run it, and keep the closed loop moving. You are not a recipe.
你需要根据场景选择合适的模板,填充参数,运行模板,并保持闭环推进。你本身不是模板。

BYPASS — check FIRST

绕过机制 — 优先检查

One bounded task, single context, no stages, no convergence condition → do it directly (inline, or one worker via
using-tmux-agent-tools
). No recipe, no run dir. When in doubt, bypass — recipes exist for loops, not ceremony.
Red flags that have actually burned us (naming one and proceeding anyway requires a stated reason):
  • 「我記得那支 recipe 內容」— recipes evolve; read the header comment (the args contract) before running. Never guess args.
  • 「先做完再補 run record」— if it meets the run-dir bar below, open it first.
  • 「這個小改不用 gate」— behavior-tier edits to any recipe DO need one consensus-gate round first.
Subagent exemption: delegated workers never enter this router — the dispatcher already routed; workers follow their brief.
如果是单一限定任务、单一上下文、无阶段划分、无收敛条件 → 直接执行(内联执行,或通过
using-tmux-agent-tools
调用单个worker)。无需使用模板,无需运行目录。存疑时选择绕过 — 模板专为循环型工作设计,而非形式化流程。
曾导致问题的警示信号(若明知存在仍继续执行,需说明理由):
  • 「我记得那个模板的内容」—— 模板会迭代更新;运行前务必阅读头部注释(参数约定)。绝不要猜测参数。
  • 「先做完再补运行记录」—— 如果符合下方运行目录的要求,应先创建运行目录。
  • 「这个小改动不需要校验」—— 对任何模板的行为层级修改,都必须先经过一轮共识校验。
子Agent豁免规则:被委派的worker无需进入此路由 — 调度器已完成路由;worker只需遵循其任务简报。

TRIGGER

触发条件

Loop-shaped work: stages plus a convergence condition. Audit chains, consensus review, plan→build lifecycles, findings triage.
循环型工作:包含多个阶段及收敛条件。例如审计链、共识评审、计划→构建生命周期、问题分类。

From the Continuity trigger (global CLAUDE.md/AGENTS.md)

来自全局CLAUDE.md/AGENTS.md的连续性触发

The global rule routes loop-shaped work here at task start. On arrival:
  1. Match the trigger word (audit / consensus verification / findings triage / root-cause deep-dive / plan→build) to a recipe via SELECT below.
  2. Runtime split: Claude invokes the recipe natively via
    Workflow
    ; Codex commands it through
    references/codex-adapter.md
    (
    claude-workflow-runner
    ) — the runner is mechanical, so use the cheapest capable model with reasoning effort
    low
    .
  3. Write-back duty: every recipe artifact/result lands in the CALLER's
    .workflow/<YYYYMMDDHHMM>-<slug>/
    run directory (the one the Continuity rule had you create) — never a detached location. One task = one run dir, shared by convention and recipe alike.
全局规则会在任务启动时将循环型工作路由至此。到达后:
  1. 通过下方的SELECT步骤,将触发词(audit / consensus verification / findings triage / root-cause deep-dive / plan→build)匹配到对应模板。
  2. 运行时拆分:Claude通过
    Workflow
    原生调用模板;Codex通过
    references/codex-adapter.md
    claude-workflow-runner
    )调用模板 — 运行器是机械性的,因此使用成本最低且具备能力的模型,推理等级设为
    low
  3. 回写职责:所有模板生成的产物/结果都必须存入调用方的
    .workflow/<YYYYMMDDHHMM>-<slug>/
    运行目录(即连续性规则要求你创建的目录)—— 绝不能存入独立位置。一个任务对应一个运行目录,模板需遵循此约定共享该目录。

SELECT

选择模板

Discover live — never recite the recipe list from memory:
bash
ls ~/.claude/workflows/*.workflow.js .claude/workflows/*.workflow.js 2>/dev/null
The inner loop (the ONLY loop — there is no scheduling outer ring; do not invent one):
audit (docs-vs-code | design-vs-code | root-cause-deep-dive)
  → findings-triage        connector ①: askUser → human VERBATIM ·
  │                        briefs → lifecycle · directFix → partitioned run
  → feature-lifecycle-auto thin shell: feature-plan-consensus | plan-pipeline
  │                        → gate ✋ (autoBuild=false: human reads the plan)
  │                        → spec-implement-dual-review-verify
  → re-run the ORIGINATING audit, SAME args
  │                        connector ②: lives in YOU, not in code
  → confirmed == 0 → converged, report · else → back to findings-triage
Entry points off the loop:
  • weird bug →
    root-cause-deep-dive-audit
    · docs/design drifted → the matching audit
  • ONE artifact needs a second-model verdict →
    consensus-gate
    — ONE round, irreversible/behavior-tier changes only; NOT a default station
  • N-angle generative design consensus →
    design-consensus
  • "what should this project do next" →
    project-direction-review
  • recipe fleet inventory / machine drift →
    workflow-manifest
Stage recipes (
feature-plan-consensus
,
plan-pipeline
,
spec-implement-dual-review-verify
) are normally reached THROUGH
feature-lifecycle-auto
; call one directly only when you want just that stage. Args auto-fill:
cli
= user's words → repo CLAUDE.md → the COUNTERPART engine (the second brain is always the OTHER engine relative to the current commander: Claude commands → a codex profile; Codex commands → a claude profile; never your own engine, never a hard-coded name) → ask once;
context
= one line (repo abs path + stack + scope). Prefer name invocation over scriptPath.
实时查找模板 — 绝不要凭记忆列举模板列表:
bash
ls ~/.claude/workflows/*.workflow.js .claude/workflows/*.workflow.js 2>/dev/null
核心循环(唯一的循环 — 不存在调度外环;请勿自行创建):
audit (docs-vs-code | design-vs-code | root-cause-deep-dive)
  → findings-triage        连接器①: askUser → 人工逐字确认 ·
  │                        简报 → 生命周期 · directFix → 分区运行
  → feature-lifecycle-auto 轻量壳层: feature-plan-consensus | plan-pipeline
  │                        → 校验 ✋ (autoBuild=false: 人工审核计划)
  │                        → spec-implement-dual-review-verify
  → 重新运行初始audit,使用相同参数
  │                        连接器②: 内置在你自身中,而非代码里
  → confirmed == 0 → 收敛完成,生成报告 · 否则 → 返回findings-triage
循环外的入口点:
  • 疑难bug →
    root-cause-deep-dive-audit
    · 文档/设计偏离 → 匹配对应的audit模板
  • 单个产物需要第二个模型的结论 →
    consensus-gate
    — 仅一轮,仅适用于不可逆/行为层级变更;非默认环节
  • 多视角生成式设计共识 →
    design-consensus
  • “项目下一步该做什么” →
    project-direction-review
  • 模板集群盘点 / 机器漂移检测 →
    workflow-manifest
阶段模板(
feature-plan-consensus
,
plan-pipeline
,
spec-implement-dual-review-verify
)通常通过
feature-lifecycle-auto
访问;仅当你只需要该阶段时才直接调用。参数自动填充规则:
cli
= 用户输入 → 仓库CLAUDE.md → 对应引擎(相对于当前指挥者,第二大脑始终是另一个引擎:Claude指挥 → Codex配置文件;Codex指挥 → Claude配置文件;绝不能是自身引擎,绝不能硬编码名称)→ 仅询问一次;
context
= 一行内容(仓库绝对路径 + 栈信息 + 范围)。优先使用名称调用,而非scriptPath。

Cross-runtime execution

跨运行时执行

Both runtimes RUN recipes through this router; only the execution vehicle differs. Claude Code executes
.workflow.js
natively with
Workflow()
. Codex executes via
ADAPTED: claude-workflow-runner
(one bounded Claude runner capsule — mechanics in
references/codex-adapter.md
), under these constraints (Codex-authored, gate-v2 2026-07-19):
  • Codex MUST freeze recipe name, args, acceptance, author runtime, and reviewer profile before dispatching exactly one Claude runner.
  • The runner MUST invoke exactly one native
    Workflow(...)
    , preserve its return under
    recipe_result
    , write schema-v1
    result.json
    , then stop.
  • Any later exception MUST cap nesting at 2, declare child profiles/round ceilings, use unique sessions plus wait-required results, and forbid children from spawning.
  • Resolve
    args.cli
    by the substantive author under review: Codex for Claude-authored work; a non-Codex profile when Codex authored the target; fail closed if unclear.
  • Human gates MUST return
    status: paused
    plus
    next_action
    , preserve
    recipe_result
    , stop the runner, and resume only via a new explicitly approved invocation.
  • Evidence MUST say
    recipe <name> executed natively on Claude runtime via runner (commanded by Codex)
    ; adapter or child failure is never recipe PASS.
Runtime matrix (Claude Code =
NATIVE
for all 12; Codex column):
RecipeCodex
3 audits,
findings-triage
,
design-consensus
,
project-direction-review
,
workflow-manifest
(7, no tmux inside)
ADAPTED: claude-workflow-runner
consensus-gate
(simple verdict outcome only)
ADAPTED: direct-claude-review
references/codex-adapter.md
consensus-gate
(as recipe), lifecycle + its 3 stages (5, they launch agent-tmux inside)
UNAVAILABLE-NATIVE
until nested-runner (depth-2) tests pass — stop and report; do not improvise
两种运行时均通过此路由运行模板;仅执行载体不同。Claude Code通过
Workflow()
原生执行
.workflow.js
。Codex通过
ADAPTED: claude-workflow-runner
执行(一个限定性的Claude运行器胶囊 — 机制详见
references/codex-adapter.md
),需遵循以下约束(Codex编写,gate-v2 2026-07-19):
  • Codex必须在调度单个Claude运行器前,冻结模板名称、参数、验收标准、作者运行时和评审者配置文件。
  • 运行器必须精确调用一次原生
    Workflow(...)
    ,将返回结果保存到
    recipe_result
    下,写入schema-v1格式的
    result.json
    ,然后停止。
  • 任何后续异常必须将嵌套层级限制为2,声明子配置文件/轮次上限,使用唯一会话并要求等待结果,禁止子进程生成。
  • 根据被评审内容的实际作者解析
    args.cli
    :Claude编写的内容 → 使用Codex;Codex编写的目标内容 → 使用非Codex配置文件;若不明确则终止执行。
  • 人工校验必须返回
    status: paused
    next_action
    ,保留
    recipe_result
    ,停止运行器,仅通过新的明确批准调用恢复执行。
  • 证据必须标注
    recipe <name> executed natively on Claude runtime via runner (commanded by Codex)
    ;适配器或子进程失败绝不能视为模板执行通过。
运行时矩阵(Claude Code = 所有12种模板均为
NATIVE
;Codex列):
模板Codex
3种audit、
findings-triage
design-consensus
project-direction-review
workflow-manifest
(共7种,内部无tmux)
ADAPTED: claude-workflow-runner
consensus-gate
(仅简单结论输出)
ADAPTED: direct-claude-review
— 详见
references/codex-adapter.md
consensus-gate
(作为模板)、生命周期及其3个阶段(共5种,内部启动agent-tmux)
UNAVAILABLE-NATIVE
直到嵌套运行器(深度2)测试通过 — 停止并报告;请勿自行变通

DEFER

延迟规则

  • Chain recipes from the TOP level only —
    workflow()
    nesting cap is 1, and the lifecycle shell spends it.
  • Run dir (
    .workflow/<slug>/
    ,
    codex-dynamic-workflows
    conventions) ONLY when work spans days, has 2+ phases, or must survive interruption/handoff. Within-chat work: a single results file, or nothing.
  • Recipe edits: behavior-tier → consensus-gate one round FIRST; wording → direct. Canonical = the agent-scripts repo bundle (
    skills/using-workflows/workflows/
    ) → redeploy to
    ~/.claude/workflows/
    ; a live edit made machine-side must be folded back into the bundle in the same change.
  • 仅能从顶层链式调用模板 —
    workflow()
    嵌套上限为1,且生命周期壳层已占用该额度。
  • 仅当工作跨多天、包含2个以上阶段,或需在中断/交接后保留时,才使用运行目录(
    .workflow/<slug>/
    ,遵循
    codex-dynamic-workflows
    约定)。聊天内工作:只需单个结果文件,或无需文件。
  • 模板编辑:行为层级修改 → 必须先经过一轮共识校验;措辞修改 → 直接编辑。标准版本为agent-scripts仓库包(
    skills/using-workflows/workflows/
    )→ 重新部署到
    ~/.claude/workflows/
    ;在机器端进行的实时编辑必须同步合并到包中。

NOT-FOUND

未找到模板

No recipe fits → the work probably is not loop-shaped; bypass. A genuinely new loop shape → propose a new recipe to the user; never improvise a half-recipe inline. Per-recipe reference:
workflows/README.md
(canonical: agent-scripts bundle
skills/using-workflows/workflows/README.md
; deployed copy at
~/.claude/workflows/README.md
).
无匹配模板 → 该工作很可能不是循环型工作;选择绕过。若确实是新的循环型工作 → 向用户提议新模板;绝不要在内部临时拼凑半完整模板。模板参考文档:
workflows/README.md
(标准版本:agent-scripts包中的
skills/using-workflows/workflows/README.md
;部署副本位于
~/.claude/workflows/README.md
)。