01 · Before and afterThe pattern
// before: page clipped to fit the prompt, model output overwrites the file
prompt.push(block('existing-page', page.slice(0, 30_000)));
// after: refuse rather than truncate
if (page.length > MAX_CHARS) throw new Error(`${path}: too large to rewrite safely`);
prompt.push(block('existing-page', page));02 · Run it on your appThe check
In any job where an LLM rewrites a file, can the input ever be shorter than the file it replaces?
If the honest answer is no or not sure, this is worth a look before it reaches production.