Untested but Promising Blueprint for Writing Production-Ready Code with AI Code Generation
What's Lacking / Required:
- Defined processes, practices, and workflows.
- The ability to generate working or easy to debug/fix code.
- The ability to generate working or fixable production-ready code.
- Efficient management of code files with thousands of lines of code (loc).
- Management of file/code history, changes, and context.
Goals:
- A simple workflow to build working/production front end code using AI-generated code. This can serve as a base or experiment upon which others can build solutions for other types of code.
- Generated code must be, as much as possible, working or easy to debug requiring minimal changes to become functional.
This Approach Had Impressive Results in My Experiments (Scalability to a Full Project Needs Testing):
- Passing pseudo-code or a skeleton/template to guide code generation.
- Additionally, providing example code with the desired features and quality as context.
- Generating decoupled code, ideally as a composition of multiple independent modules.
- Debugging and fixing code at the file and module level. For now, without tests (since AI-generated tests would also need to be verified). Use tests if they are written or fixed by a human developer, and for production code.
Generate Production Code in Two Phases:
Phase 1: Base/Prototype
First, we generate a simple, working version of the required component. This version should be easy to understand, reason about, and already in a functional state. It will include the structure, layout, network calls, and state management that will either remain in the final version or serve as the foundation for it.
Phase 2: Production/Final
In the second phase, we use the working, simplified code to generate the final, production-ready version. This includes all enhancements, refinements, bug fixes, and changes necessary for production code.
Design/Requirements -> Base Code -> Production Code
The key is to effectively use pseudo code and skeletons, combined with high-quality context, to enforce quality and constraints at both stages. Maintaining two separate stages, a base stage and a production stage, is crucial.
Also follow the best practices as stated below.
I recently shared the best practices I discovered/found for coding using AI or code generation
https://gist.github.com/ditpoo/fe3d2955f59cee83ae8426fe2c24adcd
This is the experiment mentioned in the post AI to code a production project from scratch.
I'm thinking of coding a chat UI for llm's, there are so many of them so its easy to compare with for quality and output.
The one below is a 3k loc front end, entire code base can be added as context and is of good enough size & complexity to reason, understand and test with.
Fits nicely in the effective 32k context window of most llms/ai model right now.
Lastly why I'm sharing this and not building the next cursor or co-piolt myself, because its for big players and there is no real moat and no viability cost wise. But someone else can try their luck though.