dh-execute-plan
Orchestrate full plan execution: read plan.md, iterate sub-tasks delegating execution and review, resume on interruption, final-review sign-off, update index.md. Use when the user says 'execute plan', 'run the plan', or 'finish all tasks'.
- License 许可
- MIT
- 最近更新
- 2026-11-10
- Stars
- ★ 8
- Forks
- 1
01 前言 Front Matter
- name
- dh-execute-plan
- license
- MIT
- metadata
- { "audience": "developers", "workflow": "development" }
- description
- Orchestrate full plan execution: read plan.md, iterate sub-tasks delegating execution and review, resume on interruption, final-review sign-off, update index.md. Use when the user says 'execute plan', 'run the plan', or 'finish all tasks'.
- allowed-tools
- read, write, edit, bash
- compatibility
- opencode, copilot, antigravity
03 SKILL.md 正文
Orchestrate the complete execution of a plan from start to finish. Iterate through all phases and their sub-tasks in order, delegate execution and review, handle interruptions, and produce a final sign-off.
Core Rules
- Create a feature branch per plan execution
- Check you are in main branch and create the feature branch.
- If not in feature branch, ask user permission to continue before any change.
- if working in monorepos with git submodules create a branch per submodule along with the branch of the main repository to align and trace commints between repositories.
- Read the plan with the
dh_plan_readtool ({ slug }→ structured JSON: meta, phases[].title/status, subTasks[].phase/title/status). Fallback when the tool is unavailable: read./docs/plans/<plan-slug>/plan.mdmanually, following the phased template markers (## Phases→### Phase N: <title>→#### Sub-Task N.M: <title>with- **Status:**bullets). These tools are exposed by the project-scopedhMCP server; under Code Mode they are called astools.dh.<tool>, anddh_<tool>is the tool's normalized name (permission actions matchdh_*). - If the plan file does not exist, stop and report — suggest running the
dh-planningskill first. - Paused handoff guard: if
./docs/plans/<plan-slug>/handoff.mdexists withstatus: paused, do not start execution from plan statuses. Stop and direct the user todh-resume-planfor that slug (it rehydrates context and detects drift). Bypass only on an explicit user instruction to skip rehydration. - Iterate phases in order; within each phase, iterate its sub-tasks in order.
- Phase lifecycle: a phase becomes
In Progresswhen its first sub-task starts; it becomesCompletedonly when ALL its sub-tasks areCompleted. - Do not re-execute sub-tasks already marked
Completed. - If a sub-task is marked
In Progress, resume from it (don't restart from the beginning). - Update statuses with the
dh_plan_update_statustool ({ slug, target: "phase"|"subtask", index: "N"|"N.M", status }): mark a sub-taskIn Progressbefore execution,Completedafter its review passes, and a phaseCompletedonly when all its sub-tasks areCompleted. Fallback when the tool is unavailable: manual plan.md edits following the marker rules (only blank lines precede status bullets). - After each sub-task execution, run the
dh-reviewskill before proceeding to the next. - If a review produces P0/P1 findings, stop and report — do not continue to the next sub-task (a blocked sub-task blocks its phase).
- After the final sub-task, run the
dh-final-reviewskill for sign-off. - Update
./docs/plans/index.mdwhen the plan is fully complete. - Resolve the roster once per plan: before the first delegation, read
## Agent Selectioninplan.mdand validate its rows for the delegated, review, and final-review roles. If the section or a required row is absent or stale (a named agent no longer exists), run the selection protocol in../dh-planning/references/agent-selection.md: discover the runtime agent list, then project config/agent directories, then global definitions; record the choices and generic fallbacks in the plan before continuing. - One delegated agent per sub-task: the active sub-task's
Delegated to agentis the single executor. Implementation sub-tasks normally name the selected implementation agent; documentation/test-only sub-tasks name the matching selected role. There is no complexity- or type-based builder split. If the field is missing/empty/unknown or the named agent is unavailable, stop and report the gap — never substitute one silently. - Project type awareness is delegated to
dh-execute-plan-task. The orchestrator does not re-detect project type — the task skill runs the software/non-software post-steps. Do not hardcode implementation, review, or final-review agent choices in the orchestration loop. - After plan completion (all projects): invoke
dh-create-documentationto update docs and create the plan's evolution + observation notes (see its Custom Directives). This ensures knowledge persists beyond the active session. - After plan completion (software projects only): invoke
dh-semverfor determining the next version bump.
Workflow
Step 1: Read plan and assess state
Read the plan (via dh_plan_read; fallback: manual read) and determine the starting point using this ordered priority:
- Paused handoff: if
./docs/plans/<plan-slug>/handoff.mdexists withstatus: paused, stop and direct the user todh-resume-plan. Do not apply priorities 1–4 until the handoff isresumedor the user explicitly bypasses it. - If all sub-tasks are
Completed(every phaseCompleted), rundh-final-reviewskill only and proceed to Step 3. Skip the execution loop. - Resume mode: if one or more phases are
In Progress, start from the FIRSTIn Progressphase, then its FIRST sub-task markedIn ProgressorPending. - If all phases are
Pending(all sub-tasksPending), start from Phase 1's first sub-task. - If the plan has no phases/sub-tasks, or every phase/sub-task has an unrecognized status, report the ambiguous state and stop.
Step 2: Execution loop
Iterate phases in order (skip phases already Completed); within each phase, iterate its sub-tasks starting from the determined starting point:
- Mark In Progress: Ensure the active sub-task is marked
In Progressviadh_plan_update_status(target: "subtask"). If it is alreadyIn Progress(resume), leave the state. Marking the first sub-task of a phase also moves that phase toIn Progress(phase lifecycle). Fallback: manual plan.md edit per the marker rules. This ensures resume works if interrupted.
0b. Resolve agents: confirm the plan's ## Agent Selection names available agents for the delegated, review, and (at the end) final-review roles, and confirm the active sub-task carries a Delegated to agent that matches one of them. A missing/empty/unknown field is a hard blocker: stop and ask the planner/user to fix the plan before delegating. A selected agent missing with no capability fallback also stops the run.
-
Execute: Follow the
dh-execute-plan-taskskill to implement this sub-task. Since this is called from the orchestrator,dh-execute-plan-taskskips its internal review and completion steps (per its orchestration guard). -
Verify: Run the
dh-reviewskill to verify the sub-task result against its acceptance criteria and produce findings in./docs/plans/<plan-slug>/tasks/review.md. -
Check findings: Read the review output:
- If P0/P1 findings exist: stop the execution loop and report the blocking issues. Do not mark this sub-task
Completed— a blocked sub-task blocks its phase (loop rule 2.4). Recommend fixing findings and re-running. - If no P0/P1 findings: mark the sub-task
Completedviadh_plan_update_status(target: "subtask", statusCompleted). Fallback: manual edit.
- If P0/P1 findings exist: stop the execution loop and report the blocking issues. Do not mark this sub-task
3a. Close the phase: When ALL sub-tasks of the current phase are Completed, mark the phase Completed via dh_plan_update_status (target: "phase", status Completed; the tool refuses phase → Completed while any sub-task is open) and report the phase completion. Fallback: manual edit.
- Repeat: Continue to the next sub-task, then the next phase, until all phases are completed.
Step 3: Final sign-off
After all sub-tasks are completed and verified:
- Run the
dh-final-reviewskill for the comprehensive final plan review. - Read the final review verdict from
./docs/plans/<plan-slug>/tasks/review.md. - If the verdict is
Request changes: report the findings — do not mark the plan complete. - If the verdict is
ApproveorApprove with comments: proceed to Step 4.
Step 4: Document evolution and close
After final sign-off passes and before marking the plan complete:
-
Generate documentation (all projects): Invoke the
dh-create-documentationskill to update project docs and createdocs/evolution/<date>-<slug>.md(evolution note) +docs/evolution/observations/<date>-<hhmm>-<slug>.md(observation note), following its Custom Directives. -
Version bump (software projects only): Invoke the
dh-semverskill to determine the correct version bump from commit history, generate a changelog, and create a git tag. Backfill: afterdh-semverdetermines the version/tag, update the evolution note'sversionand the indexPlan/Releaseentry with the new version/tag. -
Mark plan complete in
./docs/plans/index.md:- Locate the row for
<plan-slug>and update the Status toCompletedand Updated timestamp columns. If the slug is not found, append a new row. - Set the plan status to
Completed.
- Locate the row for
-
Report the plan completion with a summary:
- Total sub-tasks completed
- Final review verdict
- Any deferred P2/P3 findings
- Documentation generated (yes/no — details)
- Version bump (if applicable)
- Evolution & observation notes (paths)
- Plan ready for merge
Resume Mode
The execution loop automatically handles interruptions:
- A paused handoff takes precedence over status-based resume: run
dh-resume-planfirst. If the handoff is absent or alreadyresumed, continue with the phase-aware priority in Step 1. - Step 2.0 explicitly marks the current sub-task as
In Progressbefore delegating todh-execute-plan-task. If the tool is interrupted, the next invocation reads the plan and finds thisIn Progresssub-task. - Resume from Step 1, which detects the phase-aware state (priority 2: first
In Progressphase → its firstIn Progress/Pendingsub-task) and continues the loop from there. - If interruption occurs after review but before the
Completedmark, the sub-task remainsIn Progresson resume — re-run the review to verify before marking Complete.
Error Handling
- Paused handoff present: do not execute around it — redirect to
dh-resume-planor get explicit confirmation to bypass. - Sub-task execution fails (validation keeps failing):
dh-execute-plan-taskstops after 3 validation attempts and reports the failure. Do not proceed to the next sub-task — the blocked sub-task blocks its phase (loop rule 2.4: never mark the phaseCompletedaround a blocker). - Missing or invalid
Delegated to agent: stop before any delegation and report the sub-task; the plan must be fixed rather than executed under a guessed owner. - Review produces blocking findings: Stop the execution loop. Recommend fixing the findings (using the
address-reviewpattern) and re-runningdh-execute-plan. - Final review fails: Report the verdict — do not mark the plan complete until findings are addressed.
Loop Integration (bundled)
This copy is bundled in the plugin; the loop below is the harness runtime contract (full text in repo-root AGENTS.md). Plan execution follows it in order — do not skip steps and never silently continue past a blocker:
dh-planning(usedh-domain-checkwhile planning)dh-execute-plan2.1dh-execute-plan-task(delegate code implementation through thedh-codingskill) 2.2dh-simplify2.3dh-review+dh-code-review2.4 IF hard blockers → stop and ask guidance; otherwise keep thedh-execute-plan-taskloopdh-preflight+dh-artifact-checkdh-final-reviewdh-create-documentation(also writes the evolution and observation notes)
Step 2.4 halts automation. When dh-execute-plan-task (or any loop step)
hits a hard blocker — repeated validation failures (3 consecutive strikes),
unresolved P0/P1 review findings, or missing preconditions that cannot be
worked around — the loop STOPS: report the blocker and ask the user for
guidance. Never silently continue, never skip the blocked step, and never mark
sub-tasks Complete around a blocker. The rule applies at phase boundaries
too: a blocked sub-task blocks its phase — do not mark the phase Completed
around a blocker. Before stopping for a hard blocker or ending the session,
run dh-pause-plan to preserve the phase/sub-task, git state, decisions,
blockers, and next steps in handoff.md; resume later with dh-resume-plan.
References
- Fast variant:
dh-execute-plan-fastexecutes fromplan_fast.mdwith no per-task gates and defers critical verification to plan end;plan.mdstays the scope truth. ../dh-planning/references/agent-selection.md: discovery, ranking, recording, and re-validation protocol for every delegated role.dh-execute-plan-taskskill: executes a single sub-task.dh-reviewskill: verifies a single sub-task result.dh-final-reviewskill: produces plan-level sign-off.dh-create-documentationskill: updates docs and writes the evolution/observation notes after plan completion (all projects).
Doc search
Documentation management: delegate create / update / delete / retrieve of generated documents (excluding docs/plans) to the best available documentation agent (bundled documentation capability as fallback) — the main and only documentation owner (see dh-create-documentation).
Search generated documentation quickly: notesmd-cli search-content "<term>" --vault "<project-name>" or obsidian search query="<term>" (fallback: rg --glob '*.md' "<term>" docs/).
04 同仓库更多 Skills
dh-simplify
Review changed code for reuse, quality, and efficiency (three parallel reviews), then fix findings directly. Use after making changes or when asked to clean up, refactor, simplify, or improve this code.
dh-setup
Audit system software, configure user MCPs/plugins, scaffold project QA (hooks + per-stack tools), bootstrap docs/architecture with the selected architecture agent, and write harness directives into AGENTS.md. Use to check requirements or setup the environment.
dh-semver
Apply strict Semantic Versioning — analyze commits since the last tag to determine the bump type (major/minor/patch from conventional commit prefixes), generate an automated changelog grouped by breaking changes, features, fixes, and chores, and create a git tag locally without pushing until confirmed, handling both conventional commits and manual version decisions. Use when preparing a release, invoked by dh-execute-plan after plan completion and dh-final-review for release readiness, or when the user asks "what version is next?", "bump version", "generate changelog", "tag release", or "what changed since last release?".
dh-review
Verify a plan sub-task against acceptance criteria, scope, done-when; review diff, validation, regression risk; structured verdict to tasks/review.md. Plan Alignment Mode (fast execution) is a separate mode: no sub-task selection, no diff review, no code review — it compares plan.md with plan_fast.md and writes tasks/review-fast.md (pre-execution) or tasks/review-fast-final.md (plan-end). Use after implementation, to review/verify the sub-task, or to check fast-plan alignment.
dh-resume-plan
Resume a paused phased plan from docs/plans/<slug>/handoff.md: validate the contract, detect drift, rehydrate context, mark the handoff resumed, and continue via dh-execute-plan resume mode. Use when the user says "resume the plan", "continue where we stopped", "pick up the plan", or "resume after a pause".
dh-preflight
Run tests, linters, static analysis as a release gate: auto-detect tooling, check dirty state, pass/fail verdict with actionable failures (no auto-fixes). Use to run preflight, pre-release check, or validate before release.