Sub topic 11
Run all formats as one batch workflow
This chapter turns the pieces from earlier chapters into one repeatable run. You give it a source asset, a core message, and a brand voice. It returns a reviewed-ready set of drafts for every format you chose.
It assumes you already have these pieces:
- A core message and a list of key claims extracted from the source.
- A brand voice written as reusable instructions.
- A format spec for each channel (length, structure, audience).
- A prompt that combines them and tells the model to use only facts from the source.
- Basic Python. The examples use only the standard library.
Why batch the work
Running formats one at a time by hand causes three problems.
- Drift. You tweak the prompt for the LinkedIn post, forget to carry the tweak to the newsletter, and the two formats start to disagree on the core message.
- Skipped checks. Under time pressure, the number check or the word count gets skipped for the last format.
- No record. Nobody can say which source version or prompt produced a draft that is now live.
A batch workflow fixes this by making the inputs explicit and the steps identical for every format. One source goes in. Every format gets the same prompt template, the same checks, and the same "needs review" status.
The shape of the workflow
The loop is automated. The review step is not. No draft skips the queue, whatever its automatic checks say.
Step 1: Define formats as data
Each format is a small spec, not a hand-written prompt. Adding a format means adding one line to a list, not writing new code.
from dataclasses import dataclass
@dataclass
class FormatSpec:
name: str
max_words: int
structure: str
FORMATS = [
FormatSpec("linkedin_post", 200, "Hook line, three short paragraphs, one closing question"),
FormatSpec("email_newsletter", 250, "Subject line, two-sentence intro, three bullets, one call to action"),
FormatSpec("video_script_60s", 150, "Hook in the first 5 seconds, three beats, spoken call to action"),
]Keep specs in one place. If the team changes the newsletter structure, the change applies to every future run.
Step 2: Build one prompt per format
A single function builds every prompt. Only the spec changes between calls.
def build_prompt(source: str, core_message: str, voice: str, spec: FormatSpec) -> str:
return (
f"Rewrite the source material as a {spec.name}.\n"
f"Core message: {core_message}\n"
f"Brand voice: {voice}\n"
f"Length: at most {spec.max_words} words.\n"
f"Structure: {spec.structure}.\n"
"Use only facts, numbers, and claims that appear in the source. "
"If something is not in the source, leave it out.\n\n"
f"<source>\n{source}\n</source>"
)Two details matter here:
- The source sits inside
<source>tags, so the model can tell the material from the instructions. - The fidelity rule appears in every prompt, in the same words. It does not depend on someone remembering to add it.
Step 3: Add automatic checks
Automatic checks are cheap and catch the most common problems. They do not prove a draft is correct. They tell the reviewer where to look first.
The first check lists numbers in the draft that never appear in the source. Invented statistics are a common failure, so these numbers deserve a human look.
import re
def numbers_in(text: str) -> set[str]:
return set(re.findall(r"\d+(?:[.,]\d+)*%?", text))
def unsupported_numbers(source: str, draft: str) -> list[str]:
return sorted(numbers_in(draft) - numbers_in(source))The second check is the word count, which is len(draft.split()). You compare it against the spec's max_words.
Step 4: Put the loop together
The loop calls the model for each spec, attaches the checks, and marks everything needs_review. The model call is a placeholder because the provider is your choice.
def call_model(prompt: str) -> str:
raise NotImplementedError("Replace with your model provider's client call")
def repurpose(source: str, core_message: str, voice: str, formats: list[FormatSpec]) -> dict:
results = {}
for spec in formats:
draft = call_model(build_prompt(source, core_message, voice, spec))
results[spec.name] = {
"draft": draft,
"word_count": len(draft.split()),
"unsupported_numbers": unsupported_numbers(source, draft),
"status": "needs_review",
}
return resultsThe status is set in code, not by the model and not by the checks. Nothing in this function can mark a draft approved. That is deliberate. Approval belongs to a person.
Testing the loop without a model
Before you connect a provider, test the loop with a fake model. This confirms the plumbing works and shows what the checks report.
def fake_model(prompt: str) -> str:
return "Our webinar drew 480 attendees and 92% rated it useful. Join the next one."
call_model = fake_model
source = "The webinar had 480 attendees. Feedback was positive."
results = repurpose(source, "Webinars build trust", "Plain and friendly", FORMATS)
for name, r in results.items():
print(name, r["word_count"], r["unsupported_numbers"], r["status"])Because repurpose looks up call_model at call time, reassigning the name swaps in the fake. Every format reports ['92%'] as unsupported, since the source never mentions 92%. This is exactly what the check is for.
Edge cases and failure modes
One format fails
A model call can time out or return an error. In the basic loop, one failure ends the whole run and you lose the drafts already produced. Catch the error per format and record it.
def repurpose_safe(source, core_message, voice, formats):
results = {}
for spec in formats:
try:
draft = call_model(build_prompt(source, core_message, voice, spec))
except Exception as exc:
results[spec.name] = {"status": "failed", "error": str(exc)}
continue
results[spec.name] = {
"draft": draft,
"word_count": len(draft.split()),
"unsupported_numbers": unsupported_numbers(source, draft),
"status": "needs_review",
}
return resultsA failed format then shows up in the report instead of silently missing. You can rerun only the failed specs.
The number check has limits
The check compares text patterns, so it misses and over-reports in predictable ways.
| Situation | What the check does | What to do |
|---|---|---|
| Source says "1,200", draft says "1200" | Flags it as unsupported | Reviewer confirms it is the same number |
| Source says "three", draft says "3" | Flags it, because words are not matched | Reviewer confirms |
| Draft invents a claim with no numbers | Reports nothing | Reviewer checks claims against the key claims list |
| Draft computes "up 50%" from two source numbers | Flags 50% | Reviewer checks the arithmetic |
A clean report means "no invented digits." It does not mean "all claims are true."
Length overruns
Models often exceed word limits slightly. Compare word_count to spec.max_words and flag overruns. Decide in advance whether you reject, retry once with a shorter limit, or leave the trim to the editor. Pick one rule so every run behaves the same way.
Long sources
If the source is longer than the model's input limit, the call fails or the model ignores the end. Do not paste a truncated transcript. Instead, use the key claims list from the earlier chapter as the source for the prompt, and keep the full text for the number check.
Make runs traceable
Store enough with each run to reproduce it later. A small record is enough.
import json
from datetime import datetime, timezone
def save_run(results: dict, source_id: str, path: str) -> None:
record = {
"source_id": source_id,
"created_at": datetime.now(timezone.utc).isoformat(),
"formats": results,
}
with open(path, "w", encoding="utf-8") as f:
json.dump(record, f, indent=2)Useful fields to add as your process matures: the prompt template version, the model name, and the reviewer's decision. When a published post gets a complaint, this record tells you which source and prompt produced it.
Practical habits
- Run the batch against one format first when you change the core message or voice. Fix problems there before you spend time on all formats.
- Keep the core message and voice identical across the batch. Different wording per format is what causes the drift described at the start.
- Review all formats from the same run together. A reviewer can then see whether the three drafts agree with each other.
- Do not retry silently until the checks pass. A retry that hides a problem still leaves the problem in the draft.
Summary of the workflow
- Prepare the source, core message, and brand voice once.
- Describe each target as a
FormatSpec. - Build a prompt for each spec with one shared function.
- Call the model and attach word count and number checks.
- Record failures per format instead of stopping the run.
- Mark every draft
needs_reviewand save the run record. - Hand the queue to a human reviewer.
Exercise
The loop in repurpose runs and returns three drafts. For one draft, unsupported_numbers is an empty list and the word count is under the limit. A teammate says it can be published without review. Give two reasons the teammate is wrong, and name one change to repurpose_safe that would make a failed model call visible instead of ending the run.
Show answer
First, the number check only compares digit patterns, so it cannot catch an invented claim without numbers, a changed meaning, or an off-brand tone. Second, the workflow sets every draft to needs_review by design, and approval is a human decision. For failures, wrap the model call in try/except and store a result with status "failed" and the error text for that format, then continue the loop so the other formats still finish.
Exercise
Your source says "We trained 1,200 customers." The draft says "We trained 1200 customers and saw a 30% rise in renewals." What does unsupported_numbers return, and which of the returned items is a real problem?
Show answer
It returns ['1200', '30%']. The value 1200 is the same number as 1,200 written without the comma, so it is a false alarm that the reviewer clears. The 30% figure does not appear in the source, so it is a likely invented statistic and must be removed or verified against the source.