AI software factory best practices: better software, fewer wasted tokens
· 11 min read · by EndorphinLab, the makers of ULU
The best practices for an AI software factory come down to one rule: catch a wrong turn while it is cheap. Plan what is hard to change, let tools check what can be measured, give AI agents a memory, and read what is risky. Each avoided rebuild saves tokens, and the software stays easier to change. Here are twelve practices, the measurements behind them, and how ULU runs many of them for you.
- The cheapest tokens are the ones you don't spend rebuilding the wrong thing.
- In one of our own team runs, about 95% of the tokens were the same instructions sent again on every call.
- In our tests ULU Brain made agents 35% cheaper on questions about callers, tests and the effect of a change, and saved nothing on simple lookups.
- In a benchmark of 15 AI coding agents, quality prompts raised cost by 12.1% per step on average and did not slow the decline in code quality.
- ULU is a ready AI software factory for your computer: AI agents, approvals, checks, memory and the cost of every step. Install ULU.
Where an AI software factory wastes tokens
An AI software factory is a line of AI agents that plan, build, test and ship software, with checks between them. Every call they make costs tokens. Four things make that bill bigger than it needs to be.
| Waste | Why it happens | What helps |
|---|---|---|
| Rebuilding | The agents built the wrong thing well | A reviewed plan and an approval before the build |
| Repeated instructions | Everything an agent carries is sent on every call | Short skills, and prompts that stay in cache |
| Searching again | Each agent learns the project from nothing | A project memory |
| Loops and retries | An agent misuses a tool or cannot see its failure | Clear tool instructions, real tests, cost in view |
In our measurements a token sent for the first time cost about 40 times what the same token cost from cache. ULU Brain made agents 35% cheaper on the questions it is built for (nine tasks on three open-source projects, three runs each, with the Claude Sonnet model). It saved nothing on simple lookups and small edits. The method and every number are in how to save tokens with AI coding agents.
What the research says about AI code quality
Most coding benchmarks give an agent the whole problem at once. Real software grows one feature after another, and early choices make later ones easy or hard. SlopCodeBench tests that. Agents build a first version and then extend their own code through a series of changing specifications: 36 problems with 196 checkpoints.
It tracks two things. Verbosity is the share of lines that are wasteful or duplicated. Structural erosion is how much of the program's complexity sits in functions that are already too complex. These figures are from the second version of the paper, from May 2026.
| What was measured | Result |
|---|---|
| Problems fully solved, start to finish | None, by any of 15 agents |
| Checkpoints passed by the best agent | 14.8% |
| Sequences where structural erosion rose | 77% |
| Sequences where verbosity rose | 75.5% |
| Average number of highly complex functions, from start to end | 3.6 to 23.7 |
| Verbosity compared with 473 open-source Python repositories | 2.3 times higher |
| Erosion compared with the same repositories | 2.0 times higher |
Better prompts cost more and help once
The researchers also told agents to write better code, or to plan first. The first version came out cleaner. After that, the code degraded at the same rate. On average the prompts raised the cost per checkpoint by 12.1% and lowered correctness by 2.3 percentage points.
Read it with its limits in mind. The agents worked without a person steering them, could not see the hidden tests, and newer models will score differently. It does not show that a team with reviews and enforced rules gets the same decline. It does show what happens by default, and that a sentence in a prompt does not change the direction.
Twelve AI software factory best practices
1. Decide how much planning the change deserves
Two questions settle it: how likely is this to need changing later, and how painful would that be? Planning everything wastes hours, and planning nothing moves those hours into rework.
| Kind of change | If it is wrong | What to do first |
|---|---|---|
| Wording, color, a small fix | Another prompt repairs it | Just ask for it |
| A new screen or an ordinary feature | Some rework | A short plan and a mockup |
| Data model, public API, permissions, payments | Hard to undo, and others depend on it | A written design that a person reviews |
| A test of whether anyone wants it | You delete it | Build it quickly, behind a switch |
2. Think before you ask
Look at the code, the documents and how others solved the problem before you accept a plan. The first draft from a model is an average answer. If you bring no view of your own, you have nothing to compare it with.
3. Agree on pictures, not walls of text
A forty-page specification gets skimmed. A mockup, a table of cases or a diagram of the data gets looked at, and people notice what is wrong with it. Ask the agent for the form that is quickest to check.
4. Keep decisions next to the code
Code shows what was built, but seldom why. If the reasons live in chat threads and private conversations with an AI, the next agent cannot see them and will undo them. Store plans and decisions in the project.
5. Let the agent test what it made
Give it a way to run the program: a browser, screenshots, a command it can call, a simulator. An agent that can see its own failure can fix it before you are involved.
6. Enforce what a tool can check
Limit function complexity, forbid duplicates, reject unused code and swallowed errors, require types. Do it with a linter in your build, so the change fails instead of depending on the agent's memory. Start with the rules that match problems you have really seen, and protect the settings so an agent cannot relax them to get a pass.
7. Automate the start and the return
Two forces shape agent work. Forward pressure starts it: an approved request, a bug report, an alert. Back pressure sends it back: failed tests, lint errors, an AI reviewer's objections. Add forward pressure only as fast as your back pressure can handle, or the factory spends tokens on work that comes back.
8. Work in small changes
A reviewer can hold a small change in mind. Split a large feature into steps that each leave the project working, and stop between them.
9. Read what matters
You may not need to read every line. Choose by stakes: always read security, money, data and the shape of the architecture. For the rest, review the plan, the tests or the running result. AI reviewers and linters are useful and should go first, but they cannot tell you whether this was the right thing to build.
10. Subtract on purpose
Since agents rarely remove anything unasked, make removal a task: merge duplicates, split the function that keeps growing, delete what nothing uses. A person should say which abstraction is wrong. With that direction, agents do the cleaning well.
11. Release behind a switch
A feature flag lets a few people use a change before everybody depends on it. If it does not help them, remove the code as well as the flag.
12. Fix the system, not only the output
When the same fault returns, do not just correct it again. Add a lint rule, a test, a line in the agent's skill or a missing document. Each fix in the system prevents many in the output. Our guide on how to build an AI software factory explains how to log runs and check that such a change worked.
What you can buy and what stays yours
Plan, build, test, review, release carefully, listen to users, repair. Teams worked this way long before agents. What changed is that one step became very fast, so the steps around it now decide the quality.
Many of the pieces can be bought or installed: the agent, the sandbox, the scheduling, the tracking. Verification is the part that stays yours. Only you know what "correct" means for your product and which mistakes your users would not forgive.
When to skip the full AI software factory
A prototype to show an idea, a script you run once, a side project for fun: speed is the point, and polishing would be the waste. The danger is the prototype that quietly becomes the product. Decide in advance which it is. If it is going to stay, plan it again with what you learned, and rebuild the parts that will carry weight.
How to measure an AI software factory
Lines written, pull requests merged and agents running in parallel measure activity. Better questions are:
- What did we ship that people use, and did it help them?
- How long does an ordinary change take now compared with three months ago?
- How often do we rework something within a few weeks of merging it?
- How many tokens and dollars does one accepted change cost?
- Are complexity and duplication rising or falling?
- Can someone on the team explain how this part works?
ULU: an AI software factory with these practices built in
ULU is a desktop app for Claude Code that turns a described project into a team of AI agents. Several of the practices above are part of how a team runs:
- Questions first. It writes a project brief, asks about what is missing, and three reviewers add questions you did not think of.
- Separate roles. Planning, building, review, testing and security are done by different agents, so the builder does not grade its own work.
- Your approval. Every team stops for you on the design and on the release.
- Checks. ULU runs the project's tests and shows the counts, and build checks look for leftover placeholders and missing files.
- Tokens and cost in view. Every step shows its cost, time and context while it runs, so you can stop a step that is going wrong.
- Memory. ULU Brain connects code, tests and history, so an agent can find what already exists. We measured where that helps and where it doesn't.
- Learning. After a run the team proposes changes to its agents and skills, and you choose what to keep.
It cannot guarantee good code. We have not run the benchmark above on ULU teams, so we claim no figure for it. ULU also cannot tell you whether the idea is good. If you don't read code, use your approvals well: try the result yourself, ask what could go wrong, and have a developer look at anything that handles money or personal data.
Questions people ask
What are the best practices for an AI software factory?
Plan what is hard to undo, separate the roles, let agents test their own work, enforce checks with tools, keep a project memory, approve the design and the release, and measure the cost of each accepted change.
How can I reduce AI token usage?
Avoid rebuilding by approving a plan first, keep agent instructions short, keep prompts in cache, and give agents a memory for questions that need searching. Watch the cost per step, so you find your own biggest waste instead of guessing.
How much does an AI software factory cost to run?
It depends on the project, the model and how much is rebuilt. With ULU the agents use your own Claude plan or API key, and every step shows its cost. See what AI agents cost and ULU's prices.
Does ULU save tokens?
On some work. ULU Brain was 35% cheaper in our tests on questions about callers, tests and the effect of a change. On simple lookups and small edits it saved nothing, and ULU no longer asks it there. Your result depends on your project.
Can I use an AI software factory if I don't code?
Yes. ULU is built for people who don't code: you describe the project, approve the design and the release, and try the result. For anything that handles money or personal data, have a developer look too.
Do I have to read all the code AI agents write?
Not all of it. Read, or have someone read, what would be expensive to get wrong, and check the rest through plans, tests and the running result.
Put your AI software factory to work
You can set up these practices one by one, or start with a team that already has the roles, approvals, checks, memory and cost tracking. Install ULU, describe your project, and see what every step costs while your AI agents build it.