🎛️ The pipeline orchestrator
The orchestrator is the conductor: it runs Research → Synthesis → Generation in order, and each stage confirms completion before the next one begins. Nothing moves forward in the dark—if Phase 1 isn’t complete, Phase 2 doesn’t run.
💡 Confirming each step is what saves you
Phase-by-phase confirmation isn’t bureaucracy: it’s what makes the pipeline resumable. Since each stage is marked "complete," a crash midway doesn’t force you to redo (or pay for) what was already finished.
triggers the phases
1 → 2 → 3
before moving on
each step recorded
💾 Checkpoints and state.json
O state.json is the Factory’s memory. It lives in output/{empresa}/ and stores the current phase, the status of each deliverable, and the total cumulative cost of the session.
// output/stripe/state.json
{
"company_name": "Stripe",
"current_phase": "synthesis",
"phases": {
"research": { "status": "complete" },
"synthesis": { "status": "in_progress" },
"generation": { "status": "pending" }
},
"deliverables": {
"01_tech_inventory": { "status": "complete", "path": "..." },
"06_quick_wins": { "status": "pending" }
},
"total_cost": 0.0773
}
📍 Current Phase
current_phase says exactly where the Factory stopped.
✅ Status by deliverable
Each of the 15+ docs is marked complete / pending / failed.
💵 Cumulative cost
total_cost adds up every call — real-time budget tracking.
💡 No checkpoint, no resuming
O state.json is the foundation for everything that follows. It’s what turns “I hit an error and lost everything” into “I hit an error and can pick up where I left off.” Every deliverable it completes is saved immediately.
on disk
where it stopped
accumulated
of the resumption
🔁 Resume When the Context Fills Up
Long Claude Code sessions run out of context—it happened twice in the construction of the original Factory. The solution isn’t to hope it won’t happen; it’s to open a new session and resume from the task list stored in the state.json.
// is the context full? new session, same command
# ver onde parou python -m strategy_factory.main status "Stripe" # retomar de onde o state.json marcou python -m strategy_factory.main resume "Stripe" # → pula research (complete), continua synthesis, depois generation
✓ With resumption
- ✓A new session reads the
state.jsonand continues - ✓Skip phases already
complete— doesn’t pay again - ✓Uses the
research_cache.jsoninstead of researching again
✗ No resumption
- ✗Context fills up → start everything from scratch
- ✗Pay for the research again every time it fails
- ✗Long sessions become dead ends
💡 Documentation is cheap in tokens
Even on Anthropic’s US$20 plan, you can do a lot—as long as you split up the requests. Building in public means showing the mess: context limits, API errors, the wrong model name in the docs. Picking back up from the task list is the skill that helps you finish even when things get stuck.
new session
continues the state
smaller requests
without getting stuck
🪢 Mermaid: current state vs. future state
The diagram prompt generates two flowcharts that tell the story of the transformation: the current state (today's stack, with bottlenecks marked) and the future state (the AI-enabled architecture). That’s the “before and after” that sells.
// Mermaid example: current state vs. future state
flowchart TB
subgraph Atual["Estado Atual"]
DS1[Planilhas soltas] --> CS1[CRM legado]
CS1 --> U1[Vendas]
CS1 -. gargalo .-> X[(Dados em silos)]
end
subgraph Futuro["Estado Futuro · IA"]
DL[Plataforma de Dados Unificada] --> AI1[Copiloto de Vendas]
DL --> AI2[Previsão de Churn]
AI1 --> U2[Vendas]
AI2 --> U3[Sucesso do Cliente]
end
Atual ==>|transformação| Futuro
📉 Current State
- •Data sources and legacy systems
- •Fragile integration points
- •Known bottlenecks marked in red
📈 Future State (AI)
- •Unified data platform
- •AI/ML services layer
- •Enhanced applications and automated workflows
💡 The deciding slide
An executive won't read three pages of text, but will understand the "before and after" in five seconds. Marking the bottlenecks in the current state creates tension; showing the future state resolves it. This pair of diagrams is often the slide that gets the project approved.
with bottlenecks
AI-enabled
before and after
the board decides
🖼️ Render Mermaid → PNG
Client can't open a file .mmd — it opens an image on the slide. The mermaid_renderer converts the code into an actual PNG for insertion into the PPTX. And if rendering fails, graceful degradation kicks in: skips the image and keeps the markdown.
mermaid_renderer (in the pipeline)
Take the code generated by the diagram prompt and export a PNG to mermaid_images/. It’s the Factory’s automatic workflow.
Skill beautiful-mermaid
Renders Mermaid as polished SVG and PNG—ideal when you want a polished diagram outside the pipeline.
eraser.io
Online editor for manually adjusting the diagram and exporting it—good for a quick touch-up before the meeting.
💡 PNG on the slide, source version-controlled
Save the .mmd in recursos/diagramas/ (versionable) and deliver the PNG in the deck. That way, you can edit the diagram text when the project changes without rebuilding the image from scratch.
PNG in the pipeline
finishing touches
manual touch-up
keep the md
📦 Package for Download
Phase 3 closes the loop: it organizes everything into folders and packages the complete download. Delivery is half the work—a package well organized is what makes the client feel they paid for something serious.
// output/{empresa-slug}/ — the delivered structure
output/stripe/ ├── markdown/ # 15 .md (os entregáveis) ├── presentations/ # 2 .pptx (resumo + achados) ├── documents/ # 2 .docx (relatório + SOW) ├── mermaid_images/ # PNGs dos diagramas ├── research_cache.json └── state.json
markdown/, internal knowledge.💡 Minimal input, maximum output—closed
Two text boxes went in at the beginning; now a folder with 19 professional deliverables comes out for less than US$1. This is the complete Factory cycle—and what you take to Track 5, where it becomes an offer and ends up in the client’s hands.
organized
md+pptx+docx
one click
the entire cycle
✅ Module summary
🎯 Mission 4.3 — The end-to-end Factory + diagrams
Run the full pipeline for the company from the previous missions and generate the current-state vs. future-state diagrams.
- Ask Claude Code to run the Factory end to end (Research → Synthesis → Generation).
- If the context fills up, start a new session and use
resume "Empresa"— confirm that it skipped what was already done. - Open the
state.jsonand see all the phases incompletee ototal_cost. - Render the diagrams (renderer,
beautiful-mermaidor eraser.io) and check the PNGs inmermaid_images/.
Success: the folder output/{empresa}/ with all 19 deliverables and rendered diagrams, for < US$1. What you gained: the Factory running end to end — the engine Track 5 turns into an offering and takes to the client.
Next track:
Track 5 · From the Factory to the Client — package it with your brand, position it, price it, and close the sale (capstone).