Cookie Cutter Vibe Coding
Combining deterministic templates with vibe coding to spend less tokens and get more accurate results
As I wrote about in this post, AI is non-deterministic. That means you’re not going to get the same result every time from the exact same prompt. You can ask your AI chatbot to build the same program you did yesterday and you might see it going down the wrong path one day even though it did it correctly the day before. You can spend a lot of time - and tokens - getting the same things right over and over again.
There’s no sense to that approach. Once you get something working and tested and prove it is correct - think about how you can use it as a template to start with on your next similar project.
A Lambda Function Template Example
Here’s an example. I’m building a lot of Lambda functions right now. Every time I build a new function I have to set up a certain amount of architecture to go along with that. Once I got one Lambda function working, I created a new project with a template for a Lambda function that has all the code to create the necessary resources. The template creates a placeholder function that prints, “Put your code here.” It has scripts to deploy the Lambda function, CloudWatch log group, and IAM resources.
In addition to my Lambda template project I have some deterministic code I use to create new projects consistently. When that code executes (no AI) it asks if the new project is for a Lambda function. Yes? Then copy the Lambda template code into the new project.
Now my new project already has all the code to deploy a Lambda function and I know it works. I don’t have to spend tokens to recreate all that same code over and over and troubleshoot it. It works. It’s the same code that I wrote before. It is deterministic. The same inputs always produce the same outputs. I get consistent results, unlike creating that code with an AI model, which tries to predict what I might want and may or may not be correct.
Once I have my new projects set up from a template, I launch a custom Kiro CLI agent to modify that code. The agent is executed by a Linux user that only has permission to work in that specific project folder.
At that point, I prompt Kiro CLI to modify my README.md to put the specific information for the Lambda function I’m building into the README. First I tell it to modify the project summary. Then I tell it to modify the section that describes the Lambda code, configuration, and what the function should do.
I explained how I use README.md files with Kiro CLI here with a Summary at the top, rules to follow, and a list of requirements with a particular numbering format.
Once I’ve got the README.md set up I can just tell Kiro to read the README.md file and then update the Lambda function code to implement the requirements in section X where X is the number of the section that contains the requirements I just added. I also tell it to follow all the rules and not to change anything else.
This method is working pretty well for me. AI models tend to do better with smaller tasks so using them to build Lambda functions is a good target project size. In addition, when the model makes some change that breaks everything you can tell it to refer to the original template project to fix the problem. It can go back and reference the original code to get back to a working state.
AI models will never produce consistent results alone due to the way they technically work. However, combined with deterministic code and processes you can get fairly reliable and less expensive results.
Subscribe for more posts like this and follow Good Vibes.
— Teri Radichel


