subagents-orchestration-guide
GitHub指导多智能体协调的编排指南,涵盖工作流决策、路由、进度管理及自主执行模式确定。通过规范子代理上下文和委托边界,确保高效协同与结果收敛。
Trigger Scenarios
Install
npx skills add shinpr/claude-code-workflows --skill subagents-orchestration-guide -g -y
SKILL.md
Frontmatter
{
"name": "subagents-orchestration-guide",
"description": "Guides subagent coordination through implementation workflows. Use when orchestrating multiple agents, managing workflow phases, or determining autonomous execution mode."
}
Subagents Orchestration Guide
Role: The Orchestrator
The orchestrator owns workflow decisions, routing, progress management, user interaction, the investigation and validation needed for those decisions, and explicitly assigned mechanical operations, using any available tool. Named specialists own explicitly assigned investigation and semantic deliverable creation or modification; invoke them before producing or changing code, tests, configuration, documents, task files, or other artifacts.
Workflow Subagent Context — Mandatory
This workflow's specialists are already self-contained through their agent definitions, loaded skills, and referenced artifacts. The smallest valid Agent prompt is the most reliable: reduce each handoff to exactly the exhaustive input-contract fields. Preserve each value's meaning from its authoritative source and apply only the serialization declared for that field. This rule supersedes general-purpose prompt self-containment because added context competes with the specialist's loaded process and can prevent coherent completion.
First Action Rule
When receiving a new full-cycle task, pass user requirements directly to requirement-analyzer. Use its request signals, scope evidence, cost evidence, and questions to judge requirement convergence and Structural Scale in the orchestrator. Dedicated design recipes use their own codebase-scoped bootstrap.
Build and judge the convergence record in the orchestrator with the requirement-convergence skill. Run its hearing protocol at the requirements stop point. Re-invoke requirement-analyzer only when an answer changes the repository analysis target or scope evidence; otherwise update the convergence and Structural Scale judgment directly. ADR qualification occurs only after codebase-analyzer returns credible technical options and the scope is confirmed.
Requirement Change Detection During Flow
Treat new or changed behaviors, constraints, or technical requirements as requirement changes. Re-run requirement-analyzer with the initial and additional requirements as complete labeled statements, identify which approved artifacts or task boundaries the change invalidates, and resume from the earliest invalidated gate while preserving outputs that remain valid.
Orchestration Principles
Outcome Stewardship
The orchestrator steers the workflow toward the smallest sufficient set of deliverables and changes that achieves the confirmed outcome while satisfying binding constraints and required verification. Evaluate specialist proposals against that boundary before routing work.
Preserve specialist evidence ownership and approved artifacts as semantic sources so the workflow converges on the confirmed MVP; orchestrator-authored investigation targets, restatements, or follow-on instructions bias evidence and create unreviewed scope.
Delegation Boundary: What vs How
Pass the governing requirement source and the specialist's expected action. Investigation specialists discover affected paths and responsibility boundaries; artifact and execution specialists receive the confirmed paths or scope they must act on. Each specialist determines its execution method from repository evidence and applicable artifacts.
Decision precedence for routing:
- User instructions (explicit requests or constraints)
- Task files and design artifacts (Design Doc, PRD, work plan)
- Objective repo state (git status, file system, project configuration)
- Specialist judgment
Before routing specialist output, validate each claim that controls the next workflow decision against the highest applicable source above. Route according to that source; specialist judgment governs decisions left unresolved by items 1-3.
When a specialist cannot determine execution method from repo state and artifacts, the specialist escalates as blocked instead of guessing. The orchestrator then escalates to the user with the specialist's blocked details.
Review Resolution
Apply references/review-resolution.md to actionable deliverable-review findings. The orchestrator decides dispositions, validates results, and routes work; the named specialist produces or changes deliverables.
Task Assignment with Responsibility Separation
| Specialist | Responsibility |
|---|---|
| task-executor | Implement scoped work and tests, and confirm added tests pass; leave whole-repository quality assurance to the quality-fixer. |
| quality-fixer | Run overall checks, fix quality failures, and return approved only after completing those fixes. |
For frontend work, substitute task-executor-frontend and quality-fixer-frontend; in fullstack work, select them by task layer.
Constraints Between Subagents
Important: Subagents cannot directly call other subagents—all coordination flows through the orchestrator.
Explicit Stop Points
Autonomous execution MUST stop and wait for user input at these points. Use AskUserQuestion to present confirmations and questions.
Before presenting an artifact at an approval stop, read its current version and base the presentation on that content.
| Phase | Stop Point | User Action Required |
|---|---|---|
| Requirements | After requirement-analyzer completes | Answer the requirement-convergence hearing, then confirm requirements |
| PRD | After document-reviewer completes PRD review | Approve PRD |
| UI Spec | After document-reviewer completes an applicable UI Spec review | Approve UI Spec |
| ADR batch | After document-reviewer reviews the complete qualifying batch | Approve all ADR decisions together |
| Design | After design-sync completes consistency verification | Approve Design Doc |
| Work Plan | After work plan review (document-reviewer, doc_type WorkPlan; Medium/Large) completes | Batch approval for implementation phase |
After applicable implementation authorization: Confirmed Small requirements or Medium/Large batch approval start autonomous execution, which continues until completion or an escalation condition is reached.
Scale Determination and Document Requirements
| Scale | Structural condition | PRD | ADR batch | Design Doc | Work Plan |
|---|---|---|---|---|---|
| Small | One outcome has one evident repository-supported implementation inside one responsibility and no unresolved durable choice | Update when applicable | None | None | None |
| Medium | One outcome coordinates across a boundary or requires investigation of a potentially durable choice | Update when applicable | When one or more decision points pass both filters | Required | Required |
| Large | Independently valuable outcomes require separate design decisions | Required | When one or more decision points pass both filters | Required | Required |
File count supports the judgment but does not determine it. A qualifying durable decision sets the floor at Medium. Apply the Choice filter before the Durability filter after repository option evidence exists.
How to Call Subagents
Execution Method
Each subagent invocation is a fresh Agent tool call, isolating each phase's context; a SendMessage resume reuses the prior agent's context and breaks that isolation. Each call uses:
subagent_type: Agent name (e.g., "task-executor")description: Concise task description (3-5 words)prompt: Values serialized in the active workflow's input contract
Orchestrator Execution Boundary
Tool choice does not define responsibility: the orchestrator may use any available tool for its owned work, while named specialists perform semantic deliverable creation or modification; the orchestrator writes only for mechanical operations explicitly assigned by the active workflow.
Prompt Construction Rule
The active workflow's input contract is already optimized to provide the specialist with the context for its owned result. The orchestrator preserves that optimization by passing its named fields in their declared forms; the prompt consists of those fields and values, while artifact paths and unchanged specialist outputs carry their own semantics.
Handling Requirement Changes
Use create mode for initial documents. For requirement-driven revisions, invoke the owning document specialist in update mode and add history:
- work-planner: update only before execution
- technical-designer / prd-creator: update affected documents, then invoke document-reviewer
- document-reviewer: run before user approval after PRD/ADR/Design Doc changes and after Work Plan changes; Small changes have no Work Plan
Basic Flow: Planning and Implementation
Planning flow (per scale)
| Scale | Planning flow |
|---|---|
| Large | requirement-analyzer → PRD → PRD review → codebase-analyzer → conditional external/UI analysis and UI Spec → optional ADR batch/review/approval → Design Doc → code-verifier/Review Resolution → document-reviewer → design-sync → acceptance-test-generator → work-planner → work plan review → task-decomposer |
| Medium | requirement-analyzer → codebase-analyzer → conditional external/UI analysis and UI Spec → optional ADR batch/review/approval → Design Doc → code-verifier/Review Resolution → document-reviewer → design-sync → acceptance-test-generator → work-planner → work plan review → task-decomposer |
| Small | requirement-analyzer → direct task execution (no Work Plan) |
The requirement-convergence and external-resource hearings run in the orchestrator. In an implementation workflow, confirmation at the Requirements stop authorizes the confirmed Small direct scope. Medium/Large implementation begins after Work Plan batch approval.
Rules:
- When documentation-criteria requires a UI Spec, complete it before ADR qualification and Design Doc creation
- An ADR batch is optional; the Design Doc is mandatory for Medium/Large work even when ADRs exist
- After requirement confirmation for Medium/Large, invoke codebase-analyzer once with exactly one governing source: approved
prd_path, or confirmedrequirementswhen no approved PRD exists - When a UI Spec applies, invoke ui-analyzer with that same governing-source choice plus existing
ui_spec_path, decision-relevantprototype_path, and selectedexternal_resource_refsor[]; invoke ui-spec-designer withconfirmed_requirement_contextas the approved PRD path exactly or, only when none exists, the unchanged confirmed convergence record, plus the complete unchangedui_analysis, applicable unchangedcodebase_analysis, optionalprototype_path, andexternal_resource_refsor[] - Before ADR qualification, use the governing source plus
reuseandinvalidationsto remove questions that already have one sufficient approach. Apply documentation-criteria Choice then Durability filters only to the remainingcandidateDecisionPoints. When non-empty, invoke each owning technical-designer withdocument_to_create: ADRBatch,confirmed_requirement_contextas the approved PRD path exactly or, only when none exists, the unchanged confirmed convergence record, ordered confirmeddecision_pointsunchanged, and the correspondingcandidateDecisionPointsobjects unchanged asdecision_materials; add an approvedui_spec_pathonly when it constrains a frontend decision. Run owner batches serially, review all returned paths once withdoc_type: ADRBatch, and obtain one user approval. After approval, set every approved ADR toAcceptedand verify the status updates. For corrections, group findings by ADR path and invoke update mode once per path before re-reviewing the complete batch. An empty result proceeds directly to the Design Doc - Invoke the Design Doc owner with
document_to_create: DesignDoc,confirmed_requirement_contextas the approved PRD path exactly or, only when none exists, the unchanged confirmed convergence record,structural_scale, unchangedcodebase_analysis, optional unchangedui_analysis, and acceptedadr_paths; frontend/fullstack invocations add only their named UI or layer artifact paths - Resolve code-verifier discrepancies through Review Resolution before invoking document-reviewer; pass the exact HC-04 inputs rather than a narrative evidence bundle
- Fullstack layer sequencing is defined only in
references/monorepo-flow.md design-syncis required whenever multiple Design Docs existtask-decomposerbegins only after work plan review (document-reviewer, doc_type WorkPlan; Medium/Large) and batch approval- Work plan review runs Review Resolution through its correction re-review, escalation, and convergence transitions; batch approval is available only at its convergence condition
Autonomous Execution Mode
Pre-Execution Gate
Verify commit capability before autonomous mode. Let task-executor and quality-fixer detect and escalate unavailable test or quality tooling; escalate a known critical missing prerequisite before entry.
Confirmed Small requirements or Medium/Large batch approval authorize task-executor implementation and quality-fixer corrections until completion or escalation.
Autonomous Execution Summary
For Medium/Large, after "batch approval for entire implementation phase" with work-planner, autonomously execute the following processes through completion or an escalation condition:
graph TD
START[Batch approval] --> TD[task-decomposer]
TD --> CYCLE[Per-task 4-step cycle, including commit]
CYCLE -->|remaining tasks| CYCLE
CYCLE -->|all tasks complete| VERIFY[code-verifier + security-reviewer]
CYCLE -->|blocked, escalation, or requirement change| USER[Escalate or re-analyze]
VERIFY -->|passed| REPORT[Completion report]
VERIFY -->|actionable findings| RR[Review Resolution]
RR -->|apply| FIX[task-executor + quality-fixer]
FIX --> VERIFY
RR -->|all decline| REPORT
RR -->|user decision required| USER
For Small, execute one direct-scope 4-step cycle and complete when quality-fixer is approved and the direct scope's observable verification condition is satisfied. Small has no task decomposition, document-dependent post-implementation verification, or task-file cleanup.
Post-Implementation Verification Pass/Fail Criteria (Medium/Large)
| Verifier | Pass | Fail | Blocked |
|---|---|---|---|
| code-verifier | summary.status is consistent or mostly_consistent |
summary.status is needs_review or inconsistent |
summary.status is blocked → Escalate to user |
| security-reviewer | status is approved or approved_with_notes |
status is needs_revision |
status is blocked → Escalate to user |
Fix-cycle handoff: Apply Review Resolution, then pass each required executor the complete apply finding objects verbatim with only their dispositions added. Carry prior_feedback to reviewer inputs that support reconciliation.
Re-run rule: After any post-implementation verification fix cycle, re-run both code-verifier and security-reviewer before accepting the result.
Conditions for Stopping Autonomous Execution
| Trigger | Action |
|---|---|
A subagent returns escalation_needed or blocked |
Escalate its concrete details to the user. |
Review Resolution returns user_decision_required |
Stop at the current gate and request that decision. |
| A requirement changes | Apply Requirement Change Detection above. After task-decomposer starts, invalidate affected tasks; restart document design only when re-analysis changes an approved requirement, contract, data flow, verification strategy, or task boundary. |
| The user stops or interrupts | Stop autonomous execution. |
Task Management: 4-Step Cycle
Per-task cycle:
- Execute: record the current HEAD as
diffBase, then invoke task-executor with the task file path when one exists; for Small, invoke it withdirect_scopeas the confirmed outcome and exclusions,governing_sources,target_paths, andobservable_verification - Branch on executor result:
status: escalation_neededorblocked→ Escalate to userrequiresTestReviewistrue→ Identify the changed integration/E2E test files in the current changes and invoke integration-test-reviewer with them aschangedTestFiles, plusdiffBase, optionaltaskFile, prompt-only claims, andmutationEvidenceapproved→ Proceed to step 3blocked→ Escalate to userneeds_revision→ PassqualityIssuesobjects unchanged into Review Resolution. On correction re-review, derive the next transition only fromprior_feedback_reconciliation; return to step 1 for rerouted corrections and proceed to step 3 only at convergence
- Otherwise → Proceed to step 3
- Quality-fix: invoke quality-fixer with upstream
mutationEvidence, plustask_filewhen available andqualityCommandfrom the caller first or task otherwisestub_detected→ Return to step 1 withincompleteImplementations[]detailsblocked→ Escalate to userapproved→ Proceed to step 4
- Commit: after quality-fixer returns
approved, compose the message fromchangeSummaryand execute git commit with Bash
Register overall phases using TaskCreate and update each phase with TaskUpdate as it completes.
Handoff Contracts
HC-01: requirement-analyzer → orchestrator and codebase-analyzer
- The orchestrator uses
requestSignals,scopeEvidence,costEvidence, andquestionsto judge convergence and Structural Scale. - Pass only approved
prd_path; when no approved PRD exists, pass only confirmedrequirements. The orchestrator-owned convergence and Scale decisions remain in the orchestration state. - Keeping the analyzer input independent of orchestrator-selected paths and technical questions preserves the objective repository evidence required for scope and option convergence.
HC-01b: convergence record → document owner
- Pass the orchestrator-judged
convergencerecord to whichever agent owns the persisting document. - prd-creator (when a PRD is created or updated): persists
outcometoSuccess Criteria, andnonGoalsplusspeculativerequirements toFuture / Out of Scopewith originuser - technical-designer / technical-designer-frontend: persists the same to the Design Doc's
Requirement Convergencewhen no PRD exists, and always records the fields leftweak-but-explicitthere - Pass the record unchanged; a field's readiness label travels with it
HC-02: codebase-analyzer → technical-designer
- For an ADR batch, pass the confirmed
decision_pointsunchanged and copy their correspondingdecisionMaterials.candidateDecisionPointsobjects unchanged asdecision_materials. - For a Design Doc, pass the codebase-analyzer JSON unchanged as
codebase_analysis; accepted artifact paths and unchanged evidence keep the Design Doc traceable to reviewed sources rather than an orchestrator-authored shadow interpretation. Use these fields as follows: - Required downstream uses:
focusAreas→ canonical disposition-target list for the Fact Disposition TabledecisionMaterials.reuseandinvalidations→ reduce implementation surface and eliminate invalid approachesdecisionMaterials.candidateDecisionPoints→ orchestrator first resolves them against the governing source,reuse, andinvalidations, then applies ADR Choice and Durability filtersdecisionMaterials.verification→ required proof boundariesdataModel,dataTransformationPipelines,qualityAssurance→ Existing Codebase Analysis / Verification Strategy / Quality Assurance sections
HC-03: technical-designer → code-verifier
- Pass the Design Doc path with
doc_type: design-doc. - Leave
code_pathsunspecified so code-verifier discovers scope from the document and treats planned future behavior as intent.
HC-04: code-verifier + codebase-analyzer → document-reviewer
- Keep verifier discrepancies unchanged so correction and review remain traceable to observed evidence rather than orchestrator-authored design instructions.
- Apply Review Resolution and rerun verification after every applied correction. Form the single
verification_evidenceobject defined by the Review Resolution reference. - Pass these exact keys:
review_context: creation,verification_evidence, the samecodebase_analysisJSON previously given to the designer, optionalui_analysis, original user requirements asrequirements_verbatim, and the sameconfirmed_requirement_contextsupplied at the owning designer invocation. - Transition after every remaining verifier item has a resolved disposition. The reviewer validates the resulting design, Fact Disposition coverage, and effective requirements; the orchestrator retains verifier-disposition ownership.
HC-05: code-verifier → next-layer technical-designer (fullstack only)
- Defined only for multi-layer fullstack flow in
references/monorepo-flow.md - Pass: prior-layer Design Doc path plus
prior_layer_verification - Treat
discrepancies[]as the known issues to address or escalate. Keep every claim absent from the verifier output classified as unverified.
technical-designer → work-planner
Pass the Design Doc path. Work-planner maps governing sections and ACs to implementation tasks. An uncovered selected obligation is a planning omission to correct; the Work Plan does not turn missing coverage or missing design content into a user-confirmation item.
HC-06: acceptance-test-generator → work-planner
- Pass the Design Doc and optional UI Spec paths to acceptance-test-generator.
- Verify each non-null
generatedFiles.<lane>path exists and each null lane hase2eAbsenceReason.<lane>. - Pass paths or nulls and absence reasons to work-planner; work-planner owns lane timing.
- Escalate unexpected integration generation failure; a null E2E lane with a valid reason is not an error.
References
references/monorepo-flow.md: Fullstack (monorepo) orchestration flowreferences/review-resolution.md: Finding adjudication and correction-loop contract
Version History
-
0d96a63
Current 2026-08-05 22:03
新增工作流子代理上下文规范与结果 stewardship 原则;重构以从证据收敛设计决策并修复工作流契约缺口。
-
51b7dbc
2026-08-05 01:44
重构规划与收敛审查逻辑;修复并强化以结果为核心的编排原则;简化编排指引;新增基于证据的审查解决机制。
-
29b9210
2026-08-03 04:20
重构需求听证协议为有序步骤以记录证据;优化子代理任务注册、收敛JSON格式及触发条件;调整非目标处理与PRD成功标准记录方式。
-
d439b50
2026-07-31 02:51
重构了编排原则,从列出可用子智能体转变为定义委托边界(What vs How)和冲突决策优先级。明确了Orchestrator仅传递目标和约束,由专家自主决定执行细节,并规定了基于仓库状态和文档的冲突解决逻辑。
-
56ab6c1
2026-07-19 22:42
优化提示词执行指导,细化了需求变更时的恢复逻辑:明确需识别被无效化的工件或边界,并保留有效输出,而非简单重启。
- 66e3b29 2026-07-05 11:58


