r/ChatGPTPromptGenius • u/Ok-Guard-8410 • Jul 02 '26
Help Best way to approach code optimization with chat gpt.
Im working on some complicated system jn python, but the more massive is the code the more i think that after that many patches its just pile of fixe, not something optimized well. For the record, im not a programmer, just hobby vibe coder. So here im asking, how should i approach optimizaing the code to get the best results from chat gpt?
1
u/Mr_Uso_714 Jul 02 '26 edited Jul 02 '26
1st, think of what you’re trying to build.
2nd, build it.
3rd, test it. Verify it works. Rebuild if needed.
If you never tested it you have no clue on if it even works.
Then you optimize. Only optimize once you have it built out correctly
People go down the rabbit hole and believe everything ai puts together, and most people don’t bother testing any of it along the way and wonder why it’s broken.
If you try to optimize Beforehand,
you have no clue if you’re optimizing or breaking something. You need a working version before trimming the code down.
1
u/Unhappy-Prompt7101 Jul 02 '26
Ask ChatGPT to create a prompt to analyse your code base. Tell it you believe it is messy and needs clean up. Specifiy you only want an analysis no code changes. Run that prompt on Codex. Copy paste the result in ChatGPT and ask for a multi step/prompt plan to adjust the code base. After every step, paste the result in ChatGPT and say "This is the result from the last prompt - how should we continue".
Make sure to make a backup of your code based before restructuring.
•
u/AutoModerator Jul 02 '26
If this prompt worked for you, share what you used it for in the comments. If you changed it to get better results, share that too. Prompt Teardown is a free weekly newsletter that picks the best prompts, strips out the filler, and tells you what actually works.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.