- Published on
What I learned building a code factory.
We all know that coding is kinda solved, so let's automate it away so we can focus on actual software engineering. That's what I worked on and I learned quite a few interesting things along the way. The main takeaway is that building a code factory gives you an incredible amount of leverage, but it works in both directions.
Basic factory setup
The basic idea that I had in my mind was:
- Let Claude run in the cloud
- Give it a Docker container and stuff so it can verify the changes quickly
- Give it access to the relevant code
And this works pretty well. You don't need to go to super great lengths, because in the end everything is just a loop.
Not dark yet
Human code review still makes sense, so it's not a dark factory. It helps to give the factory access to pipelines, logs and stuff to validate the changes. But you probably want to review at least some changes.
Categorize your code changes
Changing README.md is fine for the factory to do and requires probably very little human review, whereas database and API changes should require human oversight. You should think about changes to which parts of your code are two-way-door changes and easy to revert and which are one-way-door changes and could easily produce an incident. But don't let the reversibility be the only metric: You can easily reverse changes to auth, but user data might be at risk.\
So if you go all out on (dark) factory, think about under what circumstances it should be autonomous.
You just can't trust the AI
Just remember. It's not a lie... if you believe it... George Costanza
It's very easy to think of specs as the natural input for a code factory and it makes sense: You want to have some sort of problem solved and you already have some mental model of the requirements and the implementation, so why not put a spec in?
And that's all cool. But why should you painstakingly find out the requirements, surely the AI can help you.
So you just use AI to generate specs as input. And it looks great! Look at all the edge cases it found. Let's ship it.
But then you look closer and use your domain knowledge and realize that it's not all that great. The spec makes wrong assumptions and actually we should do it slightly differently.
This is all good when you have the knowledge, but terrible if you don't.
The less business context an engineer has, the more closely you should review the spec before implementation.
It's much cheaper to challenge an incorrect assumption in a spec than to discover it after the factory has implemented it, written tests for it and opened a merge request.
You should have an input/spec review before starting implementation
Reviewing code from a business perspective is kinda difficult if you lack the full context, you are then mostly limited to the syntax and architecture.
So it makes sense to share specs early with business context so code reviewers can actually review if it makes sense from a business perspective as well.
Claude can review a lot, but it won't catch business-related errors if you don't give it context to challenge it's assumptions.
Cheaper models might be more expensive
In my experiment, answering simple questions based on code takes Haiku a lot more tokens than Sonnet, so using a cheaper model backfires here.
The important metric should always be cost per successfully completed task, so keep an eye on that before prematurely trying to optimize the costs of your factory.
Along with that: You should have evals
Your factory is a product in itself and you should be able to measure its quality.
It helps to have consistent evals to know which prompt change decreased the quality of the factory. It also helps to figure out if newer models are better and if you need frontier models or you can operate with open-weight ones and for which tasks you need what.
Otherwise, you're just optimizing based on vibes.
Teams bots are terrible
The API is somewhat okay-ish, once you point the models in the right direction for the non-deprecated API. But the whole Azure registration is a huge pain and uploading zip files to Teams sucks.
But the end result is great: Even non-technical people can interact with your factory, start feature requests and ask questions about the code. It unlocks so much value creation for the business side and gives developers so much more time to focus on dev work.
Garbage in, garbage out. Now at industrial scale and super fast
You really gotta watch your input. Building a code factory feels like building a dangerous weapon.
Worst case it goes like this:
- AI generates a specification containing an incorrect assumption
- AI implements the specification correctly
- AI generates tests validating the incorrect assumption
- AI reviews the implementation and approves it
- Everything is green, but the business capability is wrong
Figma has no great MCP server :(
Annoyingly Figma does not support machine-to-machine MCP auth, but only local user auth. We ended up using screenshots as input instead.
Prompting together is great for people development
So how we structured our factory is that people can prompt the factory for stuff. But people have very different prompting styles. By having an environment where you can see the prompts of other people, you can help others get better and teach them. Maybe they need to give more context, maybe they can specify a coding pattern to get the desired result.
What's interesting is that you don't just get insights into how people prompt, but also into how they approach engineering problems.
In some ways, collaborative prompting feels like a new form of pair programming.
Don't waste human capacity
Human time and review capacity are now the most expensive resource that you have. Don't spend it on stuff the factory could've fixed. You need to have AI-assisted code review and need to feed that back to the factory so that it can fix easy bugs. The goal should be that a review agent has reviewed the code (ideally a different model) and the first-pass fixes have been implemented before a human is tasked to look at it.
You also need to make sure the AI can test code changes really well, be it with Docker containers or in a staging environment.
Your factory is only as fast as your product discovery
You gotta have a good pipeline for new product ideas or otherwise your factory is gonna grind to a halt. Of course, the goal isn't to keep the factory busy. Building stuff just because building stuff has become cheap is probably a terrible product strategy. But still, you need to think about your product side.
Before coding was the bottleneck, so we could afford long discovery, designing and planning phases. But with faster code delivery, thinking about what to build can now take a lot longer than actually building it.
So you need to talk with your product side as well and think about how to support them. Maybe you can give them access to the factory so they can prototype new features easily?
Engineering skills
You'll need curious engineers watching the factory output. You need engineers who want to understand why and how something works, not just that the pipeline is green and the ticket can be moved to done.
It's very dangerous because you feel the engineers are empowered and moving so fast, but they are not growing because they lack the hands-on experience.
One of the dangers of a code factory is that engineers can become significantly more productive without actually becoming better engineers.
Previously, implementing a feature forced you to engage with the architecture, understand the domain and thoroughly think through all the ugly edge cases. Now much of that experience can be delegated away. If the AI can suggest you a spec with 3 edge cases, the engineers might feel like they covered all, when they might've missed one they would've caught when thinking deeply about the problem.
If engineers stop developing the skills needed to challenge the factory's output, you'll eventually have people reviewing software they could neither have built nor properly evaluated themselves.
Good engineering practices compound
As with all AI before, it helps to use good engineering practices. Add architecture tests, make sure your test pyramid is actually a pyramid. Code that is easy to work with for humans is also great for agents.
With great leverage comes great responsibility
Building a code factory was not super difficult from a software perspective. But the changes and challenges it produces on the people and organization side are surprisingly big and harder to solve.
The factory amplifies what you put in, so you gotta spend a lot more time in discovery and specification of features now.
Coding is solved. Software engineering got a lot more interesting.