Plain and simple: Feed the code it produced back into it and ask it to modify the sections needing maintenance or changes, or just tell it the issues you're having and ask it to explain/debug them.
Be careful! I have been experimenting with just this approach and ChatGPT 4 often forgets important parts of the code when generating the new files. If you ask ChatGPT to break down every change into step-by-step changes with code examples, it does a really great job and you can check every change yourself before implementing it.
A good prompt is key. If pasting code make sure to run it through the tokenizer first to make sure itβs not too long. Be very descriptive about what you want it to do. If it goes off the rails just hit the stop button and then edit your prompt with the little edit button at the top right and try again, this saves on context length and it saves the previous prompt and response so you can switch between them and compare.
IMO, the problem is that it doesn't work. It could introduce other bugs, make incorrect changes, or mess up the code. If a good developer does this, it converges, with GPT I am not so sure.
We need to find a way for the system to iterate, debug, write unit tests, and repeat the loop. In theory it's doable, but we are yet to see the system which does this.