How do human programmers develop code? They also don't keep all the code in their head and then dump thousands of lines of code linearly in one go. Instead of feeding whole files, or even whole functions as context we could give the AI a sandboxed shell with an editor (maybe ed?), and a language toolchain with a test framework. Let it do trial and error, get feedback from the terminal when they make mistakes.