Best way is to create as much context as you can for your project. Agents do it by prompting you again and but still get lost.

My Solution: A python script that generates code with custom prompts and chaining in following order:

User prompt -> Functional doc -> Technical doc -> Backend code -> Frontend code

Using this approach the script forces the AI to document and save all of its assumptions and code decisions. To increase its accuracy it uses custom prompts and also adds on output of previous steps as context to generate response for next step. Its open source and free available here :- https://github.com/vivek100/oneShotCodeGen

Link to two projects generated via this script: https://github.com/vivek100/oneShotCodeGen/tree/main/example...

PS: This can still make errors, happy to take suggestions on how to improve it.

  • weebhek 12 hours ago |
    How to make the most of this script: ( At least what has helped me in getting high quality code in one go)

    Step 1 : Start the script with a simple prompt like "Create an expense management tool" and it will set up the whole project with relevant functional requirements doc, technical implementation doc, database setup, backend code and frontend code. It will even install all the dependencies and place the code in relevant folder

    Step 2: Open generated code folder in cursor, ask it to read all the files and then start making changes. Works like a charm mostly :P.

  • handfuloflight 12 hours ago |
    Any examples of these one shot generated projects? Github repo?