Generated code spreads because nothing tells the next prompt where the module ends. A file that exports every function is a hallway. The following change will call the helper you meant to keep private, and then you cannot change the helper without updating strangers. The diagram on this article is the correction: neighbors enter through one public edge, and the interior stays interior.
Name the door before you name the rooms
Write the public surface in the prompt, in the language’s ordinary terms. Two functions, or one type and two methods. Say what they take and what they return. Say, in the same breath, what other files must not import. “Callers may use parse and save. They may not import the cache or the retry.” If you cannot say that yet, you do not have a module. You have a folder of ideas, and you should not ask a model to fill it.
Make the privacy real
A comment that says “internal” is not a boundary. Use the feature the language already has: an unexported function, a package that is not part of the public module, a file that no route includes. Then try to misuse it. If a one-line import from a neighboring package can reach the cache, the diagram is a wish. Close that path before you add behavior. It is cheaper to close an unused door than to migrate callers off a helper they found.
What may sit inside
Cache, retry, logging details, and the shape of a private record can change without a caller noticing, so they belong inside. The moment a caller needs to configure them, you have a new public decision, and it should be a small argument on the existing door or a new function you add on purpose. Do not promote the private function to public because a prompt found it convenient. Convenience is how hallways form.
Tell the next prompt about the door
Paste the public surface at the start of the next chat, and repeat the import ban. A model that has not been shown the edge will treat every symbol it can see as available. After the diff, pass one of the review is still the file list: if a caller outside the module changed, either the public edge changed for a reason you can write down, or the change crossed a wall and should be reverted.
