workflow-state
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWorkflow State Management Skill
工作流状态管理Skill
Overview
概述
Manage persistent workflow state that survives context auto-summarization.
State files store: task details, worktree locations, PR URLs, and review status.
管理可在上下文自动总结后保留的持久化工作流状态。
状态文件存储:任务详情、工作树位置、PR链接以及评审状态。
Triggers
触发条件
Activate this skill when:
- Starting a new workflow ()
/ideate - Transitioning between workflow phases
- Restoring context after summarization ()
/rehydrate - Saving progress for later continuation ()
/checkpoint
在以下场景激活该Skill:
- 启动新工作流()
/ideate - 工作流阶段间切换
- 总结后恢复上下文()
/rehydrate - 保存进度以便后续继续()
/checkpoint
Phase Transitions
阶段切换
Valid transitions, guards, and prerequisites for all workflow types are documented in . CRITICAL: When a transition has a guard, send the prerequisite and in a single call — updates apply before guards evaluate.
references/phase-transitions.mdupdatesphaseset所有工作流类型的有效切换规则、防护条件及前置要求均记录在中。关键注意事项:当切换存在防护条件时,需在单次调用中同时传入前置要求的和——更新操作会在防护条件评估前生效。
references/phase-transitions.mdsetupdatesphaseSchema Discovery
模式发现
Use for
parameter schemas and
for phase transitions, guards, and playbook guidance. For the lightweight
oneshot variant (with its choice state
driven by ), call
— oneshot is a first-class playbook alongside feature/debug/refactor. Use
for event data schemas.
exarchos_workflow({ action: "describe", actions: ["set", "init", "get"] })exarchos_workflow({ action: "describe", playbook: "feature" })implementing → synthesize|completedsynthesisPolicyexarchos_workflow({ action: "describe", playbook: "oneshot" })exarchos_event({ action: "describe", eventTypes: ["workflow.transition", "task.completed"] })使用获取参数模式,使用获取阶段切换规则、防护条件及工作流指南。对于轻量型一次性工作流变体(其选择状态由驱动),请调用——oneshot是与feature/debug/refactor同级的一等工作流。使用获取事件数据模式。
exarchos_workflow({ action: "describe", actions: ["set", "init", "get"] })exarchos_workflow({ action: "describe", playbook: "feature" })implementing → synthesize|completedsynthesisPolicyexarchos_workflow({ action: "describe", playbook: "oneshot" })exarchos_event({ action: "describe", eventTypes: ["workflow.transition", "task.completed"] })State Location
状态存储位置
Workflow state lives in the MCP event store, not the filesystem. Use to read state and to discover active workflows. Do not scan — that path is legacy and may be stale or empty.
exarchos_workflow getexarchos_view pipeline~/.claude/workflow-state/*.state.json工作流状态存储在MCP事件存储中,而非文件系统。使用读取状态,使用发现活跃工作流。请勿扫描——该路径为遗留路径,内容可能过期或为空。
exarchos_workflow getexarchos_view pipeline~/.claude/workflow-state/*.state.jsonState Operations
状态操作
For full MCP tool signatures, error handling, and anti-patterns, see .
references/mcp-tool-reference.md关于MCP工具的完整签名、错误处理及反模式,请参考。
references/mcp-tool-reference.mdInitialize State
初始化状态
At the start of , use with with:
/ideatemcp__exarchos__exarchos_workflowaction: "init"- : the workflow identifier (e.g.,
featureId)"user-authentication" - : one of
workflowType,"feature","debug","refactor""oneshot" - (optional, oneshot only): one of
synthesisPolicy,"always","never"(default"on-request") — silently ignored for non-oneshot types"on-request"
This creates a new workflow state entry. The initial phase depends on
:
workflowType- → starts in
featureideate - → starts in
debugtriage - → starts in
refactorexplore - → starts in
oneshot(skips ideate entirely)plan
在启动时,使用并设置,同时传入:
/ideatemcp__exarchos__exarchos_workflowaction: "init"- :工作流标识符(示例:
featureId)"user-authentication" - :可选值为
workflowType、"feature"、"debug"、"refactor""oneshot" - (可选,仅适用于oneshot):可选值为
synthesisPolicy、"always"、"never"(默认值"on-request")——非oneshot类型会自动忽略该参数"on-request"
此操作将创建新的工作流状态条目。初始阶段取决于:
workflowType- → 初始阶段为
featureideate - → 初始阶段为
debugtriage - → 初始阶段为
refactorexplore - → 初始阶段为
oneshot(直接跳过ideate阶段)plan
Workflow Types at a Glance
工作流类型概览
- — full
featurefor real features with subagent dispatch and two-stage reviewideate → plan → delegate → review → synthesize - —
debugfor bug workflows with track selectiontriage → investigate → (thorough | hotfix) - —
refactorfor code improvements, polish for small and overhaul for multi-taskexplore → brief → (polish | overhaul) - —
oneshotfor trivial changes; direct-commit by default with an opt-in PR path resolved via a choice-state guard driven byplan → implementing → (completed | synthesize)and thesynthesisPolicyeventsynthesize.requested
See for the lightweight variant's full prose, including the choice-state mechanics and trigger.
@skills/oneshot-workflow/SKILL.mdfinalize_oneshot- — 完整的
feature流程,适用于包含子Agent调度和两阶段评审的正式功能开发ideate → plan → delegate → review → synthesize - —
debug流程,适用于包含路径选择的Bug修复工作流triage → investigate → (thorough | hotfix) - —
refactor流程,适用于代码优化,polish用于小型优化,overhaul用于多任务重构explore → brief → (polish | overhaul) - —
oneshot流程,适用于微小变更;默认直接提交,可通过plan → implementing → (completed | synthesize)和synthesisPolicy事件驱动的选择状态防护条件开启PR路径synthesize.requested
关于轻量型变体的完整说明,包括选择状态机制和触发器,请参考。
finalize_oneshot@skills/oneshot-workflow/SKILL.mdRead State
读取状态
Use with and :
mcp__exarchos__exarchos_workflowaction: "get"featureId- Full state: Call with just
featureId - Specific field: Add for dot-path lookup (e.g.,
query,query: "phase")query: "tasks" - Multiple fields: Add array for projection (e.g.,
fields)fields: ["phase", "featureId", "tasks"]
Field projection via returns only the requested top-level keys, reducing token cost.
fields使用并设置和:
mcp__exarchos__exarchos_workflowaction: "get"featureId- 完整状态:仅传入即可
featureId - 特定字段:添加参数进行点路径查询(示例:
query、query: "phase")query: "tasks" - 多个字段:添加数组进行投影查询(示例:
fields)fields: ["phase", "featureId", "tasks"]
通过进行字段投影仅返回指定的顶层键,可降低Token消耗。
fieldsUpdate State
更新状态
Use with with and either , , or both:
mcp__exarchos__exarchos_workflowaction: "set"featureIdupdatesphase- Update phase:
phase: "delegate" - Set artifact path:
updates: { "artifacts.design": "docs/designs/2026-01-05-feature.md" } - Mark task complete (by index):
updates: { "tasks[0].status": "complete", "tasks[0].completedAt": "<timestamp>" } - Add worktree:
updates: { "worktrees.wt-001": { "branch": "feature/001-types", "taskId": "001", "status": "active" } } - Phase + updates together: ,
phase: "delegate"updates: { "artifacts.plan": "docs/plans/plan.md" }
Worktree status values:
'active' | 'merged' | 'removed'使用并设置,同时传入以及、或两者:
mcp__exarchos__exarchos_workflowaction: "set"featureIdupdatesphase- 更新阶段:
phase: "delegate" - 设置工件路径:
updates: { "artifacts.design": "docs/designs/2026-01-05-feature.md" } - 标记任务完成(按索引):
updates: { "tasks[0].status": "complete", "tasks[0].completedAt": "<timestamp>" } - 添加工作树:
updates: { "worktrees.wt-001": { "branch": "feature/001-types", "taskId": "001", "status": "active" } } - 同时更新阶段和字段:,
phase: "delegate"updates: { "artifacts.plan": "docs/plans/plan.md" }
工作树状态可选值:
'active' | 'merged' | 'removed'Editing the tasks
array
tasks编辑tasks
数组
tasksThe dot-path parser used by recognizes only numeric array brackets (, , …). Keyed forms like are NOT supported and now throw an error with a clear message — earlier versions silently wrote to a bogus top-level key, returning while the actual task was untouched. Three patterns are supported:
set updatestasks[0]tasks[1]tasks[id=T-001]INVALID_INPUTsuccess: true-
Replace the whole array (use this when the plan is being revised wholesale; matches the issue #1003 contract):typescript
exarchos_workflow({ action: "set", featureId: "<id>", updates: { tasks: [ { id: "T-001", title: "...", status: "pending" }, { id: "T-002", title: "...", status: "pending" }, ]}, }) -
Edit one task by its array index:typescript
exarchos_workflow({ action: "set", featureId: "<id>", updates: { "tasks[0].status": "complete", "tasks[0].completedAt": "<ts>" }, })First read(tasks) to find the index of the task you want to edit, then set by that index.action: "get", query: "tasks" -
Append a new task by writing to the next-free index. If the array currently has length, write to
N:tasks[N]typescript// Suppose tasks already contains T-001 and T-002 (length 2). To append: exarchos_workflow({ action: "set", featureId: "<id>", updates: { "tasks[2]": { id: "T-003", title: "Follow-up", status: "pending" } }, })The parser allows writing one slot past the current length (); writing further out (MAX_ARRAY_GAP = 1against a length-2 array) throwstasks[5]. Read the currentINVALID_INPUTlength before appending.tasks
set updatestasks[0]tasks[1]tasks[id=T-001]INVALID_INPUTsuccess: true-
替换整个数组(当计划需要全面修订时使用;符合issue #1003约定):typescript
exarchos_workflow({ action: "set", featureId: "<id>", updates: { tasks: [ { id: "T-001", title: "...", status: "pending" }, { id: "T-002", title: "...", status: "pending" }, ]}, }) -
按数组索引编辑单个任务:typescript
exarchos_workflow({ action: "set", featureId: "<id>", updates: { "tasks[0].status": "complete", "tasks[0].completedAt": "<ts>" }, })先读取(tasks)找到目标任务的索引,再按该索引进行设置。action: "get", query: "tasks" -
追加新任务:写入下一个可用索引。如果当前数组长度为,则写入
N:tasks[N]typescript// 假设tasks已包含T-001和T-002(长度为2),追加新任务: exarchos_workflow({ action: "set", featureId: "<id>", updates: { "tasks[2]": { id: "T-003", title: "Follow-up", status: "pending" } }, })解析器允许写入当前长度之后的一个位置();写入超出范围的位置(如长度为2的数组写入MAX_ARRAY_GAP = 1)会抛出tasks[5]错误。追加前请先读取当前INVALID_INPUT的长度。tasks
Get Summary
获取摘要
For context restoration after summarization, use with and . This outputs a minimal summary suitable for rebuilding orchestrator context.
mcp__exarchos__exarchos_workflowaction: "get"featureId总结后恢复上下文时,使用并设置和。此操作会输出用于重建编排器上下文的极简摘要。
mcp__exarchos__exarchos_workflowaction: "get"featureIdReconcile State
状态对账
To verify state matches git reality, the SessionStart hook automatically reconciles on resume. For manual verification, run the reconciliation script:
typescript
exarchos_orchestrate({
action: "reconcile_state",
stateFile: "<state-file>",
repoRoot: "<repo-root>"
})On : State is consistent.
On : Discrepancies found — review output and resolve.
passed: truepassed: false为验证状态与git实际情况一致,SessionStart钩子会在恢复时自动执行对账操作。如需手动验证,运行对账脚本:
typescript
exarchos_orchestrate({
action: "reconcile_state",
stateFile: "<state-file>",
repoRoot: "<repo-root>"
})当时:状态一致。
当时:发现不一致——请查看输出并解决问题。
passed: truepassed: falseIntegration Points
集成点
When to Update State
状态更新时机
| Event | State Update |
|---|---|
| Create state file |
| Design saved | Set |
| Plan saved | Set |
| Plan-review gaps found | Set |
| Plan-review approved | Set |
| Task dispatched | Set task |
| Task complete | Set task |
| Worktree created | Add to |
| Review complete | Update |
| PR created | Set |
| PR feedback | Append to |
| 事件 | 状态更新操作 |
|---|---|
| 创建状态文件 |
| 设计文档保存 | 设置 |
| 计划文档保存 | 设置 |
| 计划评审发现问题 | 设置 |
| 计划评审通过 | 设置 |
| 任务分派 | 设置任务 |
| 任务完成 | 设置任务 |
| 工作树创建 | 添加至 |
| 评审完成 | 更新 |
| PR创建 | 设置 |
| PR反馈 | 追加至 |
Oneshot-specific state updates
Oneshot专属状态更新
Oneshot is a first-class workflow type with a compressed lifecycle and an
opt-in PR path. The rows below mirror the feature-workflow table above.
| Phase | State updates | Events emitted |
|---|---|---|
| | |
| | |
| | |
| — | |
The fork is a choice state resolved
by , which reads the guard
( + events). See
for the full opt-in mechanics.
implementing → synthesize | completedfinalize_oneshotsynthesisOptedInsynthesisPolicysynthesize.requested@skills/oneshot-workflow/SKILL.mdOneshot是一等工作流类型,具有压缩的生命周期和可选PR路径。以下表格与上方功能工作流表格对应。
| 阶段 | 状态更新 | 触发事件 |
|---|---|---|
| | |
| | |
| | |
| — | |
implementing → synthesize | completedfinalize_oneshotsynthesisOptedInsynthesisPolicysynthesize.requested@skills/oneshot-workflow/SKILL.mdAutomatic State Updates
自动状态更新
Skills should update state at key moments:
brainstorming/SKILL.md:
markdown
After saving design:
1. Update state: `.artifacts.design = "<path>"`
2. Update state: `.phase = "plan"`implementation-planning/SKILL.md:
markdown
After saving plan:
1. Update state: `.artifacts.plan = "<path>"`
2. Populate `.tasks` from plan
3. Update state: `.phase = "delegate"`delegation/SKILL.md:
markdown
On task dispatch:
- Update task status to "in_progress"
- Add worktree to state if created
On task complete:
- Update task status to "complete"
- Check if all tasks done, suggest checkpointSkills应在关键节点更新状态:
brainstorming/SKILL.md:
markdown
保存设计文档后:
1. 更新状态:`.artifacts.design = "<path>"`
2. 更新状态:`.phase = "plan"`implementation-planning/SKILL.md:
markdown
保存计划文档后:
1. 更新状态:`.artifacts.plan = "<path>"`
2. 从计划中填充`.tasks`
3. 更新状态:`.phase = "delegate"`delegation/SKILL.md:
markdown
任务分派时:
- 将任务状态更新为"in_progress"
- 若创建了工作树则添加至状态
任务完成时:
- 将任务状态更新为"complete"
- 检查是否所有任务完成,建议创建检查点State Schema
状态模式
See for full schema.
docs/schemas/workflow-state.schema.jsonKey sections:
- : Schema version (currently "1.1")
version - : Unique workflow identifier
featureId - : Required. One of "feature", "debug", "refactor", or "oneshot"
workflowType - : Current workflow phase
phase - : Paths to design, plan, PR
artifacts - : Task list with status
tasks - : Active git worktrees
worktrees - : Plan-review delta analysis results (
planReview,gaps)approved - : Review results
reviews - : Merge/PR state
synthesis
完整模式请参考。
docs/schemas/workflow-state.schema.json关键部分:
- :模式版本(当前为"1.1")
version - :唯一工作流标识符
featureId - :必填项。可选值为"feature"、"debug"、"refactor"或"oneshot"
workflowType - :当前工作流阶段
phase - :设计文档、计划文档、PR的路径
artifacts - :带状态的任务列表
tasks - :活跃的git工作树
worktrees - :计划评审差异分析结果(
planReview、gaps)approved - :评审结果
reviews - :合并/PR状态
synthesis
Best Practices
最佳实践
- Update often - State should reflect reality at all times
- Use MCP tools - Prefer workflow-state MCP tools over manual JSON editing
- Reconcile on resume - Always verify state matches git state
- Checkpoint at boundaries - Save state before likely context exhaustion
- Read state, don't remember - After summarization, read from state file
- 频繁更新 - 状态应始终反映实际情况
- 使用MCP工具 - 优先使用工作流状态MCP工具,而非手动编辑JSON
- 恢复时对账 - 始终验证状态与git状态一致
- 边界处创建检查点 - 在可能出现上下文耗尽前保存状态
- 读取状态,而非记忆 - 总结后从状态文件读取信息
Troubleshooting
故障排查
MCP Tool Call Failed
MCP工具调用失败
If an Exarchos MCP tool returns an error:
- Check the error message — it usually contains specific guidance
- Verify the workflow state exists: call with
mcp__exarchos__exarchos_workflowand the featureIdaction: "get" - If "version mismatch": another process updated state — retry the operation
- If state is corrupted: call with
mcp__exarchos__exarchos_workflowandaction: "cancel"dryRun: true
如果Exarchos MCP工具返回错误:
- 查看错误信息——通常包含具体指导
- 验证工作流状态是否存在:调用并设置
mcp__exarchos__exarchos_workflow和对应的featureIdaction: "get" - 若提示"version mismatch":其他进程已更新状态——重试操作
- 若状态损坏:调用并设置
mcp__exarchos__exarchos_workflow和action: "cancel"dryRun: true
State Desync
状态不同步
If workflow state doesn't match git reality:
- The SessionStart hook runs reconciliation automatically on resume
- If manual check needed: compare state file with and branch state
git log - Update state via with
mcp__exarchos__exarchos_workflowto match git truthaction: "set"
如果工作流状态与git实际情况不符:
- SessionStart钩子会在恢复时自动执行对账
- 如需手动检查:对比状态文件与及分支状态
git log - 使用并设置
mcp__exarchos__exarchos_workflow更新状态,使其与git实际情况一致action: "set"
Checkpoint File Missing
检查点文件缺失
If the PreCompact hook can't find state to checkpoint:
- Verify a workflow is active: call with
mcp__exarchos__exarchos_workflowand the featureIdaction: "get" - If no active workflow: the hook will silently skip (expected behavior)
- If workflow exists but checkpoint fails: check disk space and permissions
如果PreCompact钩子无法找到用于创建检查点的状态:
- 验证是否存在活跃工作流:调用并设置
mcp__exarchos__exarchos_workflow和对应的featureIdaction: "get" - 若无活跃工作流:钩子会静默跳过(预期行为)
- 若工作流存在但检查点创建失败:检查磁盘空间和权限
Resume Finds Stale State
恢复时发现过期状态
If state references branches or worktrees that no longer exist:
- The SessionStart hook handles reconciliation automatically
- It updates state to reflect current git reality
- Missing branches are flagged in the session-start output
如果状态引用的分支或工作树已不存在:
- SessionStart钩子会自动处理对账
- 它会更新状态以反映当前git实际情况
- 缺失的分支会在会话启动输出中标记
Multiple Active Workflows
多个活跃工作流
If multiple workflow state files exist:
- The system uses the most recently updated active (non-completed) workflow
- Use with
mcp__exarchos__exarchos_workflowandaction: "cancel"on stale workflows to preview cleanupdryRun: true - Cancel stale workflows before starting new ones
如果存在多个工作流状态文件:
- 系统会使用最近更新的活跃(未完成)工作流
- 对过期工作流调用并设置
mcp__exarchos__exarchos_workflow和action: "cancel",预览清理操作dryRun: true - 在启动新工作流前取消过期工作流
Example Workflow
示例工作流
-
Start new workflow: Usewith
mcp__exarchos__exarchos_workflowwithaction: "init",featureId: "user-authentication"workflowType: "feature" -
After design phase: Usewith
mcp__exarchos__exarchos_workflowwith:action: "set"featureId: "user-authentication"phase: "plan"updates: { "artifacts.design": "docs/designs/2026-01-05-user-auth.md" }
-
Check state: Usewith
mcp__exarchos__exarchos_workflowwithaction: "get"featureId: "user-authentication" -
Resume after context loss: Usewith
mcp__exarchos__exarchos_workflowwithaction: "get"to get context restoration outputfeatureId: "user-authentication"
-
启动新工作流:使用并设置
mcp__exarchos__exarchos_workflow,同时传入action: "init"、featureId: "user-authentication"workflowType: "feature" -
设计阶段完成后:使用并设置
mcp__exarchos__exarchos_workflow,同时传入:action: "set"featureId: "user-authentication"phase: "plan"updates: { "artifacts.design": "docs/designs/2026-01-05-user-auth.md" }
-
检查状态:使用并设置
mcp__exarchos__exarchos_workflow和action: "get"featureId: "user-authentication" -
上下文丢失后恢复:使用并设置
mcp__exarchos__exarchos_workflow和action: "get"获取上下文恢复输出featureId: "user-authentication"