map-workflow

$npx mdskill add tranhieutt/software_development_department/map-workflow

Generates a multi-agent workflow graph from a pattern and agent list.

  • Plans feature delivery before any implementation begins.
  • Uses Read, Write, and Bash tools to generate and save graphs.
  • Selects graph structure based on the specified pattern and agent list.
  • Outputs a workflow file for user approval before dispatching agents.

SKILL.md

.github/skills/map-workflowView on GitHub ↗
---
name: map-workflow
type: workflow
description: "Generates a structured multi-agent workflow graph from a pattern and agent list. Supports Sequential, Parallel, Hierarchical, and Iterative patterns. Used by @producer to plan feature delivery before any implementation begins."
argument-hint: "--pattern <name> --agents <list> --task <description> [--max-iter <N>] [--save <filename>]"
user-invocable: true
allowed-tools: Read, Write, Bash
effort: 2
when_to_use: "Use at the start of any multi-agent feature or sprint wave. Always run BEFORE implementation. Output the graph for user approval before dispatching any agent."
---

# Map Workflow

Generate a workflow graph for a multi-agent task using one of four patterns.
Present the graph to the user for approval before any agent is dispatched.

## Steps

### 1. Parse arguments

Extract from `$ARGUMENTS`:

| Flag | Required | Default | Description |
| :--- | :--- | :--- | :--- |
| `--pattern` | yes | — | `Sequential`, `Parallel`, `Hierarchical`, or `Iterative` |
| `--agents` | yes | — | Comma-separated agent names in execution order |
| `--task` | yes | — | One-sentence description of what this workflow delivers |
| `--max-iter` | no | `3` | Max loop iterations (Iterative pattern only) |
| `--save` | no | none | If set, write the graph to `.tasks/[filename].workflow.md` |

If `--pattern` or `--agents` or `--task` is missing, print usage and stop:

```text
Usage: /map-workflow --pattern <Sequential|Parallel|Hierarchical|Iterative> \
                     --agents "<agent1,agent2,...>" \
                     --task "<what this workflow delivers>" \
                     [--max-iter <N>] [--save <filename>]

Patterns:
  Sequential   — linear pipeline, one agent after another
  Parallel     — fan-out to multiple agents simultaneously, then merge
  Hierarchical — supervisor delegates to specialists
  Iterative    — test-driven loop until quality gate passes

Reference: docs/templates/workflow-graph.md
```

### 2. Validate agents

For each agent name in `--agents`, verify it exists in `.claude/agents/`.
If an agent is not found, warn but continue:

```text
⚠️  Agent "foo-developer" not found in .claude/agents/ — check spelling.
    Proceeding with remaining agents.
```

### 3. Generate the workflow graph

Using the pattern and agents, fill in the workflow schema from
`docs/templates/workflow-graph.md`. Apply these rules per pattern:

**Sequential:** Each agent becomes one node. `on_pass` chains to the next agent.
`on_fail: stop` for all nodes.

**Parallel:** First agent in list becomes the `orchestrate` node. Last agent
becomes the `merge` node. All middle agents run in parallel from orchestrate
to merge. A `qa-engineer` node is appended after merge if not already in the list.

**Hierarchical:** First agent becomes the `plan` (supervisor) node.
Remaining agents are parallel specialist nodes. First agent is also the final
`review` node. All specialists must complete before review.

**Iterative:** Exactly 2 agents required — first is the implementer,
second is the tester. Loop: implementer → tester → [fail→implementer | pass→done].
Cap at `--max-iter` iterations.

### 4. Display the graph

Show the filled YAML schema and an ASCII flow diagram:

```text
🗺️  Workflow Graph — [pattern] · [task]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

[YAML schema — filled in]

Flow:
[ASCII diagram derived from nodes]

Agents dispatched: [N]
Estimated turns:   [N × 5 turns per agent, rough estimate]
Max iterations:    [N — Iterative only, else omit]

Verification criteria per node:
  [node-id] (@agent): [on_pass condition description]
```

