When one file isn't enough
Growing past a single file without losing the thread.
Single-file projects are wonderful, and they work for longer than people expect. The trouble starts somewhere past a few hundred lines: you scroll to find things, the model starts rewriting parts you did not ask about, and pasting the whole file into a chat costs more context than the question is worth.
Split by what changes together
The bad split is by technical type — all the helpers here, all the constants there. It looks tidy and means every change touches four files.
The good split is by reason to change. Everything about payments in one place, everything about the layout in another. Then a change to how you take payments is one file open, one file to paste, one file to review.
Don't split too early
Three hundred lines that you can read top to bottom beats eight files you have to hold in your head simultaneously. The point to split is when you are scrolling to find things or when a file has clearly become two subjects, not when it hits an arbitrary line count.
This file is <n> lines: <paste> Should I split it, honestly? If not, say so and tell me what would change your mind. If yes: propose the fewest files that fix the problem. For each — the name, what moves in, what it exports. Plan only, no code yet.
Tell the model about the shape
Once you have several files, the model's biggest handicap is not knowing what it cannot see. Every request should say what exists:
My project: - index.html — the page, loads the two scripts below - storage.js — reads and writes to localStorage, exports load()/save() - render.js — turns a list of items into DOM, exports renderList() I want to change <what>. Which file does it belong in? If it needs a new one, say so. Only show me the changed file, and tell me if any other file needs updating to match.
That last line prevents the most common multi-file bug: a function renamed in one place and still called by its old name in another.
Keep a map file
A short comment block at the top of your entry file listing what each file does, kept current, is worth more than any amount of documentation elsewhere. It is the thing you paste at the start of a new chat, and the thing you read when you come back after two weeks.
If you cannot write that list from memory, that is the signal to stop adding features and go read your own code.