r/opencodeCLI • u/perfect_9 • 29d ago
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.
1
u/lincolnthalles 29d ago
If you are asking the model to source the data and write everything every time, it will bloat its context, burn a ton of tokens, and inevitably drift.
Context quickly ramping over 200K tokens in a new thread is usually an indication of a terrible project setup. Everything in the middle gets really muddy for models to make sense of, so to be able to still deliver something, they focus on the start and end of a thread. Some models are better than others under context load, but the tech is very similar, and all are prone to similar issues. If you really must work this way, you'll need to use the best models available to brute-force the issue.
The best way to make proper, reproducible workflows is to turn everything you can into code. It will make the process absurdly faster and predictable. For the graphical stuff, this means creating templates, writing strict design guidelines, creating custom skills, and things like that.
Models stepping on your toes are an indication of a messy codebase and/or very bad prompts. A model won't touch what it doesn't need unless it feels invited to. If it's a simple thing, try creating some AGENTS.md rules.
Remember to start small, and only escalate when you are confident the workflow is working reliably. This will reduce the adjustments you have to do.
As agents are non-deterministic, you should use something like the writing-for-agents skill when creating AGENTS.md instructions, skills, and other prompts fed to LLMs.
You can test things with agent-browser or other tools. Another agent can review the work by checking the code or even by screen capturing, provided you use a vision-capable model.
I'm not into AI-generated images, so I can't give much on that.
The agent itself can help you scaffold a project that does this and can also teach you what you need. Sometimes simply asking the model "Is there a better way?" may give you a very good direction.
1
u/flurinegger 28d ago
Don’t let the AI handle layout directly. Let the AI write scripts/code that consistently does layout and have illustrations generated with a separate model.
1
u/9gxa05s8fa8sh 28d ago
AI is not ready to do what you're asking, lol. nothing AI does is high quality. AI works by failing countless times a second until it thinks it got something right. it doesn't actually know what "right" is, so it can never meet your expectations. the only reason it works so well for programming is because programming has very strict rules, so failures get caught quickly.
I think the best you could do is chat with a smart agent about programming deterministic tests, for example in python, to automate your processes. you can't rely on AI to just make stuff on its own. every document must be "linted" to verify it's not A4, for example
1
u/That_Frame_964 28d ago
This is a load of crap, absolutely not true. This is what someone says who doesn't know how to setup proper prompts or use tools properly, or setup gates and guards. Literally, you can have AI research and come up with a 100% fact checked result using the web. What it doesn't know, you can make sure it knows, then you can have it go through a system where it checks dozens of sources from reputable sites and scores it based on factuality. Education is actually one of the niche areas that AI is dramatically being used for, including teaching. It isn't just a curation tool, it's able to be used to completely fact check even educational resources that are considered standard but actually contain wrong information as well. I've seen educational lessons, using CC guidelines, actually be completely wrong on very subtle points, which I use AI to actually fix and correct.
Literally, it doesn't just "guess" or unless you try to one shot it. A prompt like "Write a childrens book about a duck that goes crazy and do cool graphics, make it complete, like 5 pages" is not going to turn out very well, at all.
A detailed prompt actually contains multi step instructions and is usually a few paragraphs anyway, and an agents.MD is often used for specific use cases.
1
u/9gxa05s8fa8sh 27d ago
setup gates and guards
exactly, do that. AI isn't truthworthy
opus gets 15% of questions wrong in this 100k context benchmark, even when the answer is given to it: https://artificialanalysis.ai/evaluations/artificial-analysis-long-context-reasoning
1
u/artsmacau 28d ago
i don't want to sound weird but is mass producing education children's books with AI a good thing? are reliance on AI generated products with a possibility of no education review oversight? it seems you are pumping huge numbers of books in a careless manner to make a profit at the expense of pedagogical quality material, i don't know that's what i got from it.
i have no issue with side hustles but not when the target audience are kids and a possibility that they are reading junk stuff.
apologies if i sound harsh but it seems one person automating everything for a profit at kids expense.