# Workflow: Synthesize Results

**Model tier**: Opus (requires intelligent synthesis and quality judgment)

## When to use

Final step in any multi-workflow execution plan. Called after all execution subagents have completed and written their outputs.

## Purpose

Read all previous step outputs, synthesize into a coherent deliverable, and produce the final user-facing artifact.

## Inputs

- **plan_path**: Path to current execution plan (`.claude/plugin-data/cc-architect/plans/current-plan.md`)
- **artifact_type**: Type of final output (plugin, skill, workflow, command, description, audit)

## Output

- `.claude/plugin-data/cc-architect/output/final.md`

---

## Phase 1: Locate Outputs

Read the execution plan to identify all previous step outputs.

**Extract from plan:**
1. List of output files from each completed step
2. Artifact type being produced
3. Request summary (what user wanted)

**Build file manifest:**
```
Step 1: .claude/plugin-data/cc-architect/tasks/{step-1-output}.md
Step 2: .claude/plugin-data/cc-architect/tasks/{step-2-output}.md
...
```

---

## Phase 2: Read and Analyze

Read each output file in order.

**For each file, extract:**
- Key findings or artifacts created
- Decisions made
- Warnings or issues flagged
- Cross-references to other files

**Build synthesis context:**
- Deduplicate overlapping information
- Identify contradictions or conflicts
- Note dependencies between outputs

---

## Phase 3: Synthesize

Combine outputs according to artifact type.

### Artifact Type: Plugin

```markdown
# Plugin Created: {plugin-name}

## Summary
{One paragraph describing what was built}

## Files Created
| Path | Purpose |
|------|---------|
| `{path}` | {description} |

## Skill(s) Included
- **{skill-name}**: {brief description}

## Next Steps
1. {Actionable next step}
2. {Actionable next step}

## Configuration (if applicable)
{How to configure the plugin}
```

### Artifact Type: Skill

```markdown
# Skill Created: {skill-name}

## Summary
{One paragraph describing the skill's purpose and trigger}

## Files Created
| Path | Purpose |
|------|---------|
| `{path}` | {description} |

## Usage
Invoke with: `/{skill-name}` or triggered by: {trigger conditions}

## Workflows Included
- **{workflow-name}**: {when to use}

## Golden Examples Needed
{Suggest 1-2 golden examples user should create based on their domain}

## Next Steps
1. Test with a real use case
2. Create golden examples
3. Add invariants as patterns emerge
```

### Artifact Type: Workflow

```markdown
# Workflow Created: {workflow-name}

## Summary
{One paragraph describing what this workflow accomplishes}

## File Location
`{path-to-workflow}`

## Integration
{How this workflow is invoked - from which skill, with what triggers}

## Testing
{How to verify the workflow works correctly}
```

### Artifact Type: Audit

```markdown
# Audit Complete: {target-name}

## Verdict: {Ready / Not Ready}

## Summary
- Significant issues: {N}
- Minor issues: {N}
- Polish items: {N}

## Critical Findings
{List significant issues with severity and remediation}

## Recommendations
{Prioritized list of actions}

## Patterns Discovered
{Novel approaches worth considering for standards}
```

### Artifact Type: Description

```markdown
# Description Generated

## Result
`{the description string}`

## Escape Hatch Test
{Pass/Fail with reasoning}

## Usage
Add to frontmatter:
```yaml
description: {the description string}
```
```

---

## Phase 4: Quality Check

Before writing final output, verify:

**Completeness:**
- [ ] All execution steps represented in synthesis
- [ ] No orphaned outputs (created but not referenced)
- [ ] User's original request fully addressed

**Coherence:**
- [ ] No contradictory information
- [ ] Consistent terminology throughout
- [ ] Logical flow from problem to solution

**Actionability:**
- [ ] Clear next steps provided
- [ ] File paths are accurate and complete
- [ ] User can act on this without additional context

**Quality signals (Opus judgment):**
- Does this feel complete?
- Would a user be satisfied receiving this?
- Is anything important buried or unclear?

---

## Phase 5: Write Final Output

Write to: `.claude/plugin-data/cc-architect/output/final.md`

**Header:**
```markdown
# {Artifact Type}: {Name}

**Generated**: {date}
**Request**: {one-line summary}
**Status**: Complete

---
```

**Body:**
Use appropriate artifact template from Phase 3.

**Footer:**
```markdown
---

## Execution Details

| Step | Model | Output | Status |
|------|-------|--------|--------|
| {step} | {model} | {file} | Complete |

## Cleanup Pending
The following temporary files will be removed:
- {list of task files}
```

---

## Error Handling

**Missing output file:**
- Note which step failed
- Include partial synthesis of completed steps
- Flag incomplete sections clearly
- Recommend re-running failed step

**Conflicting outputs:**
- Present both versions
- Note the conflict
- Recommend resolution approach

**Quality check failure:**
- Do not write incomplete synthesis
- Return to orchestrator with specific gaps
- Recommend additional steps needed

---

## Anti-Patterns

| Wrong | Right |
|-------|-------|
| Copy-paste raw outputs | Synthesize and deduplicate |
| Hide warnings from user | Surface all issues clearly |
| Skip quality check | Always verify before writing |
| Vague next steps | Specific, actionable guidance |
| Bury important findings | Lead with critical information |
