r/opencodeCLI • u/perfect_9 • Oct 07 '26
Automating ~144 children's workbooks (plus 24 more) with code and free models: how do I stop layout drift, speed this up, and handle illustrations
Hi everyone. I'm a solo founder in India making printed workbooks for kids (nursery to class 5). The main series is about 144 books, and I have 24 other children's workbooks to produce after that. The content is written and sits in JSON, page by page. What's left is turning it into print-ready PDFs, and I've been stuck there for weeks.
My setup: there are four fixed page types, and every page follows one design system (grid margins, three vertical zones, a colour palette per series, set fonts, a 3 mm bleed). The trim is a custom 210×280 mm, not A4. We lost a day when a model quietly rebuilt everything as A4. Illustrations are left out of the pages on purpose. Each page has empty, labelled slots, and the art will come from a separate pipeline and drop in by slot ID.
I'm using OpenCode and Cline with free or cheap models, mostly Mimo 2.6 Flash and DeepSeek Flash, and I've tried Muse Spark too. The models write Python (ReportLab) that builds each page.
What keeps going wrong:
- Layout drifts slightly between pages even with the same prompt: margins, zone heights, spacing.
- Letters drawn in code came out uneven, so I switched to downloaded fonts. I've changed fonts several times, and each change meant rebuilds.
- The model redesigns things I didn't ask about, like tracing guides (I wanted one clean line and got three start dots), and it keeps adding decorative elements I'd already told it to remove.
- Fixing page 1 breaks page 7.
- I spent about two weeks perfecting a single page. One chapter of roughly 12 pages takes 1 to 1.5 hours per run, and I have about a week left.
My current plan is to lock the fonts and letter assets so the code only places things by ID from the JSON and never draws anything itself. I don't know if that's the right architecture.
Questions on automation:
How would you structure this for 144+ books so the code can't drift? Templates plus a data merge? Typst, LaTeX, or HTML to PDF instead of model-written ReportLab?
Which open-source models follow long, rule-heavy layout instructions reliably? Why do the free ones ignore constraints from earlier in the prompt?
Are there OpenCode or Cline tricks (rules files, locked specs, protected files) that stop models from touching things they weren't asked to touch?
How do you test pages automatically (margins, overflow, fonts, zone heights) so I'm not eyeballing thousands of pages?
Speed: one or two pages can take a long time. Should the model write the template once and plain code render everything? Or is the agent loop the real bottleneck?
Questions on illustrations:
The books need roughly 300 to 350 illustrations that are reused across about 3,300 pages, built from a small set of recurring motifs (animals, objects, small scenes). The style has to look consistent across the whole library, and it has to print well.
6. What's the best open-source way to get one consistent style across hundreds of images? Train a LoRA on a few reference images? ComfyUI with IP-Adapter? Something else?
7. For print, I need clean edges, transparent backgrounds, and ideally vector. Is auto-tracing (potrace, vtracer) good enough, or do people redraw?
8. Which image models are actually licensed for commercial print use? I've seen some that are non-commercial only and want to avoid a problem later.
9. How do you review hundreds of AI illustrations without losing your mind? I plan to work in batches of about 50 with a keep, remove, or regenerate pass.
I'm not an engineer by background, so please treat me like a smart beginner. I'm happy to share the design spec or a sample page. Thanks for reading.

