Original Reddit post

I spent a while fighting LLM drift on branded documents (Word, PowerPoint, Excel) and landed on a pattern that generalizes well beyond docs, so I’m sharing it. The problem: hand an LLM a reference file and say “follow this exactly,” and it doesn’t follow, it imitates. Imitation is lossy by definition. Fonts drift, the palette wanders, the structure (cover, table of contents, body order) collapses, and the model invents styling that was never in the file. More prompting doesn’t help, because the failure is structural: the brand only lives in the context window, and the model is free to emit any literal value it likes. The pattern that worked, “the model proposes, a deterministic layer disposes”: Split verifiable facts from interpretation. Parse the file deterministically for the ground truth a model can’t hallucinate (in OOXML: real named styles, theme colors, layouts, named ranges, exact child order). Let the model annotate meaning on top (what’s a cover, what’s body, how captions work), but only as a proposal. Never let the model emit load-bearing literals. The generator never writes a font name or a hex. Those come only from the parsed facts. The model picks which role to apply; the engine resolves that role to an artifact that provably exists. Fail closed. A verify step refuses to run if any role points at a style, layout or range the file doesn’t actually contain. A wrong fill is recoverable, a silently invented value is not. The effect: off-brand output stops being a probability you fight and becomes a state the system can’t reach. The same shape applies to any task where an LLM must respect a hard ground truth (schemas, APIs, configs): extract facts deterministically, let the model reason on top, gate the output against the facts. I packaged this as an open-source skill for Claude Code / Codex covering all three formats (MIT, still alpha: Word is solid end-to-end, PowerPoint and Excel share the engine). Repo if it’s useful: https://github.com/ferdinandobons/brand-docs For people building agents: where do you draw the line between “let the model decide” and “the deterministic layer decides,” and how do you gate output against ground truth? submitted by /u/Ambitious-Pie-7827

Originally posted by u/Ambitious-Pie-7827 on r/ClaudeCode