### 5. Ask for approval

```text
✋ Does this workflow look correct?
   Reply "yes" to confirm and begin dispatching agents.
   Reply "edit [node-id] [field] [value]" to adjust a node.
   Reply "no" to cancel.
```

Do NOT dispatch any agent until the user confirms.

### 6. Save (if --save provided)

After approval, if `--save <filename>` was passed, write the graph to
`.tasks/<filename>.workflow.md` and print:

```text
✅ Workflow saved → .tasks/<filename>.workflow.md
```

### 7. Dispatch (after approval)

After the user confirms, hand off to `@producer` with the instruction:

> "Execute workflow `[id]` — dispatch agents in the order defined by the graph.
>  For each node: run the agent, check the outcome, follow on_pass/on_fail edges.
>  Write a ledger entry to `production/traces/decision_ledger.jsonl` at each
>  node completion. Save a checkpoint via `/save-state [task_id]` if any node fails."

---

## Quick Examples

```bash
# Simple 3-agent pipeline
/map-workflow --pattern Sequential \
  --agents "technical-director,backend-developer,qa-engineer" \
  --task "Build JWT auth endpoint"

# Parallel frontend + backend
/map-workflow --pattern Parallel \
  --agents "backend-developer,frontend-developer" \
  --task "Login feature — API and UI"

# TDD loop, max 3 retries
/map-workflow --pattern Iterative \
  --agents "backend-developer,qa-engineer" \
  --task "Payment service" --max-iter 3

# Save to .tasks/
/map-workflow --pattern Hierarchical \
  --agents "lead-programmer,backend-developer,frontend-developer,qa-engineer" \
  --task "Sprint 04 wave 1" --save sprint-04-wave-1
```

More from tranhieutt/software_development_department

SkillDescription
agent-healthReads production/traces/agent-metrics.jsonl and displays a per-agent performance summary table for the current or a specified session. Highlights agents with high error rates or OPEN circuit breaker state.
agent-styleProvides the vendored agent-style v0.3.5 prose rule pack as a portable Claude skill. Use when installing, syncing, applying, or auditing SDD Agent-Style support in another project, or when a style-review workflow needs the bundled rules.
angular-best-practicesProvides Angular best practices for components, modules, services, and reactive patterns. Use when working with Angular TypeScript files, component templates, NgModules, RxJS observables, or when the user mentions Angular, ng, or Angular CLI.
annotateRecords unexpected API behaviors, undocumented caveats, version bugs, or non-obvious workarounds into .claude/memory/annotations.md. Use immediately when an undocumented behavior or surprising caveat is discovered during development.
aws-serverlessProvides AWS serverless architecture patterns for Lambda, API Gateway, DynamoDB, SQS, and SAM/CDK. Use when working with AWS serverless files (serverless.yml, CDK stacks) or when the user mentions Lambda, API Gateway, serverless, or AWS SAM.
backend-architectDesigns scalable backend architectures covering microservices, event-driven systems, API gateways, and data stores. Use when designing a backend system or when the user mentions backend architecture, scalability, or distributed systems.
cloud-run-puppeteerDeploys Puppeteer browser automation on Google Cloud Run with Docker. Use when running headless browser tasks on Cloud Run, or when the user mentions Cloud Run, Puppeteer, headless Chrome, or serverless browser automation.
codex-sddAdapts SDD for Codex while preserving Claude Code behavior. Use when working in Codex, setting up Codex compatibility, mapping Claude tools to Codex tools, or explaining how SDD should run outside Claude Code.
database-architectDesigns relational and NoSQL database schemas, indexing strategies, migration plans, and data modeling patterns. Use when designing a database or when the user mentions database architecture, schema design, or data modeling.
db-reviewReviews database schemas, queries, and migrations for correctness, performance, security, and best practices. Use when reviewing SQL migration files or when the user mentions database review, schema review, or query audit.