| name | unified-deliverables-flow |
| description | Generate spreadsheets, diagrams, and PDF reports in a phased workflow with explicit iteration budgets and error recovery |
Unified Multi-Deliverable Generation Workflow
This skill provides a structured, phased approach for creating multiple deliverable types (spreadsheets, diagrams, PDF reports) in a single cohesive workflow with explicit iteration budgeting to prevent premature exhaustion.
Overview
Use this workflow when you need to:
- Generate multiple deliverable types (Excel, images, PDFs) in one task
- Ensure balanced iteration allocation across all deliverables
- Handle tool failures gracefully with retries and fallbacks
- Produce downloadable artifacts with verified paths
Critical: Iteration Budget Allocation
Allocate iterations BEFORE starting work:
| Phase | Deliverable | Budget | Checkpoint |
|---|
| Phase 1 | Spreadsheet | 8 iterations | File exists + readable |
| Phase 2 | Diagram | 8 iterations | File exists + >1KB |
| Phase 3 | PDF Report | 8 iterations | File exists + ARTIFACT_PATH output |
| Buffer | Error recovery | 6 iterations | Remaining for retries |
| Total | All deliverables | 30 iterations | All verified |
Rules:
- Complete each phase before moving to the next
- If a phase exceeds budget, use fallback strategy (see below)
- Never spend >10 iterations on a single deliverable without checkpoint
- Verify each deliverable before proceeding
Step-by-Step Instructions
Phase 0: Pre-Work Setup (1 iteration max)
-
Define all deliverables explicitly:
Deliverable 1: hardware_selection_table.xlsx (Excel with comparison data)
Deliverable 2: cnc_workcell_layout.png (PNG diagram of layout)
Deliverable 3: final_report.pdf (PDF summary report)
-
Verify workspace is accessible:
run_shell
command: ls -la /workspace/ && mkdir -p /workspace/artifacts
-
Set path variables for consistency:
- All files go to
/workspace/ or /workspace/artifacts/
- Use absolute paths in all code
- Never use relative paths like
./output.xlsx
Phase 1: Spreadsheet Generation (Budget: 8 iterations)
Step 1.1: Choose approach
| Method | Tool | Best For |
|---|
| Direct Python | execute_code_sandbox | Quick generation, simple tables |
| Shell agent | shell_agent | Complex logic, error recovery |
Step 1.2: Create spreadsheet code
from openpyxl import Workbook
from openpyxl.styles import Font, Alignment, Border, Side
def create_hardware_table():
wb = Workbook()
ws = wb.active
ws.title = "Hardware Selection"
headers = ["Component", "Option A", "Option B", "Option C", "Recommendation"]
for col, header in enumerate(headers, 1):
cell = ws.cell(row=1, column=col, value=header)
cell.font = Font(bold=True)
cell.alignment = Alignment(horizontal='center')
data = [
["Controller", "PLC-X100 ($500)", "PLC-Y200 ($650)", "PLC-Z300 ($800)", "PLC-Y200"],
["Motor", "Servo-500W ($300)", "Servo-750W ($400)", "Stepper-1kW ($250)", "Servo-750W"],
["Sensor", "Proximity-S1 ($50)", "Vision-V2 ($200)", "Laser-L3 ($150)", "Vision-V2"]
]
for row_idx, row_data in enumerate(data, 2):
for col_idx, value in enumerate(row_data, 1):
ws.cell(row=row_idx, column=col_idx, value=value)
col ws.columns:
max_length = (((cell.value)) cell col cell.value)
ws.column_dimensions[col[].column_letter].width = (max_length + , )
output_path =
wb.save(output_path)
()
()
output_path
create_hardware_table()
Step 1.3: Execute with verification
execute_code_sandbox
code: <spreadsheet code from Step 1.2>
language: python
Step 1.4: Verify (REQUIRED before proceeding)
run_shell
command: ls -lh /workspace/*.xlsx && python3 -c "import openpyxl; openpyxl.load_workbook('/workspace/hardware_selection_table.xlsx')"
Checkpoint criteria:
- ✓ File exists
- ✓ Size > 1KB
- ✓ No errors opening file
- ✗ If failed, retry once with shell_agent, then proceed to Phase 2 with note
Phase 2: Diagram Generation (Budget: 8 iterations)
Step 2.1: Choose diagram type and tool
| Diagram Type | Tool | Library |
|---|
| Flowchart/Blocks | execute_code_sandbox | matplotlib, graphviz |
| Layout/Floorplan | shell_agent | matplotlib, PIL |
| Architecture | execute_code_sandbox | matplotlib, diagram |
Step 2.2: Create diagram code (matplotlib example)
import matplotlib.pyplot as plt
import matplotlib.patches as patches
def create_layout_diagram():
fig, ax = plt.subplots(figsize=(12, 8))
ax.set_xlim(0, 100)
ax.set_ylim(0, 80)
ax.set_aspect('equal')
ax.set_title('CNC Workcell Layout', fontsize=16, pad=20)
components = [
{'label': 'CNC Machine', 'xy': (30, 40), 'w': 25, 'h': 20, 'color': '#3498db'},
{'label': 'Robot Arm', 'xy': (60, 40), 'w': 15, 'h': 15, 'color': '#e74c3c'},
{'label': 'Material Rack', 'xy': (10, 20), 'w': 15, 'h': 40, 'color': '#2ecc71'},
{'label': 'Control Panel', 'xy': (, ), : , : , : },
{: , : (, ), : , : , : , : , : }
]
comp components:
comp.get():
rect = patches.Rectangle(
(comp[][], comp[][]),
comp[], comp[],
linewidth=,
edgecolor=comp[],
facecolor=comp[],
linestyle= comp.get()
)
:
rect = patches.Rectangle(
(comp[][], comp[][]),
comp[], comp[],
linewidth=,
edgecolor=,
facecolor=comp[]
)
ax.add_patch(rect)
ax.text(
comp[][] + comp[]/,
comp[][] + comp[]/,
comp[],
ha=, va=, fontsize=, fontweight=
)
plt.grid(, alpha=)
plt.xlabel()
plt.ylabel()
output_path =
plt.savefig(output_path, dpi=, bbox_inches=)
plt.close()
()
()
output_path
create_layout_diagram()
Step 2.3: Execute and verify
execute_code_sandbox
code: <diagram code from Step 2.2>
language: python
Verification:
run_shell
command: ls -lh /workspace/*.png && file /workspace/*.png
Checkpoint criteria:
- ✓ File exists
- ✓ Size > 1KB
- ✓ File type confirmed as PNG/image
- ✗ If failed after 2 retries, use shell_agent fallback, then proceed
Phase 3: PDF Report Generation (Budget: 8 iterations)
Step 3.1: Prepare content aggregation
Gather data from previous phases:
- Spreadsheet: key findings, recommendations
- Diagram: visual summary
- Additional: scoring, conclusions
Step 3.2: Create PDF generation code
from reportlab.lib import colors
from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, Image
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import inch
from reportlab.lib.enums import TA_CENTER, TA_LEFT
def create_final_report(output_path):
doc = SimpleDocTemplate(output_path, pagesize=letter,
rightMargin=0.75*inch, leftMargin=0.75*inch,
topMargin=0.75*inch, bottomMargin=0.75*inch)
styles = getSampleStyleSheet()
story = []
title_style = ParagraphStyle('CustomTitle', parent=styles['Heading1'],
fontSize=20, spaceAfter=30, alignment=TA_CENTER,
fontName='Helvetica-Bold')
heading_style = ParagraphStyle('CustomHeading', parent=styles['Heading2'],
fontSize=14, spaceAfter=12, spaceBefore=20,
fontName='Helvetica-Bold')
story.append(Paragraph("CNC Workcell Implementation Report", title_style))
story.append(Spacer(1, 0.5*inch))
story.append(Paragraph("Executive Summary", heading_style))
summary_text = """
This report presents the hardware selection analysis and workcell layout
for the proposed CNC implementation. After evaluating multiple options across
controllers, motors, and sensors, recommended configurations balance cost,
performance, and reliability.
"""
story.append(Paragraph(summary_text, styles[]))
story.append(Spacer(, *inch))
story.append(Paragraph(, heading_style))
data = [
[, , , ],
[, , , ],
[, , , ],
[, , , ]
]
table = Table(data, colWidths=[*inch, *inch, *inch, *inch])
table.setStyle(TableStyle([
(, (, ), (-, ), colors ),
(, (, ), (-, ), colors.whitesmoke),
(, (, ), (-, -), ),
(, (, ), (-, ), ),
(, (, ), (-, ), ),
(, (, ), (-, ), ),
(, (, ), (-, -), colors.beige),
(, (, ), (-, -), , colors.black),
(, (, ), (-, -), )
]))
story.append(table)
story.append(Spacer(, *inch))
story.append(Paragraph(, heading_style))
story.append(Paragraph(, styles[]))
story.append(Spacer(, *inch))
story.append(Paragraph(, heading_style))
rec_text =
story.append(Paragraph(rec_text, styles[]))
story.append(Spacer(, *inch))
story.append(Spacer(, *inch))
footer_style = ParagraphStyle(, parent=styles[],
fontSize=, alignment=TA_CENTER, textColor=colors.grey)
story.append(Paragraph(, footer_style))
doc.build(story)
()
()
output_path
create_final_report()
Step 3.3: Execute with explicit artifact path
execute_code_sandbox
code: <PDF code from Step 3.2>
language: python
Step 3.4: Final verification
run_shell
command: ls -lh /workspace/*.pdf && echo "---" && ls -lh /workspace/*.xlsx /workspace/*.png
Checkpoint criteria:
- ✓ PDF file exists
- ✓ Size > 10KB (reports should be substantial)
- ✓ ARTIFACT_PATH was output
- ✓ All three deliverables verified
Error Recovery & Fallback Strategies
When execute_code_sandbox fails repeatedly:
Strategy 1: Use shell_agent (more resilient)
shell_agent
task: Create an Excel file at /workspace/hardware_selection_table.xlsx with hardware comparison data including controllers, motors, and sensors with costs and recommendations
Strategy 2: Simplify the code
- Remove complex styling
- Use basic libraries only (csv instead of openpyxl if needed)
- Reduce dependencies
Strategy 3: Change output format
- Excel → CSV if openpyxl fails
- PNG → SVG if PIL/matplotlib fails
- PDF → Markdown + convert later
When iteration budget is running low:
| Iterations Remaining | Action |
|---|
| < 10 | Skip non-critical formatting, use minimal viable output |
| < 5 | Use simplest possible implementation, skip verification |
| < 3 | Output text summary with file paths, request manual generation |
Best Practices
- Phase sequentially - Complete and verify each phase before moving on
- Use absolute paths - Always
/workspace/filename.ext, never relative
- Output ARTIFACT_PATH - Every successful generation must print this
- Verify before proceeding - Run shell check after each deliverable
- Track iteration count - Count tool calls, stop at 25 to leave buffer
- Simplify on failure - If complex code fails, strip to minimum viable
- Document decisions - Note why fallback was used for future reference
Quick Reference: Tool Selection
| Task | Primary Tool | Fallback Tool |
|---|
| Spreadsheet | execute_code_sandbox (openpyxl) | shell_agent (pandas) |
| Diagram | execute_code_sandbox (matplotlib) | shell_agent (graphviz) |
| PDF Report | execute_code_sandbox (reportlab) | shell_agent (fpdf) |
| Verification | run_shell (ls, file) | read_file (for content check) |
Complete Workflow Checklist
Troubleshooting
| Problem | Immediate Action |
|---|
| execute_code_sandbox returns "[ERROR] unknown error" | Retry once, then switch to shell_agent |
| File not found after execution | Check actual path with run_shell: ls /workspace/ |
| ARTIFACT_PATH not output | Re-run with explicit print statement |
| Iteration budget nearly exhausted | Skip remaining deliverables, document what was created |
| Library import fails | Add !pip install <library> at code start |
Related Tools
execute_code_sandbox - Primary tool for code execution (Python)
shell_agent - Fallback for complex tasks or when sandbox fails
run_shell - Verification and workspace inspection
read_file - Content verification (type: xlsx, png, pdf)
create_file - Alternative for text-based outputs