workflow-state

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Workflow 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
references/phase-transitions.md
. CRITICAL: When a transition has a guard, send the prerequisite
updates
and
phase
in a single
set
call — updates apply before guards evaluate.
所有工作流类型的有效切换规则、防护条件及前置要求均记录在
references/phase-transitions.md
中。关键注意事项:当切换存在防护条件时,需在单次
set
调用中同时传入前置要求的
updates
phase
——更新操作会在防护条件评估前生效。

Schema Discovery

模式发现

Use
exarchos_workflow({ action: "describe", actions: ["set", "init", "get"] })
for parameter schemas and
exarchos_workflow({ action: "describe", playbook: "feature" })
for phase transitions, guards, and playbook guidance. For the lightweight oneshot variant (with its
implementing → synthesize|completed
choice state driven by
synthesisPolicy
), call
exarchos_workflow({ action: "describe", playbook: "oneshot" })
— oneshot is a first-class playbook alongside feature/debug/refactor. Use
exarchos_event({ action: "describe", eventTypes: ["workflow.transition", "task.completed"] })
for event data schemas.
使用
exarchos_workflow({ action: "describe", actions: ["set", "init", "get"] })
获取参数模式,使用
exarchos_workflow({ action: "describe", playbook: "feature" })
获取阶段切换规则、防护条件及工作流指南。对于轻量型一次性工作流变体(其
implementing → synthesize|completed
选择状态由
synthesisPolicy
驱动),请调用
exarchos_workflow({ action: "describe", playbook: "oneshot" })
——oneshot是与feature/debug/refactor同级的一等工作流。使用
exarchos_event({ action: "describe", eventTypes: ["workflow.transition", "task.completed"] })
获取事件数据模式。

State Location

状态存储位置

