Execute the multi-agent implementation planning workflow with specialized agents and validation loops
Executes a two-agent planning workflow that transforms specifications into technical implementation plans.
/plugin marketplace add deepeshBodh/human-in-loop/plugin install deepeshbodh-humaninloop-plugins-humaninloop@deepeshBodh/human-in-loopYou are the Supervisor orchestrating a two-agent planning workflow. You own the loop, manage state via files, and route based on agent outputs.
$ARGUMENTS
If $ARGUMENTS is empty or appears literally, check for resume state first, then proceed with the detected feature.
If $ARGUMENTS is empty (blank string with no content), use AskUserQuestion to handle a known Claude Code bug where inputs containing @ file references don't reach plugin commands:
AskUserQuestion(
questions: [{
question: "⚠️ Known Issue: Input may have been lost\n\nClaude Code has a bug where inputs containing @ file references don't reach plugin commands.\n\nWould you like to re-enter your input?",
header: "Input",
options: [
{label: "Re-enter input", description: "I'll type my input in the terminal"},
{label: "Continue without input", description: "Proceed with no input provided"}
],
multiSelect: false
}]
)
$ARGUMENTSSUPERVISOR (this command)
│
├── Creates context + directories
├── Invokes agents with minimal prompts
├── Parses structured prose outputs
├── Updates context between phases
└── Owns all routing decisions
AGENTS (independent, no workflow knowledge)
│
├── Plan Architect → Writes research.md, data-model.md, contracts/
└── Devil's Advocate → Reviews artifacts, finds gaps
Communication Pattern: Context + Artifacts + Separate Reports
specs/{feature-id}/
├── spec.md # Input (from specify workflow)
├── research.md # Phase 1 output
├── data-model.md # Phase 2 output
├── contracts/ # Phase 3 output
│ └── api.yaml
├── quickstart.md # Phase 3 output
├── plan.md # Summary (completion)
└── .workflow/
├── context.md # Context + instructions (specify)
├── plan-context.md # Context + instructions (plan)
├── planner-report.md # Plan Architect output
└── advocate-report.md # Devil's Advocate output
| Agent | File | Purpose |
|---|---|---|
| Plan Architect | ${CLAUDE_PLUGIN_ROOT}/agents/plan-architect.md | Transform spec into planning artifacts |
| Devil's Advocate | ${CLAUDE_PLUGIN_ROOT}/agents/devils-advocate.md | Review artifacts, find gaps, generate clarifications |
Before starting, verify the specification workflow is complete:
Identify the feature directory:
$ARGUMENTS specifies a feature ID: use that001-user-auth)specs/ by highest numeric prefixCheck for spec.md: Read specs/{feature-id}/spec.md
/humaninloop:specify firstCheck specify workflow status: Read specs/{feature-id}/.workflow/context.md
status != completed:
AskUserQuestion(
questions: [{
question: "Specification workflow not complete (status: {status}). Planning requires a completed spec.",
header: "Entry Gate",
options: [
{label: "Complete specification first", description: "Return to /humaninloop:specify"},
{label: "Abort", description: "Cancel planning workflow"}
],
multiSelect: false
}]
)
If entry gate passes: Continue to Resume Detection
Before starting, check for interrupted planning workflows:
Check for existing plan-context.md:
test -f specs/{feature-id}/.workflow/plan-context.md
If found: Read frontmatter, check status and phase fields
If status is not completed:
AskUserQuestion(
questions: [{
question: "Found interrupted planning workflow for '{feature_id}' (phase: {phase}, status: {status}). Resume or start fresh?",
header: "Resume?",
options: [
{label: "Resume", description: "Continue from {phase} phase"},
{label: "Start fresh", description: "Delete plan artifacts and restart"}
],
multiSelect: false
}]
)
If resume: Read context, jump to appropriate phase based on status
If fresh: Delete plan artifacts (research.md, data-model.md, contracts/) and proceed
Use the template at ${CLAUDE_PLUGIN_ROOT}/templates/plan-context-template.md.
Write to specs/{feature-id}/.workflow/plan-context.md with these values:
| Placeholder | Value |
|---|---|
{{phase}} | research |
{{status}} | awaiting-planner |
{{iteration}} | 1 |
{{feature_id}} | Feature ID |
{{created}} | ISO date |
{{updated}} | ISO date |
{{spec_status}} | present |
{{constitution_path}} | Path to constitution |
{{constitution_principles}} | Extracted key principles |
{{spec_path}} | specs/{feature-id}/spec.md |
{{research_path}} | specs/{feature-id}/research.md |
{{research_status}} | pending |
{{datamodel_path}} | specs/{feature-id}/data-model.md |
{{datamodel_status}} | pending |
{{contracts_path}} | specs/{feature-id}/contracts/ |
{{contracts_status}} | pending |
{{planner_report_path}} | specs/{feature-id}/.workflow/planner-report.md |
{{advocate_report_path}} | specs/{feature-id}/.workflow/advocate-report.md |
{{codebase_context}} | Empty (filled by planner if brownfield) |
{{supervisor_instructions}} | See Phase 2 for initial instructions |
{{clarification_log}} | Empty on first iteration |
Update {{supervisor_instructions}} in plan-context.md:
**Phase**: Research
Create technical research document resolving all unknowns from the specification.
**Read**:
- Spec: `specs/{feature-id}/spec.md`
- Constitution: `.humaninloop/memory/constitution.md`
**Write**:
- Research: `specs/{feature-id}/research.md`
- Report: `specs/{feature-id}/.workflow/planner-report.md`
**Use Skills**:
- `analysis-codebase` (if brownfield)
- `patterns-technical-decisions`
**Report format**: Follow `${CLAUDE_PLUGIN_ROOT}/templates/planner-report-template.md`
Update plan-context.md frontmatter:
phase: research
status: awaiting-planner
updated: {ISO date}
Task(
subagent_type: "humaninloop:plan-architect",
prompt: "Read your instructions from: specs/{feature-id}/.workflow/plan-context.md",
description: "Create research document"
)
Confirm the agent created:
specs/{feature-id}/research.mdspecs/{feature-id}/.workflow/planner-report.mdIf missing, report error and stop.
Update context for advocate:
**Phase**: Research Review
Review the research document for gaps and quality.
**Read**:
- Spec: `specs/{feature-id}/spec.md`
- Research: `specs/{feature-id}/research.md`
- Planner report: `specs/{feature-id}/.workflow/planner-report.md`
**Write**:
- Report: `specs/{feature-id}/.workflow/advocate-report.md`
**Use Skills**:
- `validation-plan-artifacts` (phase: research)
**Report format**: Follow `${CLAUDE_PLUGIN_ROOT}/templates/advocate-report-template.md`
Update status:
status: awaiting-advocate
Invoke advocate:
Task(
subagent_type: "humaninloop:devils-advocate",
prompt: "Read your instructions from: specs/{feature-id}/.workflow/plan-context.md",
description: "Review research document"
)
Read advocate report and extract verdict.
If verdict is ready:
{{research_status}} to completeIf verdict is needs-revision or critical-gaps:
Update {{supervisor_instructions}} in plan-context.md:
**Phase**: Data Model
Create data model document extracting entities, relationships, and validation rules.
**Read**:
- Spec: `specs/{feature-id}/spec.md`
- Research: `specs/{feature-id}/research.md`
- Constitution: `.humaninloop/memory/constitution.md`
**Write**:
- Data Model: `specs/{feature-id}/data-model.md`
- Report: `specs/{feature-id}/.workflow/planner-report.md`
**Use Skills**:
- `analysis-codebase` (if brownfield, for existing entities)
- `patterns-entity-modeling`
**Report format**: Follow `${CLAUDE_PLUGIN_ROOT}/templates/planner-report-template.md`
phase: datamodel
status: awaiting-planner
iteration: 1
updated: {ISO date}
Task(
subagent_type: "humaninloop:plan-architect",
prompt: "Read your instructions from: specs/{feature-id}/.workflow/plan-context.md",
description: "Create data model"
)
Confirm: specs/{feature-id}/data-model.md
Update context for advocate:
**Phase**: Data Model Review
Review the data model for completeness and consistency with spec + research.
**Read**:
- Spec: `specs/{feature-id}/spec.md`
- Research: `specs/{feature-id}/research.md`
- Data Model: `specs/{feature-id}/data-model.md`
- Planner report: `specs/{feature-id}/.workflow/planner-report.md`
**Write**:
- Report: `specs/{feature-id}/.workflow/advocate-report.md`
**Use Skills**:
- `validation-plan-artifacts` (phase: datamodel)
**Check**:
- Entity coverage (all nouns from requirements)
- Relationship completeness
- Consistency with research decisions
Invoke advocate and route based on verdict (same as Phase 2).
If ready: Proceed to Phase 4 (Contracts)
Update {{supervisor_instructions}} in plan-context.md:
**Phase**: Contracts
Create API contracts and integration guide.
**Read**:
- Spec: `specs/{feature-id}/spec.md`
- Research: `specs/{feature-id}/research.md`
- Data Model: `specs/{feature-id}/data-model.md`
- Constitution: `.humaninloop/memory/constitution.md`
**Write**:
- Contracts: `specs/{feature-id}/contracts/api.yaml`
- Quickstart: `specs/{feature-id}/quickstart.md`
- Report: `specs/{feature-id}/.workflow/planner-report.md`
**Use Skills**:
- `analysis-codebase` (if brownfield, for existing API patterns)
- `patterns-api-contracts`
**Report format**: Follow `${CLAUDE_PLUGIN_ROOT}/templates/planner-report-template.md`
phase: contracts
status: awaiting-planner
iteration: 1
updated: {ISO date}
Task(
subagent_type: "humaninloop:plan-architect",
prompt: "Read your instructions from: specs/{feature-id}/.workflow/plan-context.md",
description: "Create API contracts"
)
Confirm:
specs/{feature-id}/contracts/api.yamlspecs/{feature-id}/quickstart.mdUpdate context for advocate:
**Phase**: Contracts Review
Review API contracts for completeness and consistency with all previous artifacts.
**Read**:
- Spec: `specs/{feature-id}/spec.md`
- Research: `specs/{feature-id}/research.md`
- Data Model: `specs/{feature-id}/data-model.md`
- Contracts: `specs/{feature-id}/contracts/api.yaml`
- Quickstart: `specs/{feature-id}/quickstart.md`
- Planner report: `specs/{feature-id}/.workflow/planner-report.md`
**Write**:
- Report: `specs/{feature-id}/.workflow/advocate-report.md`
**Use Skills**:
- `validation-plan-artifacts` (phase: contracts)
**Check**:
- Endpoint coverage (all user actions mapped)
- Schema consistency with data model
- Error handling completeness
- Cross-artifact consistency
Invoke advocate and route based on verdict.
If ready: Proceed to Phase 5 (Completion)
When advocate verdict is needs-revision or critical-gaps:
Present clarifications to user using AskUserQuestion:
AskUserQuestion(
questions: clarifications.map(c => ({
question: c.question,
header: c.gap_id,
options: c.options || [
{label: "Yes", description: ""},
{label: "No", description: ""},
{label: "Not sure", description: "Needs more discussion"}
],
multiSelect: false
}))
)
Update context with user answers:
Append to ## Clarification Log:
### Phase: {phase} - Iteration {N}
#### Gaps Identified
{List from advocate report}
#### User Answers
| Gap ID | Question | Answer |
|--------|----------|--------|
| G1 | {question} | {user's answer} |
Update supervisor instructions for revision:
**Phase**: {phase} (Revision)
Revise the {artifact} based on user feedback.
**Read**:
- Current artifact: `specs/{feature-id}/{artifact}`
- Gaps and user answers: See `## Clarification Log` below
- Previous artifacts for context
**Write**:
- Updated artifact: `specs/{feature-id}/{artifact}`
- Report: `specs/{feature-id}/.workflow/planner-report.md`
Increment iteration in context frontmatter
Loop back to Planner invocation
Use your judgment to recommend exiting if:
Always give the user the choice—never force-terminate without consent:
AskUserQuestion(
questions: [{
question: "We've been iterating on the {phase} phase. {Context}. How should we proceed?",
header: "Next Step",
options: [
{label: "Continue refining", description: "Another round of revision"},
{label: "Accept current state", description: "Proceed to next phase with known gaps"},
{label: "Stop and review manually", description: "Exit workflow, review artifacts yourself"}
],
multiSelect: false
}]
)
Write specs/{feature-id}/plan.md:
# Implementation Plan: {feature_id}
> Summary document for the planning workflow.
---
## Overview
{2-3 sentence summary extracted from spec.md}
---
## Key Decisions
| Decision | Choice | See |
|----------|--------|-----|
{For each decision in research.md}
---
## Entities
| Entity | Status | Attributes | Relationships |
|--------|--------|------------|---------------|
{For each entity in data-model.md}
---
## Endpoints
| Endpoint | Method | Description |
|----------|--------|-------------|
{For each endpoint in contracts/api.yaml}
---
## Artifacts
| Artifact | Path | Status |
|----------|------|--------|
| Specification | specs/{feature-id}/spec.md | ✓ Complete |
| Research | specs/{feature-id}/research.md | ✓ Complete |
| Data Model | specs/{feature-id}/data-model.md | ✓ Complete |
| API Contracts | specs/{feature-id}/contracts/api.yaml | ✓ Complete |
| Quickstart | specs/{feature-id}/quickstart.md | ✓ Complete |
---
## Next Steps
Run `/humaninloop:tasks` to generate implementation tasks from this plan.
Update plan-context.md frontmatter:
phase: completed
status: completed
updated: {ISO date}
Update artifact statuses:
research_status: complete
datamodel_status: complete
contracts_status: complete
Output to user:
## Planning Complete
**Feature**: {feature_id}
### Summary
- Decisions documented: {count from research.md}
- Entities modeled: {count from data-model.md}
- Endpoints designed: {count from contracts/}
### Artifacts Generated
- `specs/{feature-id}/plan.md` - Summary document
- `specs/{feature-id}/research.md` - Technical decisions
- `specs/{feature-id}/data-model.md` - Entity definitions
- `specs/{feature-id}/contracts/api.yaml` - OpenAPI specification
- `specs/{feature-id}/quickstart.md` - Integration guide
### Known Limitations
{Any minor gaps deferred, if applicable}
### Next Steps
1. Review the plan at `specs/{feature-id}/plan.md`
2. Run `/humaninloop:tasks` to generate implementation tasks
**Agent Failed**
Error: {error_message}
Agent: {agent_name}
Phase: {phase}
The workflow state has been saved. Run `/humaninloop:plan` to resume from {phase} phase.
If expected output files are missing after agent invocation:
Resume logic based on phase and status fields:
| Phase | Status | Resume Point |
|---|---|---|
research | awaiting-planner | Phase 2.3 (invoke planner) |
research | awaiting-advocate | Phase 2.5 (invoke advocate) |
research | awaiting-user | Clarification loop |
datamodel | awaiting-planner | Phase 3.3 (invoke planner) |
datamodel | awaiting-advocate | Phase 3.5 (invoke advocate) |
datamodel | awaiting-user | Clarification loop |
contracts | awaiting-planner | Phase 4.3 (invoke planner) |
contracts | awaiting-advocate | Phase 4.5 (invoke advocate) |
contracts | awaiting-user | Clarification loop |
completed | completed | Report already done |