plan-graph
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePlan Graph
Plan Graph(计划图谱)
Turn plan markdown into a concrete graph instead of hand-waving over the document structure. This skill is for plan-driven orchestration, not for live steering once workers are already moving.
将计划 Markdown 转换为具体的图结构,而不是在文档结构上含糊其辞。该 skill 用于基于计划的编排,而非在 worker 已经开始运行后进行实时引导。
Handoff Contract
交接契约
For plan-backed orchestration, treat this as the canonical handoff bundle:
- the exact plan selection: explicit paths, or
--planplus--plans-root--glob - any explicit edges
--depends source:target - the resolved
graph_id selection_hash- and
snapshot_pathwhen a snapshot exists on diskstate_dir
Carry the same selection when auto-managed reuse is acceptable. Carry the explicit when downstream work must attach to one exact saved slot regardless of selection context.
graph_id对于基于计划的编排,应将以下内容视为标准交接包:
- 精确的计划选择:显式 路径,或
--plan加--plans-root--glob - 所有显式 边
--depends source:target - 解析出的
graph_id selection_hash- 磁盘上存在 snapshot 时的 和
snapshot_pathstate_dir
如果允许自动管理并复用状态,请沿用相同的选择。如果下游工作必须附加到一个精确的已保存 slot,无论选择上下文如何,都请沿用显式 。
graph_idCanonical Inputs
标准输入
Default search root:
- in the current working directory
./.codex/plans - override with
--plans-root - or set or
CODEX_PLANS_ROOTCODEX_HOME
Expected frontmatter shape:
nameoverviewtodosisProject
Expected todo shape:
idcontentstatus
Expected todo statuses in the current local corpus:
pendingin_progresscompleted
The parser is intentionally tolerant of imperfect plans such as empty names, empty overviews, and . Treat those as warnings unless the calling task explicitly wants strict validation.
todos: []Recommended file shape below the frontmatter:
- repeat the plan name as the top-level heading
- add short markdown sections such as ,
Execution Notes,Constraints, orReferencesOperator Guidance - keep the body focused on narrative guidance that frontmatter cannot express cleanly
- write the body as something a subagent can read end-to-end to understand intent, boundaries, success criteria, and implementation guidance without relying only on the frontmatter
Do not duplicate the overview paragraph or the todo list in the markdown body unless a caller explicitly wants that redundancy. The frontmatter remains the machine-readable source of truth for graphing and status.
When creating new plan files, start from and adapt it instead of inventing the body structure ad hoc.
references/plan-template.plan.md默认搜索根目录:
- 当前工作目录中的
./.codex/plans - 使用 覆盖
--plans-root - 或设置 或
CODEX_PLANS_ROOTCODEX_HOME
预期的 frontmatter 结构:
nameoverviewtodosisProject
预期的 todo 结构:
idcontentstatus
当前本地语料中的预期 todo 状态:
pendingin_progresscompleted
解析器有意容忍不完整的计划,例如名称为空、概述为空以及 。除非调用任务明确要求严格验证,否则应将其视为警告。
todos: []frontmatter 下推荐的正文结构:
- 将计划名称重复为顶级标题
- 添加简短的 Markdown 章节,例如 、
Execution Notes、Constraints或ReferencesOperator Guidance - 让正文专注于 frontmatter 无法清晰表达的叙述性指导
- 将正文写成 subagent 能够从头读到尾的内容,使其可以理解意图、边界、成功标准和实施指导,而不必只依赖 frontmatter
除非调用方明确需要这种冗余,否则不要在 Markdown 正文中重复概述段落或 todo 列表。对于图构建和状态跟踪,frontmatter 仍然是机器可读的事实来源。
创建新计划文件时,应从 开始并进行调整,而不是临时臆造正文结构。
references/plan-template.plan.mdDurable State
持久化状态
Do not rely on implicit thread or agent metadata for cross-agent persistence.
- If you pass or set
--graph-id <id>, the tool uses that explicit graph slot.GRAPH_ID - If you omit , the tool reuses the latest slot for the same resolved plan selection and rewrites that snapshot from current plan files before reporting.
GRAPH_ID - A plan selection means both the resolved absolute plan paths and any explicit edges.
--depends - If no saved snapshot matches, it creates a managed graph slot automatically from that selection and writes a snapshot for later reuse.
- Persist shared state under by default.
./.codex/plan-graphs/<resolved-graph-id>/ - Override the snapshot root with ,
--state-dir, orCODEX_PLAN_GRAPHS_ROOT.CODEX_HOME - forces persistence for an explicit graph id.
--write-state - If you use an explicit without
--graph-id, only treat--write-stateas real when the command output actually includes it.snapshot_path
This survives across root agent work, spawned workers, explorers, and later resumptions far better than thread-local context.
不要依赖隐式 thread 或 agent metadata 实现跨 Agent 持久化。
- 如果传入 或设置
--graph-id <id>,工具将使用该显式 graph slot。GRAPH_ID - 如果省略 ,工具会复用同一已解析计划选择对应的最新 slot,并在输出报告前根据当前计划文件重写该 snapshot。
GRAPH_ID - 计划选择同时包含解析后的绝对计划路径和所有显式 边。
--depends - 如果没有匹配的已保存 snapshot,工具会根据该选择自动创建一个受管理的 graph slot,并写入 snapshot 供后续复用。
- 默认在 下持久化共享状态。
./.codex/plan-graphs/<resolved-graph-id>/ - 使用 、
--state-dir或CODEX_PLAN_GRAPHS_ROOT覆盖 snapshot 根目录。CODEX_HOME - 会强制为显式 graph id 持久化状态。
--write-state - 如果使用显式 但未指定
--graph-id,只有在命令输出实际包含--write-state时,才应将其视为真实存在。snapshot_path
与 thread-local context 相比,这种方式能更好地跨 root Agent 工作、派生 worker、explorer 以及后续恢复而持续存在。
Workflow
工作流
- Choose the plan set.
- Use explicit paths when the task already points at specific plans.
--plan - Otherwise search the default or overridden plans root with .
--glob - If you need to author new plan files first, copy and then fill in the frontmatter plus the detailed markdown body.
references/plan-template.plan.md - Or use to scaffold a plan set and persisted graph state automatically.
scripts/plan_graph.py generate --breadth N --depth M
- Use explicit
- Validate the plan corpus first.
- Run .
scripts/plan_graph.py validate
- Run
- Validation covers both parse quality and graph integrity: duplicate plan names or slugs, duplicate todo ids, empty todo content, self-dependencies, dependency cycles, and orphaned plan nodes.
- In a multi-plan selection, every selected plan should participate in at least one dependency edge. If a plan is documentation-only or an umbrella wrapper, either link it explicitly or leave it out of the active graph selection.
- Because inter-plan edges connect the source plan's final todo to the target plan's first todo, wrapper or project-summary plans usually work best as downstream rollup nodes unless their todo sequence is intentionally written to gate all child work.
- Use only when malformed plans should fail the workflow.
--strict
- Use
- Start with a quick summary when you need orientation.
- Run .
scripts/plan_graph.py summary - This gives the per-plan status plus handoff state without flooding the operator with the full DAG.
- Run
- Build the graph when structure matters.
- Run for a full text or JSON DAG.
scripts/plan_graph.py dag - Run a visual pass with whenever you need to confirm roots, parallel branches, blocked lanes, or whether the umbrella project plan is incorrectly acting like an execution node.
--format mermaid - Mermaid output intentionally omits the plain-text handoff footer, so pair it with a text or JSON /
dagrun when you also need the resolved graph id, blockers, or handoff state.frontier - Add edges when plan-to-plan sequencing is known but not stored in frontmatter.
--depends source:target - In text mode, this command prints lines for downstream handoff.
handoff state
- Run
- Surface launchable work.
- Run .
scripts/plan_graph.py frontier --lanes N --max-depth M - This gives the next executable lane per plan after accounting for completed todos and explicit upstream plan dependencies.
- In text mode, this command also includes the same footer.
handoff state
- Run
- Visually check the graph before handing it off.
- Render the graph with .
scripts/plan_graph.py dag --format mermaid - Confirm the critical path, any parallel lanes, and every relationship shown by the matching text
blocked_byordagrun.frontier - If the visual graph shows a documentation-only wrapper plan acting like a runnable lane, either remove it from the active selection or add explicit dependencies so it is no longer an orphaned node.
- Render the graph with
- Inspect what already exists before minting new work.
- Run to see existing plan files.
scripts/plan_graph.py plans - Run to see saved graph snapshots.
scripts/plan_graph.py graphs - Run to preview matched plan-file deletion, then rerun with
scripts/plan_graph.py delete-planto actually delete them.--yes - Use when you need machine-readable
--format json,graph_id,selection_hash,snapshot_path,state_dir,plan_count, oredge_countfor downstream operators.selected_plan_paths
- Run
- Preserve exact targeting across subagents.
- Rerun any /
--planselection plus the same--globedges to resolve the same auto-managed graph slot.--depends - For strict targeting, pass an explicit (or reuse the resolved one from prior output).
--graph-id - Prefer or
--format jsonwhenever you need the exactgraphs --format json,graph_id,selection_hash, orstate_dir.snapshot_path
- Rerun any
- Persist or reuse the shared snapshot when the graph will feed other skills.
- In the common case, rerun the same plan selection and let the tool auto-reuse the saved slot.
- Hand the resolved to
GRAPH_ID,subagent-graph, ordagonly when another tool or agent truly needs that exact slot.helm
- 选择计划集合。
- 当任务已经指向特定计划时,使用显式 路径。
--plan - 否则,使用 搜索默认或覆盖后的 plans root。
--glob - 如果需要先编写新的计划文件,请复制 ,然后填写 frontmatter 和详细的 Markdown 正文。
references/plan-template.plan.md - 或使用 自动生成计划集合和持久化的图状态。
scripts/plan_graph.py generate --breadth N --depth M
- 当任务已经指向特定计划时,使用显式
- 首先验证计划集合。
- 运行 。
scripts/plan_graph.py validate
- 运行
- 验证同时涵盖解析质量和图完整性:重复的计划名称或 slug、重复的 todo id、todo 内容为空、自依赖、依赖环,以及孤立的计划节点。
- 在多计划选择中,每个选中的计划都应至少参与一条依赖边。如果某个计划仅用于文档或是 umbrella wrapper,要么显式链接它,要么将其排除在活动图选择之外。
- 由于计划间的边会将源计划的最后一个 todo 连接到目标计划的第一个 todo,wrapper 或 project-summary 计划通常最适合作为下游 rollup 节点,除非其 todo 序列有意被编写为 gate 所有子项工作。
- 仅当格式错误的计划应导致工作流失败时,才使用 。
--strict
- 仅当格式错误的计划应导致工作流失败时,才使用
- 需要快速掌握整体情况时,先获取摘要。
- 运行 。
scripts/plan_graph.py summary - 它会提供每个计划的状态和 handoff state,而不会用完整 DAG 淹没操作者。
- 运行
- 当结构很重要时构建图。
- 运行 获取完整的文本或 JSON DAG。
scripts/plan_graph.py dag - 每当需要确认根节点、并行分支、阻塞通道,或 umbrella project plan 是否错误地充当执行节点时,都使用 进行可视化检查。
--format mermaid - Mermaid 输出有意省略纯文本 handoff footer,因此当还需要解析后的 graph id、blockers 或 handoff state 时,请配合文本或 JSON 格式的 /
dag运行。frontier - 当已知计划间的执行顺序但尚未存储在 frontmatter 中时,添加 边。
--depends source:target - 在文本模式下,该命令会为下游交接打印 行。
handoff state
- 运行
- 找出可启动的工作。
- 运行 。
scripts/plan_graph.py frontier --lanes N --max-depth M - 在考虑已完成的 todo 和显式上游计划依赖后,它会给出每个计划的下一条可执行通道。
- 在文本模式下,该命令还会包含相同的 footer。
handoff state
- 运行
- 在交接前对图进行可视化检查。
- 使用 渲染图。
scripts/plan_graph.py dag --format mermaid - 确认关键路径、所有并行通道,以及匹配的文本 或
dag结果中显示的每条frontier关系。blocked_by - 如果可视化图显示仅用于文档的 wrapper plan 表现得像可运行通道,则将其从活动选择中移除,或添加显式依赖,使其不再是孤立节点。
- 使用
- 在创建新工作之前检查已有内容。
- 运行 查看现有计划文件。
scripts/plan_graph.py plans - 运行 查看已保存的 graph snapshot。
scripts/plan_graph.py graphs - 运行 预览匹配的计划文件删除操作,然后使用
scripts/plan_graph.py delete-plan重新运行以实际删除。--yes - 当下游操作需要机器可读的 、
graph_id、selection_hash、snapshot_path、state_dir、plan_count或edge_count时,使用selected_plan_paths。--format json
- 运行
- 在 subagent 之间保持精确目标。
- 重新运行任何 /
--plan选择以及相同的--glob边,以解析同一个自动管理的 graph slot。--depends - 对于严格定位,请传入显式 ,或复用之前输出中解析出的 graph id。
--graph-id - 每当需要精确的 、
graph_id、selection_hash或state_dir时,优先使用snapshot_path或--format json。graphs --format json
- 重新运行任何
- 当图将提供给其他 skills 时,持久化或复用共享 snapshot。
- 在常见情况下,重新运行相同的选择计划,并让工具自动复用已保存的 slot。
- 仅当另一个工具或 Agent 确实需要该精确 slot 时,才将解析出的 交给
GRAPH_ID、subagent-graph或dag。helm
Commands
命令
Use the bundled CLI instead of re-parsing plan files ad hoc:
bash
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py generate --plans-root ./.codex/plans --graph-id example-graph --title-prefix "Example Plan" --slug-prefix example-plan --breadth 2 --depth 2 --todo-count 3
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py generate --plans-root ./.codex/plans --state-dir ./.codex/plan-graphs --title-prefix "Migration Plan" --slug-prefix migration-plan --breadth 3 --depth 2 --format json
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py plans --glob '*.plan.md'
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py graphs
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py delete-plan --plan "$PLAN_PATH"
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py delete-plan --plan "$PLAN_PATH" --yes
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py validate --glob '*.plan.md'
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py summary --plan "$PLAN_PATH"
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py summary --glob '*subagent*.plan.md' --format json
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py dag --plan "$PLAN_PATH" --format mermaid
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py dag --plans-root ./.codex/plans --glob '*subagent*.plan.md' --depends source:target --format mermaid
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py dag --plan "$PLAN_PATH"
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py frontier --glob '*subagent*.plan.md' --lanes 3 --max-depth 2 --format json
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py frontier --glob '*subagent*.plan.md' --lanes 3 --max-depth 2 --graph-id subagents-v1 --write-state使用随附的 CLI,而不是临时重复解析计划文件:
bash
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py generate --plans-root ./.codex/plans --graph-id example-graph --title-prefix "Example Plan" --slug-prefix example-plan --breadth 2 --depth 2 --todo-count 3
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py generate --plans-root ./.codex/plans --state-dir ./.codex/plan-graphs --title-prefix "Migration Plan" --slug-prefix migration-plan --breadth 3 --depth 2 --format json
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py plans --glob '*.plan.md'
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py graphs
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py delete-plan --plan "$PLAN_PATH"
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py delete-plan --plan "$PLAN_PATH" --yes
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py validate --glob '*.plan.md'
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py summary --plan "$PLAN_PATH"
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py summary --glob '*subagent*.plan.md' --format json
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py dag --plan "$PLAN_PATH" --format mermaid
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py dag --plans-root ./.codex/plans --glob '*subagent*.plan.md' --depends source:target --format mermaid
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py dag --plan "$PLAN_PATH"
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py frontier --glob '*subagent*.plan.md' --lanes 3 --max-depth 2 --format json
python /Users/zackjackson/.codex/skills/plan-graph/scripts/plan_graph.py frontier --glob '*subagent*.plan.md' --lanes 3 --max-depth 2 --graph-id subagents-v1 --write-stateBoundaries
边界
- Use after the plan graph is known and you need launch waves, ownership, and merge sequencing.
subagent-graph - Use when you only need the current frontier, blocked lanes, or plan progress. The
dagskill is the frontier/status companion, not the full DAG renderer.dag - Use when workers are already active and the problem is operational steering.
helm - removes matched plan files only. It does not prune saved graph snapshots.
delete-plan - is for scaffolding plan files and a matching saved graph slot. It is not a substitute for execution planning after real todo content is known.
generate
Read when you need the exact frontmatter assumptions, the on-disk state layout, or the saved-slot matching rules.
references/cursor-plan-format.md- 在 plan graph 已明确,并且需要启动波次、所有权分配和合并顺序时,使用 。
subagent-graph - 仅需当前 frontier、阻塞通道或计划进度时,使用 。
dagskill 是 frontier/status 的配套工具,而不是完整的 DAG renderer。dag - 当 worker 已经活跃且问题属于操作层面的引导时,使用 。
helm - 仅删除匹配的计划文件,不会清理已保存的 graph snapshot。
delete-plan - 用于搭建计划文件和匹配的已保存 graph slot,不能替代在明确真实 todo 内容后进行执行规划。
generate
当需要了解确切的 frontmatter 假设、磁盘状态布局或已保存 slot 的匹配规则时,请阅读 。
references/cursor-plan-format.md