Workflow state lives in the MCP event store, not the filesystem. Use
exarchos_workflow get
to read state and
exarchos_view pipeline
to discover active workflows. Do not scan
~/.claude/workflow-state/*.state.json
— that path is legacy and may be stale or empty.
工作流状态存储在MCP事件存储中,而非文件系统。使用
exarchos_workflow get
读取状态,使用
exarchos_view pipeline
发现活跃工作流。请勿扫描
~/.claude/workflow-state/*.state.json
——该路径为遗留路径,内容可能过期或为空。

State Operations

状态操作

For full MCP tool signatures, error handling, and anti-patterns, see
references/mcp-tool-reference.md
.
关于MCP工具的完整签名、错误处理及反模式,请参考
references/mcp-tool-reference.md

Initialize State

初始化状态

At the start of
/ideate
, use
mcp__exarchos__exarchos_workflow
with
action: "init"
with:
  • featureId
    : the workflow identifier (e.g.,
    "user-authentication"
    )
  • workflowType
    : one of
    "feature"
    ,
    "debug"
    ,
    "refactor"
    ,
    "oneshot"
  • synthesisPolicy
    (optional, oneshot only): one of
    "always"
    ,
    "never"
    ,
    "on-request"
    (default
    "on-request"
    ) — silently ignored for non-oneshot types
This creates a new workflow state entry. The initial phase depends on
workflowType
:
  • feature
    → starts in
    ideate
  • debug
    → starts in
    triage
  • refactor
    → starts in
    explore
  • oneshot
    → starts in
    plan
    (skips ideate entirely)
/ideate
启动时,使用
mcp__exarchos__exarchos_workflow
并设置
action: "init"
,同时传入:
  • featureId
    :工作流标识符(示例:
    "user-authentication"
  • workflowType
    :可选值为
    "feature"
    "debug"
    "refactor"
    "oneshot"
  • synthesisPolicy
    可选,仅适用于oneshot):可选值为
    "always"
    "never"
    "on-request"
    (默认值
    "on-request"
    )——非oneshot类型会自动忽略该参数
此操作将创建新的工作流状态条目。初始阶段取决于
workflowType
  • feature
    → 初始阶段为
    ideate
  • debug
    → 初始阶段为
    triage
  • refactor
    → 初始阶段为
    explore
  • oneshot
    → 初始阶段为
    plan
    (直接跳过ideate阶段)

Workflow Types at a Glance

工作流类型概览

  • feature
    — full
    ideate → plan → delegate → review → synthesize
    for real features with subagent dispatch and two-stage review
  • debug
    triage → investigate → (thorough | hotfix)
    for bug workflows with track selection
  • refactor
    explore → brief → (polish | overhaul)
    for code improvements, polish for small and overhaul for multi-task
  • oneshot
    plan → implementing → (completed | synthesize)
    for trivial changes; direct-commit by default with an opt-in PR path resolved via a choice-state guard driven by
    synthesisPolicy
    and the
    synthesize.requested
    event
See
@skills/oneshot-workflow/SKILL.md
for the lightweight variant's full prose, including the choice-state mechanics and
finalize_oneshot
trigger.
  • feature
    — 完整的
    ideate → plan → delegate → review → synthesize
    流程,适用于包含子Agent调度和两阶段评审的正式功能开发
  • debug
    triage → investigate → (thorough | hotfix)
    流程,适用于包含路径选择的Bug修复工作流
  • refactor
    explore → brief → (polish | overhaul)
    流程,适用于代码优化,polish用于小型优化,overhaul用于多任务重构
  • oneshot
    plan → implementing → (completed | synthesize)
    流程,适用于微小变更;默认直接提交,可通过
    synthesisPolicy
    synthesize.requested
    事件驱动的选择状态防护条件开启PR路径
关于轻量型变体的完整说明,包括选择状态机制和
finalize_oneshot
触发器,请参考
@skills/oneshot-workflow/SKILL.md

Read State

读取状态

Use
mcp__exarchos__exarchos_workflow
with
action: "get"
and
featureId
:
  • Full state: Call with just
    featureId
  • Specific field: Add
    query
    for dot-path lookup (e.g.,
    query: "phase"
    ,
    query: "tasks"
    )
  • Multiple fields: Add
    fields
    array for projection (e.g.,
    fields: ["phase", "featureId", "tasks"]
    )
Field projection via
fields
returns only the requested top-level keys, reducing token cost.
使用
mcp__exarchos__exarchos_workflow
并设置
action: "get"
featureId
  • 完整状态:仅传入
    featureId
    即可
  • 特定字段:添加
    query
    参数进行点路径查询(示例:
    query: "phase"
    query: "tasks"
  • 多个字段:添加
    fields
    数组进行投影查询(示例:
    fields: ["phase", "featureId", "tasks"]
通过
fields
进行字段投影仅返回指定的顶层键,可降低Token消耗。

Update State

更新状态

Use
mcp__exarchos__exarchos_workflow
with
action: "set"
with
featureId
and either
updates
,
phase
, or both:
  • 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_workflow
并设置
action: "set"
,同时传入
featureId
以及
updates
phase
或两者:
  • 更新阶段
    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
数组

The dot-path parser used by
set updates
recognizes only numeric array brackets (
tasks[0]
,
tasks[1]
, …). Keyed forms like
tasks[id=T-001]
are NOT supported and now throw an
INVALID_INPUT
error with a clear message — earlier versions silently wrote to a bogus top-level key, returning
success: true
while the actual task was untouched. Three patterns are supported:
  1. 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" },
      ]},
    })
  2. 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
    (
    action: "get", query: "tasks"
    ) to find the index of the task you want to edit, then set by that index.
  3. Append a new task by writing to the next-free index. If the array currently has length
    N
    , write to
    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 (
    MAX_ARRAY_GAP = 1
    ); writing further out (
    tasks[5]
    against a length-2 array) throws
    INVALID_INPUT
    . Read the current
    tasks
    length before appending.
set updates
使用的点路径解析器仅支持数字数组括号(
tasks[0]
tasks[1]
等)。
tasks[id=T-001]
这类键值形式不被支持,会直接抛出
INVALID_INPUT
错误并给出明确提示——早期版本会静默写入错误的顶层键,返回
success: true
但实际任务未被修改。支持以下三种模式:
  1. 替换整个数组(当计划需要全面修订时使用;符合issue #1003约定):
    typescript
    exarchos_workflow({
      action: "set",
      featureId: "<id>",
      updates: { tasks: [
        { id: "T-001", title: "...", status: "pending" },
        { id: "T-002", title: "...", status: "pending" },
      ]},
    })
  2. 按数组索引编辑单个任务
    typescript
    exarchos_workflow({
      action: "set",
      featureId: "<id>",
      updates: { "tasks[0].status": "complete", "tasks[0].completedAt": "<ts>" },
    })
    先读取
    tasks
    action: "get", query: "tasks"
    )找到目标任务的索引,再按该索引进行设置。
  3. 追加新任务:写入下一个可用索引。如果当前数组长度为
    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" } },
    })
    解析器允许写入当前长度之后的一个位置(
    MAX_ARRAY_GAP = 1
    );写入超出范围的位置(如长度为2的数组写入
    tasks[5]
    )会抛出
    INVALID_INPUT
    错误。追加前请先读取当前
    tasks
    的长度。

Get Summary

获取摘要

For context restoration after summarization, use
mcp__exarchos__exarchos_workflow
with
action: "get"
and
featureId
. This outputs a minimal summary suitable for rebuilding orchestrator context.
总结后恢复上下文时,使用
mcp__exarchos__exarchos_workflow
并设置
action: "get"
featureId
。此操作会输出用于重建编排器上下文的极简摘要。

Reconcile 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
passed: true
:
State is consistent. On
passed: false
:
Discrepancies found — review output and resolve.
为验证状态与git实际情况一致,SessionStart钩子会在恢复时自动执行对账操作。如需手动验证,运行对账脚本:
typescript
exarchos_orchestrate({
  action: "reconcile_state",
  stateFile: "<state-file>",
  repoRoot: "<repo-root>"
})
passed: true
:状态一致。
passed: false
:发现不一致——请查看输出并解决问题。

Integration Points

集成点

When to Update State

状态更新时机

EventState Update
/ideate
starts
Create state file
Design savedSet
artifacts.design
, phase = "plan"
Plan savedSet
artifacts.plan
, populate tasks, phase = "plan-review"
Plan-review gaps foundSet
planReview.gaps
, auto-loop to plan
Plan-review approvedSet
planReview.approved = true
, phase = "delegate"
Task dispatchedSet task
status = "in_progress"
,
startedAt
Task completeSet task
status = "complete"
,
completedAt
Worktree createdAdd to
worktrees
object
Review completeUpdate
reviews
object
PR createdSet
artifacts.pr
,
synthesis.prUrl
PR feedbackAppend to
synthesis.prFeedback
事件状态更新操作
/ideate
启动
创建状态文件
设计文档保存设置
artifacts.design
,阶段设为"plan"
计划文档保存设置
artifacts.plan
,填充tasks,阶段设为"plan-review"
计划评审发现问题设置
planReview.gaps
,自动循环回plan阶段
计划评审通过设置
planReview.approved = true
,阶段设为"delegate"
任务分派设置任务
status = "in_progress"
,记录
startedAt
任务完成设置任务
status = "complete"
,记录
completedAt
工作树创建添加至
worktrees
对象
评审完成更新
reviews
对象
PR创建设置
artifacts.pr
synthesis.prUrl
PR反馈追加至
synthesis.prFeedback

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.
PhaseState updatesEvents emitted
plan
(oneshot)
oneshot.planSummary
,
artifacts.plan
, optional
oneshot.synthesisPolicy
workflow.transition
implementing
(oneshot)
tasks[].status
,
artifacts.tests
task.*
, optional
synthesize.requested
(via
request_synthesize
)
synthesize
(oneshot)
synthesis.prUrl
,
artifacts.pr
workflow.transition
,
stack.submitted
completed
(oneshot)
workflow.transition
(to
completed
)
The
implementing → synthesize | completed
fork is a choice state resolved by
finalize_oneshot
, which reads the
synthesisOptedIn
guard (
synthesisPolicy
+
synthesize.requested
events). See
@skills/oneshot-workflow/SKILL.md
for the full opt-in mechanics.
Oneshot是一等工作流类型,具有压缩的生命周期和可选PR路径。以下表格与上方功能工作流表格对应。
阶段状态更新触发事件
plan
(oneshot)
oneshot.planSummary
artifacts.plan
、可选
oneshot.synthesisPolicy
workflow.transition
implementing
(oneshot)
tasks[].status
artifacts.tests
task.*
、可选
synthesize.requested
(通过
request_synthesize
触发)
synthesize
(oneshot)
synthesis.prUrl
artifacts.pr
workflow.transition
stack.submitted
completed
(oneshot)
workflow.transition
(切换至
completed
implementing → synthesize | completed
分支是由
finalize_oneshot
解析的选择状态,该函数会读取
synthesisOptedIn
防护条件(
synthesisPolicy
+
synthesize.requested
事件)。关于完整的可选PR机制,请参考
@skills/oneshot-workflow/SKILL.md

Automatic 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 checkpoint
Skills应在关键节点更新状态:
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
docs/schemas/workflow-state.schema.json
for full schema.
Key sections:
  • version
    : Schema version (currently "1.1")
  • featureId
    : Unique workflow identifier
  • workflowType
    : Required. One of "feature", "debug", "refactor", or "oneshot"
  • phase
    : Current workflow phase
  • artifacts
    : Paths to design, plan, PR
  • tasks
    : Task list with status
  • worktrees
    : Active git worktrees
  • planReview
    : Plan-review delta analysis results (
    gaps
    ,
    approved
    )
  • reviews
    : Review results
  • synthesis
    : Merge/PR state
完整模式请参考
docs/schemas/workflow-state.schema.json
关键部分:
  • version
    :模式版本(当前为"1.1")
  • featureId
    :唯一工作流标识符
  • workflowType
    :必填项。可选值为"feature"、"debug"、"refactor"或"oneshot"
  • phase
    :当前工作流阶段
  • artifacts
    :设计文档、计划文档、PR的路径
  • tasks
    :带状态的任务列表
  • worktrees
    :活跃的git工作树
  • planReview
    :计划评审差异分析结果(
    gaps
    approved
  • reviews
    :评审结果
  • synthesis
    :合并/PR状态

Best Practices

最佳实践

  1. Update often - State should reflect reality at all times
  2. Use MCP tools - Prefer workflow-state MCP tools over manual JSON editing
  3. Reconcile on resume - Always verify state matches git state
  4. Checkpoint at boundaries - Save state before likely context exhaustion
  5. Read state, don't remember - After summarization, read from state file
  1. 频繁更新 - 状态应始终反映实际情况
  2. 使用MCP工具 - 优先使用工作流状态MCP工具,而非手动编辑JSON
  3. 恢复时对账 - 始终验证状态与git状态一致
  4. 边界处创建检查点 - 在可能出现上下文耗尽前保存状态
  5. 读取状态,而非记忆 - 总结后从状态文件读取信息

Troubleshooting

故障排查

MCP Tool Call Failed

MCP工具调用失败

If an Exarchos MCP tool returns an error:
  1. Check the error message — it usually contains specific guidance
  2. Verify the workflow state exists: call
    mcp__exarchos__exarchos_workflow
    with
    action: "get"
    and the featureId
  3. If "version mismatch": another process updated state — retry the operation
  4. If state is corrupted: call
    mcp__exarchos__exarchos_workflow
    with
    action: "cancel"
    and
    dryRun: true
如果Exarchos MCP工具返回错误:
  1. 查看错误信息——通常包含具体指导
  2. 验证工作流状态是否存在:调用
    mcp__exarchos__exarchos_workflow
    并设置
    action: "get"
    和对应的featureId
  3. 若提示"version mismatch":其他进程已更新状态——重试操作
  4. 若状态损坏:调用
    mcp__exarchos__exarchos_workflow
    并设置
    action: "cancel"
    dryRun: true

State Desync

状态不同步

If workflow state doesn't match git reality:
  1. The SessionStart hook runs reconciliation automatically on resume
  2. If manual check needed: compare state file with
    git log
    and branch state
  3. Update state via
    mcp__exarchos__exarchos_workflow
    with
    action: "set"
    to match git truth
如果工作流状态与git实际情况不符:
  1. SessionStart钩子会在恢复时自动执行对账
  2. 如需手动检查:对比状态文件与
    git log
    及分支状态
  3. 使用
    mcp__exarchos__exarchos_workflow
    并设置
    action: "set"
    更新状态,使其与git实际情况一致

Checkpoint File Missing

检查点文件缺失

If the PreCompact hook can't find state to checkpoint:
  1. Verify a workflow is active: call
    mcp__exarchos__exarchos_workflow
    with
    action: "get"
    and the featureId
  2. If no active workflow: the hook will silently skip (expected behavior)
  3. If workflow exists but checkpoint fails: check disk space and permissions
如果PreCompact钩子无法找到用于创建检查点的状态:
  1. 验证是否存在活跃工作流:调用
    mcp__exarchos__exarchos_workflow
    并设置
    action: "get"
    和对应的featureId
  2. 若无活跃工作流:钩子会静默跳过(预期行为)
  3. 若工作流存在但检查点创建失败:检查磁盘空间和权限

Resume Finds Stale State

恢复时发现过期状态

If state references branches or worktrees that no longer exist:
  1. The SessionStart hook handles reconciliation automatically
  2. It updates state to reflect current git reality
  3. Missing branches are flagged in the session-start output
如果状态引用的分支或工作树已不存在:
  1. SessionStart钩子会自动处理对账
  2. 它会更新状态以反映当前git实际情况
  3. 缺失的分支会在会话启动输出中标记

Multiple Active Workflows

多个活跃工作流

If multiple workflow state files exist:
  1. The system uses the most recently updated active (non-completed) workflow
  2. Use
    mcp__exarchos__exarchos_workflow
    with
    action: "cancel"
    and
    dryRun: true
    on stale workflows to preview cleanup
  3. Cancel stale workflows before starting new ones
如果存在多个工作流状态文件:
  1. 系统会使用最近更新的活跃(未完成)工作流
  2. 对过期工作流调用
    mcp__exarchos__exarchos_workflow
    并设置
    action: "cancel"
    dryRun: true
    ,预览清理操作
  3. 在启动新工作流前取消过期工作流

Example Workflow

示例工作流

  1. Start new workflow: Use
    mcp__exarchos__exarchos_workflow
    with
    action: "init"
    with
    featureId: "user-authentication"
    ,
    workflowType: "feature"
  2. After design phase: Use
    mcp__exarchos__exarchos_workflow
    with
    action: "set"
    with:
    • featureId: "user-authentication"
    • phase: "plan"
    • updates: { "artifacts.design": "docs/designs/2026-01-05-user-auth.md" }
  3. Check state: Use
    mcp__exarchos__exarchos_workflow
    with
    action: "get"
    with
    featureId: "user-authentication"
  4. Resume after context loss: Use
    mcp__exarchos__exarchos_workflow
    with
    action: "get"
    with
    featureId: "user-authentication"
    to get context restoration output
  1. 启动新工作流:使用
    mcp__exarchos__exarchos_workflow
    并设置
    action: "init"
    ,同时传入
    featureId: "user-authentication"
    workflowType: "feature"
  2. 设计阶段完成后:使用
    mcp__exarchos__exarchos_workflow
    并设置
    action: "set"
    ,同时传入:
    • featureId: "user-authentication"
    • phase: "plan"
    • updates: { "artifacts.design": "docs/designs/2026-01-05-user-auth.md" }
  3. 检查状态:使用
    mcp__exarchos__exarchos_workflow
    并设置
    action: "get"
    featureId: "user-authentication"
  4. 上下文丢失后恢复:使用
    mcp__exarchos__exarchos_workflow
    并设置
    action: "get"
    featureId: "user-authentication"
    获取上下文恢复输出