Claude Code Workflow Research banner
TokenRollAI TokenRollAI

Claude Code Workflow Research

Productivity community

Description

Research notes and captured artifacts for Claude Code workflow orchestration

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

Claude Code Workflow 实现原理:从抓包看动态多代理编排

本文基于一次 Claude Code workflow 的 Reqable 抓包和本地运行产物,拆解 Claude Code dynamic workflow 的实现原理、工作机制和 agent 交接方式。

一句话概括:Claude Code workflow 的本质不是“模型在一次请求里并发思考”,而是“主模型生成一段 JavaScript 编排脚本,Claude Code 本地 runtime 执行脚本并启动多个普通子代理会话”。子代理通过 `StructuredOutput` 返回结构化 JSON,本地 runtime 再把这些 JSON 作为普通 JavaScript 值传给后续阶段,最终把脚本的 `return` 值通过 `` 回灌主会话。

证据范围

本仓库保留了同一次 workflow 运行的两类材料:

本次运行的关键 ID:

字段
Session ID 915155ec-d5cc-44ba-b5eb-fb3e513a1d8f
Workflow run ID wf_1b6a0439-04e
Task ID wts66al8s
主题 桌游设计锦标赛:并行发明概念,评委团打分,综合冠军设计稿

关键证据文件:

文件 说明
`workflow-artifacts/workflow-tool-prompt.md` 主模型看到的 Workflow 工具提示词,包含触发规则、JS DSL、并发语义、恢复规则和质量模式。
`workflow-artifacts/workflow-tool-schema.json` 主模型看到的 Workflow 工具 schema。
`workflow-artifacts/main-workflow-tool-use.json` 主模型实际发出的 tool_use: Workflow,其中包含完整内联 JS。
`workflow-artifacts/boardgame-tournament-wf_1b6a0439-04e.js` Claude Code 持久化保存的本次 workflow JS。
`workflow-artifacts/subagent-system-prompt.md` 注入 workflow 子代理的系统提示词。
`workflow-artifacts/structured-output-schemas/` agent(..., { schema }) 传给 StructuredOutput 的 JSON schema。
`workflow-artifacts/subagent-prompts/` 去重后的 21 个逻辑子代理 prompt。
`workflow-artifacts/examples/` 子代理 StructuredOutput 工具调用和 tool_result 回灌样例。
`workflow-artifacts/journal.jsonl` 本地 workflow runtime 的 agent start/result 日志。
[`wo