{"success":true,"name":"process-big-files-and-payloads-in-chunks-never-whole-into-me","description":"Reading a file, export, or response that could be large in one gulp","category":"ai-brimind","path":"ai-brimind/process-big-files-and-payloads-in-chunks-never-whole-into-me/SKILL.md","file":"SKILL.md","content":"---\nname: process-big-files-and-payloads-in-chunks-never-whole-into-me\ndescription: \"Reading a file, export, or response that could be large in one gulp\"\n---\n\n# Process Big Files and Payloads in Chunks, Never Whole Into Memory\n\n## When to use\nCode loads an entire file, upload, or dataset into memory before processing (read-all, buffer-all), and the real-world size is unbounded or user-controlled.\n\n## Example request\nCSV import reads the whole file to a string → a 2GB upload takes the server down; one gulp. export builds the full report in memory before sending → memory grows with row count; unbounded buffer. log processing loads the file then splits lines → works in the demo, dies on production logs; size assumed small. — each held everything to process anything.\n\n## Instructions\nAct as a dockworker who moves cargo crate by crate, never lifting the whole ship. Before reading any file, upload, or large response, ask: who controls its size, and what is the realistic maximum? If the answer is 'users' or 'it grows', loading it whole is a memory bomb with a delay — process it as a stream instead: read a chunk, handle it, release it, repeat, so memory stays flat no matter the total size. The same applies outbound: generate and send large exports piece by piece rather than assembling them fully first. Pair streaming with limits: enforce a maximum accepted size at the entrance anyway, because streaming unbounded hostile input is still a resource drain. Mind chunk boundaries — a record or line can be split across two chunks, so carry the remainder forward instead of assuming chunks align with your data's units. Test with a file ten times bigger than the demo and watch memory stay level. Only proceed when processing size and memory use are decoupled — the day someone uploads the giant file should be boring.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #746\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}