# Workflow: Build Execution Plan

Build a structured execution plan that orchestrates cc-architect workflows. This is the CRITICAL first step in all cc-architect operations.

## Who should do this work

- **Sonnet subagent**: Always.

## Inputs

- User request (original message)
- `workflows/catalog.md` (workflow catalog)

## Steps

### 1. Read catalog
Read `workflows/catalog.md` and note workflow names, paths, triggers, complexity, and model tier recommendations.

### 2. Analyze request
Identify:
- Primary intent
- Artifact type (plugin, skill, workflow, command, description)
- Scope (new, modify, audit, improve)
- Dependencies

### 3. Select workflows
- Find primary workflow for main request
- Identify supporting workflows
- Prefer fewer workflows
- Only include workflows directly contributing to output

### 4. Determine sequence
Order: Setup (Haiku) → Processing (Sonnet) → Synthesis (Opus) → Cleanup (Haiku)

Rules:
- Gather before analyzing
- Analyze before synthesizing
- Scaffold before populating
- Cleanup last

### 5. Assign model tiers

| Work Type | Model | Examples |
|-----------|-------|----------|
| Busywork | Haiku | Scaffolding, file gathering, validation, cleanup |
| Processing | Sonnet | Filtering, drafting, analysis, pattern matching |
| Intelligence | Opus | Final artifacts, quality decisions, user-facing output |

Heuristics: Judgment? → Opus. Transform content? → Sonnet. Mechanical? → Haiku.

### 6. Apply batching
Batch same-tier steps with no dependencies. When uncertain, keep sequential.

### 7. Write plan
Write to `.claude/plugin-data/cc-architect/plans/current-plan.md` using format below.

## Output

Write plan to `.claude/plugin-data/cc-architect/plans/current-plan.md`:

```markdown
# Execution Plan

Generated: {timestamp}
Request: {one-line summary}

## Request Summary
{2-3 sentences}

## Selected Workflows
1. **{workflow-name}** - {why needed}

## Execution Steps

### Step N: {action name}
- **Model**: haiku | sonnet | opus
- **Workflow**: `workflows/{name}.md`
- **Input**: {context/files}
- **Output**: `.claude/plugin-data/cc-architect/tasks/{step-N-name}.md`
- **Purpose**: {what this accomplishes}

### Final Step: Synthesize (Opus)
- **Input**: All previous outputs
- **Output**: `.claude/plugin-data/cc-architect/output/final.md`

### Cleanup (Haiku)
- Remove temporary files

## Artifacts
**Final**: `.claude/plugin-data/cc-architect/output/final.md`
**Created**: {persistent files}
```

## Verification

The plan is valid if:

- [ ] Every workflow referenced exists in the catalog
- [ ] Every step has all five required fields (Model, Workflow, Input, Output, Purpose)
- [ ] Step outputs and inputs chain correctly (no references to nonexistent outputs)
- [ ] Final synthesis step uses Opus
- [ ] Cleanup step is present and uses Haiku
- [ ] Batched steps have no dependencies between them

## Anti-patterns

| Anti-Pattern | Why It's Wrong | Correct Approach |
|--------------|----------------|------------------|
| Skipping synthesis step | User output should always be Opus-polished | Always include synthesis |
| Using Opus for file gathering | Wastes expensive model on busywork | Use Haiku for mechanical tasks |
| Batching dependent steps | Creates race conditions | Keep dependent steps sequential |
| Vague output paths | Executor won't know where to write | Always specify exact paths |
| Missing cleanup step | Leaves temporary files cluttering plugin-data | Always include cleanup |
| Plan has AI "decide" something | Plan should be fully deterministic | Specify exact actions |

