A repeatable pattern for AI-written descriptions, summaries, specs and FAQs across a directory or catalog — without an API key, an SDK dependency, or a per-token bill.
You have a few hundred (or a few thousand) items, such as products, courses or listings, ideally already sitting in a deliberate classification scheme, and you want good, consistent, AI-written content for each. The reflex is to wire up a model API: get a key, add an SDK, write a worker, watch the token meter. For an on-demand job at this scale, that’s a lot of moving parts and a recurring cost for something you’ll run occasionally.
There’s a simpler shape. If you already work with an AI coding agent in your editor/terminal, that agent is your generator. The “LLM call” is the agent itself, working in-session: no key, no SDK, no billing path in your codebase. The trick is to wrap it in a small, deterministic seam so the output is grounded, validated, and reproducible instead of vibes.
A file holding exactly the rows that need content, and nothing else. The agent never sees a connection string, so it cannot write anywhere.
A local agent reads that file and writes the prose. No per-token cost, and no API key in your codebase.
Nothing is trusted on arrival. Schema, length, banned wording and an originality check gate every row before a single one is written.
The seam is the whole design: the model's output is a FILE, never a write. Everything untrustworthy stops at the validator.
Table of Contents
The seam: export → generate → validate-ingest
Three steps, one direction. Two of them are plain code; the middle one is the agent.
1. Export (code). For each item, assemble a grounded “packet” from your database, and only the fields the generator is allowed to use (the canonical facts, the source text, the real attributes). Write it to a work file. Compute a source_hash over exactly those inputs.
packets/<item-id>.json → { canonical fields, source text, source attributes, source_hash }Code language: HTML, XML (xml)
The packet is a contract: it says “here is everything you may ground on, and nothing else.”
2. Generate (the agent, in-session). The agent reads a packet and applies a versioned spec: a prompt that lives in your repo as a file. The prompt is the spec: it defines the structure that serves search, answer and generative engines, the tone, the word count, the banned phrases, the rules. The agent writes a result file. Because the spec is checked in and versioned, the job is reproducible in the way that matters: same spec, same inputs, same shape of output.
3. Ingest (code). Now the safety net. Run the spec’s rules as code assertions over each result:
- Grounding / no fabrication: every fact in the output must trace back to the packet’s source. If the agent invented a spec value or a feature, the assertion fails and the row is rejected.
- House-style: banned filler phrases, word-count bounds, required fields present, no broken encoding.
- Structure: the right sections, valid JSON, scores in range.
Results that pass get written to your database. Results that fail get rejected or flagged for a regenerate. Generation is never trusted blind — the validators are the contract enforcement.
Generation is never trusted blind; the validators are the contract enforcement.
Why it works
- No dependency, no key, no cost path. Nothing in your codebase imports a model SDK. The generation work is exactly what the agent already does for you.
- The boundaries stay in code, so the system stays replay-safe and diffable. Export, validators, versioning and materiality are all deterministic. Only the prose synthesis is delegated, and the spec makes that part reproducible too.
- It mirrors a clean data pipeline. Export = read; generate = transform; ingest = load with validation. The agent slots into the “intelligent step” that would otherwise be a human or an API worker.
Only the prose synthesis is delegated — everything else stays deterministic code.
The four disciplines that make it trustworthy
- Ground everything. The packet defines the allowed inputs; the validator rejects anything that doesn’t trace to them. This is your defense against hallucinated facts — and, on commercial content, your defense against misleading-advertising liability.
- Validators as code, not faith. Encode the house-style as assertions in the ingest step. If a rule matters, it’s a test, not a hope.
- Materiality via
source_hash. Gate regeneration on a hash of the grounded inputs. If a price or a count changed but the substance didn’t, don’t burn effort rewriting prose. Only regenerate when the inputs that the prose depends on actually changed. - Version the spec. Stamp every generated row with the
spec_versionthat produced it. Bumping the spec (v1 → v2) is a content migration — you regenerate the affected items — never an in-place edit of a spec you’ve already released. That keeps “which rule produced this text?” answerable forever.
Honest limits
- Throughput is hands-on. You’re in the loop per batch; this isn’t a fire-and-forget cron at a million items. It shines at on-demand, hundreds-to-low-thousands scale.
- House-style can drift across a big batch, so the validators (banned words, length, structure) have to be strict. They catch the drift you won’t notice by eye.
- Prose isn’t byte-identical across regenerations. “Same input + spec → same output” holds for the deterministic code, not for the wording. So the
source_hashgates whether to regenerate, not output equality — and you review via validators, not a diff of the prose. - Validators can’t catch everything. Some drafts are grounded, well formed and still wrong. The next section shows which ones, and the comparison after it covers when a batch API or a local model is worth switching to.
What the validators catch, and what only a reread catches
Code checks only test what can be stated as a rule. In a test run on a catalog of 658 online courses, an agent wrote 219 course pages in batches of 20. The checks rejected drafts for words not found in the source, wrong lengths, banned phrasing, sweeping “from X to Y” filler, British spellings and FAQ questions of a forbidden shape. Each rejected draft was rewritten and checked again before it was saved.
Other problems passed every check. They were caught only because the agent reread each draft against its source before saving:
| Problem | Why no check caught it | Example from the test run |
|---|---|---|
| An FAQ answer that names the topic without answering the question | Every word in it is grounded | Four such answers in a single batch, each rewritten before saving |
| A title or summary that promises what the lessons don’t teach | The text matches the source, and the source is wrong | A course called “Concurrency” taught entirely in C++ without saying so |
| Lesson text filed under the wrong lesson title | Both the title and the text are in the source | Two lessons carrying each other’s descriptions |
| Two items that are one course in two editions | Each page is valid on its own | The same lessons sold once for each of two clouds |
| A wrong category | The category came from the source | 18 of the 219 courses, such as electronics filed under artificial intelligence |
One failure had nothing to do with prose. A field written in the wrong place in the result file was dropped by the save step without an error, so five items were reported as saved without it. Reading the saved records back caught it, the same lesson as not treating a success message as confirmation. The save step now refuses any field it doesn’t recognize.
A check can prove every word is grounded; only a reader can tell whether the answer answers the question.
Run batches until one finds nothing new
You can’t know in advance which problems your source data holds, so your list of checks can’t be complete on the first day. Treat the first batches as a survey:
- Write a batch of 20 items spread across categories, not 20 similar ones.
- Log every new kind of problem in a register, with the item that showed it.
- Turn each problem you can state as a rule into a check, or into a warning shown before writing. Keep the rest as written rules for the reread.
- Repeat until a whole batch turns up no new kind of problem.
In the test run, the new problem types per batch went 7, 3, 3, 5, 4, 3, 3, 3, 3 and 2, then 0 in the eleventh batch. That zero is the point at which the register is complete enough to hand to a faster route.
In-session agent or batch API: benefits and limits of each
The model can be the same on both routes. What differs is the loop around it.
| In-session agent | Batch API | |
|---|---|---|
| Judgment per item | Can skip an outdated item, link two editions, or correct a category | Only the choices your prompt allows |
| Context | Can open a related item when a pair looks suspicious | Sees the one prompt you send |
| A failed check | Rewrites the sentence and checks again in the same loop | Needs a retry loop written in code |
| Rereading | Rereads each draft against its source before saving | Only if you add a second review request |
| New kinds of problem | Noticed while working and added to the register the same day | Noticed only when someone reads the output |
| Speed | About an hour per batch of 20 in the test run, one item at a time | Many requests in parallel; most batches finish within an hour |
| Cost | No per-token bill on top of the agent you already use | Billed per token, at a discount for batch requests |
| Setup | Nothing new in your codebase | An API key, a worker, and your data sent to the provider |
What the in-session route gives you: judgment, context and the reread, plus a learning loop that keeps growing your checks. Its limits: it is slow, it needs a running session (it can run unattended overnight, but still one item at a time), and its slips repeat. In the test run, the unanswerable-FAQ slip came back batch after batch despite a written rule against it, so the reread stays necessary however mature the checks get.
What a batch API gives you: throughput, unattended runs and a lower price per request. Anthropic’s Message Batches API, for example, processes requests asynchronously at 50% of the standard cost. Its limits are the rows of the table: anything the in-session agent does by judgment has to be built as code or written into the prompt, or it doesn’t happen at all.
The model can be the same on both routes; what differs is the loop around it.
Decision checklist
- Still finding new kinds of problems? Stay in session.
- A whole batch found nothing new? A batch API becomes a reasonable choice, if you carry the loop over:
- the register written into the prompt as explicit rules, with each item’s warnings passed in;
- a second review request that rereads each draft against its source, for unanswered questions and unsupported claims;
- changes that affect other items (linking editions, skipping an item, moving a category) proposed for approval, never applied by the batch;
- a human reread of a sample, such as one item in twenty, from every run.
- Want the judgment without the API? Keep the in-session route and let it work through the backlog overnight, one item at a time.
Using both: the batch API drafts, the local AI agent decides
Once two stores’ registers stopped finding new kinds of problem, we tried the checklist above for real. The batch API and the local AI agent did not replace each other; each covered what the other can’t. In one week the combination wrote 168 course pages for two stores. Drafting cost about $0.07 a page at batch prices as of November 2026, and no draft had to be held back; the reread’s work was wording, grounding and two grammar rules the drafts had explained wrongly. The loop:
- The session builds the batch. It exports each item’s grounded packet, and the house rules plus the problem register become one shared system prompt, cached so every request reads it at a fraction of the price (how to make that cache hit).
- The batch writes every draft in one run: 83 pages for $5.65 (November 2026).
- The session rereads every draft against its source. It splits the run into groups of about ten and starts one reviewer agent per group, all following one written brief. Reviewers fix wording and grounding and report every judgment instead of making it.
- The session decides the judgments: category moves, notices that link a short course to its full version, and holds.
- The session scans the whole batch for what no single request can see, such as the same image idea repeated across a run.
- The validators run again, and the session saves in groups, each behind a backup.
What each side cannot do, and which side covers it:
| Limit | Seen in our runs | Covered by |
|---|---|---|
| A batch request sees one item | Two listings of one lecture series under different titles went unflagged; padlocks and cafe tables recurred across a run | The session, comparing packets and scanning the batch |
| A batch request cannot look anything up | It could not find a newer-version course to point an outdated one to | The session, searching the catalog |
| A batch request copies examples from its rules | One rule’s example, “not an accredited certification”, turned up in about 15 of 83 drafts with no support in the source | The reread; the rule was fixed before the next run |
| A batch request describes its sources | About one draft in three said “the overview mentions” instead of describing the course | The reread |
| A batch request has no authority | It can only suggest a category; the session decided 61 corrections in one store’s 83 pages | The session |
| The session writes one item at a time | About an hour per 20 pages | The batch: 83 drafts in one run |
| The session’s cost grows with its context | Every step re-sends the conversation, so a long session costs more per item | The batch’s flat price per request; reviewer agents also start fresh, so their cost stays flat |
The checklist held up with two changes. The second review pass works better as reviewer agents inside the session than as a second batch request, because a reviewer can open the related item when a pair looks suspicious. And the human sample became a full reread: with reviewers in parallel, rereading all 83 pages took about seven minutes of waiting.
The batch is a fast, flat-priced writer; the session is the editor who can see across items and look things up.
The split rule stays: a store that shows a new kind of problem goes back to in-session batches until a batch of its own finds nothing new.
The short version
Delegate only the prose synthesis. Keep everything around it — the grounded inputs, the validators, the versioning, the materiality gate — in deterministic code. Then accept that validators only catch what can be stated as a rule: reread each draft against its source, run batches until one finds nothing new, and only then weigh a batch API, carrying the register, a review pass and a sampled reread with it. The two then work best together: the batch drafts, and the session rereads, decides and looks things up.
Frequently Asked Questions
How is this different from just pasting prompts into a chatbot?
The difference is the deterministic seam around the agent. You export a grounded packet (only the fields the generator may use), the agent generates against a versioned prompt checked into your repo, and every result is validated as code on ingest: grounding, house-style, structure. Pasting into a chatbot gives you none of that: no grounding contract, no reproducibility, no automated rejection of a bad row. Here the validators are the contract, not your goodwill.
Does my catalog data leave my machine?
It depends on where your agent’s model runs. Most AI coding agents send what they read, including the packet, to their provider’s servers to generate the text, the same as an API call would. What this pattern removes is the API key, the SDK and the per-token bill in your codebase, not the trip to the provider. If the data must stay on your machine, run a local model, and export only the fields the generator needs either way.
What happens to content already written when I change the prompt?
Nothing, until you decide to regenerate it. Each row carries the spec_version that produced it, so a new version of the prompt is a content migration: you regenerate the items written under the old version and leave the released spec unedited. That keeps every row traceable to the exact rules that wrote it.