Orchestrates multi-agent workflow to plan, scaffold, implement, validate, and commit a production-ready PolicyEngine dashboard from a natural-language description.
From essentialnpx claudepluginhub policyengine/policyengine-claude --plugin data-scienceCoordinate a multi-agent workflow to plan, scaffold, implement, validate, and commit a production-ready PolicyEngine dashboard application.
$ARGUMENTS should contain:
--repo NAME_OR_PATH — use an existing repo (searches sibling of cwd, ~/Documents/PolicyEngine/, ~/PolicyEngine/, ~/)--skip-init — use current working directory as the repo (no repo creation or cloning)--skip-validate — skip the Phase 5 validation loopExamples:
/create-dashboard A dashboard showing child poverty rates by state under different CTC reform scenarios
/create-dashboard --repo child-poverty-dashboard "Add a comparison mode showing baseline vs reform"
/create-dashboard --skip-init "Build a SNAP eligibility calculator for a single household"
/create-dashboard --skip-validate "A simple income tax calculator using the PolicyEngine API"
DASHBOARD_NAME = derived from description or user input
REPO_PATH = absolute path to the dashboard repository
PREFIX = /tmp/dashboard-{DASHBOARD_NAME}
PLUGIN_ROOT = directory containing this plugin (use: dirname of agents/dashboard/*.md)
CRITICAL — Context Window Protection:
You DO:
You MUST NOT:
| File | Writer | Reader | Size |
|---|---|---|---|
{REPO_PATH}/plan.yaml | planner agent | All subsequent agents | Full |
{PREFIX}-plan-summary.md | planner agent | Orchestrator | Short ≤20 |
{PREFIX}-build-report.md | build-validator | Orchestrator | Short ≤15 |
{PREFIX}-design-report.md | design-validator | Orchestrator | Short ≤15 |
{PREFIX}-arch-report.md | arch-validator | Orchestrator | Short ≤15 |
{PREFIX}-plan-report.md | plan-validator | Orchestrator | Short ≤15 |
Parse $ARGUMENTS:
- DESCRIPTION: the natural-language dashboard description
- OPTIONS: --repo, --skip-init, --skip-validate
Clean up leftover files from previous runs:
rm -f /tmp/dashboard-*-plan-summary.md /tmp/dashboard-*-build-report.md /tmp/dashboard-*-design-report.md /tmp/dashboard-*-arch-report.md /tmp/dashboard-*-plan-report.md
Resolve PLUGIN_ROOT — find the directory containing this plugin:
# Find the agents directory to determine plugin root
find ~ -maxdepth 6 -path '*/policyengine-claude/agents/dashboard/dashboard-planner.md' -not -path '*/node_modules/*' 2>/dev/null | head -1 | xargs dirname | xargs dirname | xargs dirname
If --skip-init: Set REPO_PATH to the current working directory. Skip to Phase 1.
If --repo NAME_OR_PATH: Search for the repo:
~/Documents/PolicyEngine/{NAME} → ~/PolicyEngine/{NAME} → ~/{NAME}REPO_PATH to the found path. Skip to Phase 1.Otherwise: Create a new repository:
AskUserQuestion:
Question: "What should the GitHub repository be named?"
Options:
- "{auto-derived-name}" (Recommended)
- "Let me type a name"
Set DASHBOARD_NAME from the answer.
gh api user --jq '.login'
If this fails, tell the user to run gh auth login and STOP.
gh api orgs/PolicyEngine/memberships/{username} --jq '.role'
If not admin or member, report and STOP.
gh repo create PolicyEngine/{DASHBOARD_NAME} --public --description "PolicyEngine {DASHBOARD_NAME} dashboard"
AskUserQuestion:
Question: "Where should I clone the repository?"
Options:
- "{sibling-of-cwd}/{DASHBOARD_NAME}" (Recommended)
- "~/Documents/PolicyEngine/{DASHBOARD_NAME}"
- "Let me specify a path"
gh repo clone PolicyEngine/{DASHBOARD_NAME} "{CLONE_PATH}"
cd {CLONE_PATH} && git add -A && git commit --allow-empty -m "Initialize dashboard repository" && git push -u origin main
REPO_PATH = {CLONE_PATH}.Set PREFIX = /tmp/dashboard-{DASHBOARD_NAME}.
Spawn a general-purpose agent ("dashboard-planner"):
subagent_type: "general-purpose"
"You are the dashboard-planner agent for the PolicyEngine dashboard builder.
WORKING DIRECTORY: {REPO_PATH}
Use absolute paths for all Read/Write/Edit/Glob/Grep operations.
Prefix all Bash commands with: cd {REPO_PATH} &&
DASHBOARD DESCRIPTION:
{DESCRIPTION}
Read and follow the complete instructions in:
{PLUGIN_ROOT}/agents/dashboard/dashboard-planner.md
ADDITIONAL REQUIREMENTS:
- Write plan.yaml to {REPO_PATH}/plan.yaml
- Also write a SHORT summary (≤20 lines) to {PREFIX}-plan-summary.md containing:
- Dashboard name and purpose
- Data pattern chosen and why
- Number and types of components
- Key API endpoints or data sources
- Any questions or concerns about the description"
Read {PREFIX}-plan-summary.md (SHORT file). Present the summary to the user:
AskUserQuestion:
Question: "Here's the dashboard plan. How should we proceed?"
Options:
- "Approve — start building" (Recommended)
- "Modify — I have feedback"
- "Reject — start over"
If "Approve": Continue to Phase 2.
If "Modify": Ask follow-up question for feedback. Then re-spawn planner agent with extra context:
"User feedback on your previous plan:
{USER_FEEDBACK}
Read the existing plan.yaml in {REPO_PATH} and update it based on this feedback.
Write updated plan.yaml and updated {PREFIX}-plan-summary.md."
Then repeat Step 1B (approval loop).
If "Reject": STOP.
Spawn a general-purpose agent ("dashboard-scaffold"):
subagent_type: "general-purpose"
"You are the dashboard-scaffold agent for the PolicyEngine dashboard builder.
WORKING DIRECTORY: {REPO_PATH}
Use absolute paths for all Read/Write/Edit/Glob/Grep operations.
Prefix all Bash commands with: cd {REPO_PATH} &&
Read and follow the complete instructions in:
{PLUGIN_ROOT}/agents/dashboard/dashboard-scaffold.md
The approved plan.yaml is at: {REPO_PATH}/plan.yaml"
After the agent completes, run quality gates:
cd {REPO_PATH} && bun run build 2>&1 | tail -50
cd {REPO_PATH} && bunx vitest run 2>&1 | tail -50
If both pass (exit code 0): Continue to Phase 3.
If either fails: Re-spawn scaffold agent with error context:
"Quality gate failed. Fix the issues:
Command: {FAILED_COMMAND}
Exit code: {EXIT_CODE}
Output:
{STDERR_AND_STDOUT}
Fix the issues in {REPO_PATH} and ensure both build and tests pass."
Max 2 retries. If still failing after retries:
AskUserQuestion:
Question: "Build/tests still failing after 2 fix attempts. What should we do?"
Options:
- "Continue anyway — I'll fix manually later"
- "Stop"
Spawn both agents in a single message so they run concurrently:
subagent_type: "general-purpose"
run_in_background: true
"You are the backend-builder agent for the PolicyEngine dashboard builder.
WORKING DIRECTORY: {REPO_PATH}
Use absolute paths for all Read/Write/Edit/Glob/Grep operations.
Prefix all Bash commands with: cd {REPO_PATH} &&
Read and follow the complete instructions in:
{PLUGIN_ROOT}/agents/dashboard/backend-builder.md
The approved plan.yaml is at: {REPO_PATH}/plan.yaml"
subagent_type: "general-purpose"
run_in_background: true
"You are the frontend-builder agent for the PolicyEngine dashboard builder.
WORKING DIRECTORY: {REPO_PATH}
Use absolute paths for all Read/Write/Edit/Glob/Grep operations.
Prefix all Bash commands with: cd {REPO_PATH} &&
Read and follow the complete instructions in:
{PLUGIN_ROOT}/agents/dashboard/frontend-builder.md
The approved plan.yaml is at: {REPO_PATH}/plan.yaml"
Wait for both agents to complete before proceeding.
Spawn a general-purpose agent ("dashboard-integrator"):
subagent_type: "general-purpose"
"You are the dashboard-integrator agent for the PolicyEngine dashboard builder.
WORKING DIRECTORY: {REPO_PATH}
Use absolute paths for all Read/Write/Edit/Glob/Grep operations.
Prefix all Bash commands with: cd {REPO_PATH} &&
Read and follow the complete instructions in:
{PLUGIN_ROOT}/agents/dashboard/dashboard-integrator.md
The approved plan.yaml is at: {REPO_PATH}/plan.yaml"
Skip this phase if --skip-validate flag is set.
ROUND = 1
MAX_ROUNDS = 3
PENDING_VALIDATORS = [build, design, architecture, plan] # all 4 initially
Spawn all pending validators in a single message, each with run_in_background: true.
For each validator, use this prompt template:
subagent_type: "general-purpose"
run_in_background: true
"You are the {VALIDATOR_NAME} agent for the PolicyEngine dashboard builder.
WORKING DIRECTORY: {REPO_PATH}
Use absolute paths for all Read/Write/Edit/Glob/Grep operations.
Prefix all Bash commands with: cd {REPO_PATH} &&
Read and follow the complete instructions in:
{PLUGIN_ROOT}/agents/dashboard/{VALIDATOR_FILE}
The plan.yaml is at: {REPO_PATH}/plan.yaml
ADDITIONAL: Write your report to {PREFIX}-{REPORT_FILE} in addition to returning it."
Validator details:
| Validator | Agent file | Report file |
|---|---|---|
| build | dashboard-build-validator.md | build-report.md |
| design | dashboard-design-validator.md | design-report.md |
| architecture | dashboard-architecture-validator.md | arch-report.md |
| plan | dashboard-plan-validator.md | plan-report.md |
Wait for all validators to complete.
Read each validator's SHORT report. Look for PASS or FAIL.
If all pass: Exit validation loop, continue to Phase 6.
If any fail: Collect the failure details from each failed validator.
Use this routing table to determine which builder agent should fix each failure:
| Failed Validator | Failure contains | Route to builder |
|---|---|---|
| build | (any failure) | dashboard-scaffold.md |
| design | (any failure) | frontend-builder.md |
| architecture | "tailwind", "next.js", "package manager" | dashboard-scaffold.md |
| architecture | "ui-kit", or other | frontend-builder.md |
| plan | "api contract" | backend-builder.md |
| plan | "component", "chart" | frontend-builder.md |
| plan | "embedding", "loading", "error" | dashboard-integrator.md |
Group failures by target builder. For each builder that needs to fix issues, spawn it:
subagent_type: "general-purpose"
"You are the {BUILDER_NAME} agent. Fix the following validation failures:
WORKING DIRECTORY: {REPO_PATH}
Use absolute paths. Prefix Bash with: cd {REPO_PATH} &&
Read the full instructions in:
{PLUGIN_ROOT}/agents/dashboard/{BUILDER_FILE}
VALIDATION FAILURES TO FIX:
{LIST_OF_FAILURES_FROM_REPORTS}
Fix each issue, ensuring the build and tests still pass.
Run: cd {REPO_PATH} && bun run build && bunx vitest run"
After fixes, set PENDING_VALIDATORS to only the validators that failed (don't re-run passed ones).
Increment ROUND. If ROUND <= MAX_ROUNDS, go back to Step 5A.
If ROUND > MAX_ROUNDS and failures remain:
AskUserQuestion:
Question: "Validation found {N} remaining issues after {MAX_ROUNDS} fix rounds. What should we do?"
Options:
- "Accept as-is — I'll fix manually"
- "Keep trying one more round"
- "Stop — don't commit"
If "Accept": Continue to Phase 6. If "Keep trying": Increment MAX_ROUNDS by 1, go back to Step 5A. If "Stop": STOP.
Present a summary to the user:
## Dashboard Build Complete
**Repository**: {REPO_PATH}
**Phases completed**: plan → scaffold → backend + frontend → integrate → validate
### How to run locally
cd {REPO_PATH}
make dev # Start full dev stack
make dev-frontend # Frontend only
make test # Run tests
make build # Production build
### Next steps
After reviewing locally, commit and push. Then use /deploy-dashboard to deploy.
AskUserQuestion:
Question: "Ready to commit and push to GitHub?"
Options:
- "Commit and push" (Recommended)
- "Stop — I want to review locally first"
If "Commit and push":
cd {REPO_PATH} && git add -A && git commit -m "Implement dashboard from plan" && git push origin HEAD
Report the result to the user with the repo URL.
If "Stop": Report that code is ready locally at {REPO_PATH} and the user can commit when ready.
Spawn the overview updater in the background — no need to wait:
subagent_type: "general-purpose"
run_in_background: true
"You are the dashboard-overview-updater agent.
Read and follow: {PLUGIN_ROOT}/agents/dashboard/dashboard-overview-updater.md"
| Category | Example | Action |
|---|---|---|
| GitHub auth failure | gh api user fails | Tell user to run gh auth login, STOP |
| Repo already exists | gh repo create says exists | Tell user to use --repo NAME, STOP |
| Build failure | bun run build fails | Re-run scaffold with error context (max 2 retries) |
| Test failure | bunx vitest run fails | Re-run scaffold with error context (max 2 retries) |
| Validation failure | Validator reports FAIL | Route to builder, re-validate (max 3 cycles) |
| Agent failure | Agent errors or doesn't complete | Report to user, suggest re-running that phase |
| User rejects plan | "Reject" at plan approval | STOP |
YOUR ROLE: You are an orchestrator ONLY. You must:
subagent_type: "general-purpose"run_in_background: true for parallel)YOU MUST NOT:
IMPORTANT — Agent Working Directory: Every agent prompt MUST include:
WORKING DIRECTORY: {REPO_PATH}
Use absolute paths for all Read/Write/Edit/Glob/Grep operations.
Prefix all Bash commands with: cd {REPO_PATH} &&
This ensures agents work in the correct directory regardless of Claude Code's cwd.
Execution Flow (CONTINUOUS):
Execute all phases sequentially without stopping (unless a STOP condition is hit):
--skip-validate