Shamscorner
Go back to articles

Inside Our Software Factory: One Laptop, 16 Days, 237 Merged Pull Requests

How we built a system of AI agents that writes, checks and merges code for হবে নাকি Coffee?, how we run it from an iPhone, what went wrong, and how to build your own.

Six stages of the factory: issue, build, gate, merge, deploy and test

At 2:13 in the morning on November 29, a laptop in Bangladesh picked up a task: add three screens to an iPhone app.

Twenty-four minutes later, an AI agent had finished the code. Our safety rules then stopped it. The change touched files that belong to the factory itself, so a person had to approve it.

At 2:41, a person did. At 2:48, it merged: 13 files and 2,822 new lines.

The app it was building is the remote control for the factory that built it.

This post explains how that works: the product, the design, the numbers, the mistakes, and how to build a small version yourself.

The short version

  • A software factory is a program that takes a list of tasks and turns them into tested, merged code. AI agents write the code. Ordinary code decides what is allowed to happen.
  • Ours builds হবে নাকি Coffee? (Hobe Naki Coffee), a platform that helps creators in Bangladesh get paid.
  • In its first 16 days, 237 pull requests from factory branches merged. A pull request is a proposed change to the code.
  • Our team went from about 10 merges a day to 24.
  • It all ran on one laptop with 16 GB of memory.
  • The hard part was not getting AI to write code. It was deciding when to trust it.

The product: what we built

Many creators in Bangladesh have an audience but no easy way to earn from it. Hobe Naki Coffee gives them one link. Supporters can use that link to pay them in several ways.

A creator can How it works
Receive coffee gifts A supporter sends money counted in coffees. One coffee is ৳20.
Offer a membership One monthly plan. Nothing is charged automatically.
Publish posts Posts can be free, paid or for members only.
Run a shop Includes cash on delivery.
Share their page QR codes, website buttons and alerts for live streams.
Work with a team Each helper gets only the access they need.
Connect an AI tool It can help with the work, but it cannot pay or move money.

The product works in both Bangla and English. A creator can start without a trade license or a tax number. They verify their identity before their first payout.

How the product fits together

The router sends browsers to the public site, creator app, staff admin or guides. AI tools use their own server. The apps share one Supabase backend.

There are ten projects in one repository. Each one can be released on its own. Four choices shape the rest:

  1. One front door. A small router sends each visitor to the right app.
  2. One backend. The apps share one Supabase database, so there is one set of facts.
  3. Strict walls. An app can use shared code, but it can never import backend code. This keeps secret keys out of the browser.
  4. Money history cannot be edited. A wrong entry is fixed with a new, opposite entry. The old one stays.

The websites run on Cloudflare. The public site uses Astro, and the creator app and staff admin use React. Payments go through SSLCOMMERZ, a payment company in Bangladesh.

How we built it

We built the rules first and the robots second:

  • A shared dictionary. Words like “creator”, “gift” and “refund” each have one meaning. People and agents use the same words.
  • Written decisions. The repository holds about 100 short records. Each says what we chose, what we rejected and why.
  • Tests. There are more than 2,800 test files.
  • Skills. These are step-by-step guides for agents, such as how to build a task or review a change.

This foundation mattered more than the choice of AI model. An agent cannot follow a rule that lives only in someone’s head.

Where the product stands today

Hobe Naki Coffee has not fully launched yet. The public site has a waitlist. So this is not a story about revenue or millions of users. We do not have those numbers.

The success so far is in engineering: a small team is building a large product, with careful checks, at a pace it could not reach before.

What is a software factory?

Most people use AI coding tools like a smart typewriter. You ask, watch, correct and repeat. The tool stops when you stop.

A factory works more like a production line. You describe what you want and walk away. The line picks up the work, builds it, inspects it and ships it. It calls you only when it needs a person.

AI assistant Software factory
Who starts the work You, each time The queue
Who checks it You Rules, tests and an AI judge, then you if needed
When it fails You notice It retries, then asks for help
When you sleep It stops It keeps going

How it works, step by step

Eight steps from collecting issues to testing. A person handles triage and risky changes. Bugs found in testing return to the queue.

1. Collect. Once a day, an agent reads error reports, logs and failed builds. It files anything that looks like a new bug.

2. Triage. A person decides whether an issue is real, how serious it is and whether it is ready. This is called triage. Only issues labelled ready-for-agent move on.

3. Queue. The most serious work goes first. The factory skips anything that is blocked or already assigned to a person.

4. Build. One agent gets one issue. It works in its own worktree, which is a separate copy of the code. It writes tests, reviews its work and opens a draft pull request.

5. Gate. Fixed rules and an AI judge decide whether a person must look.

6. Merge lane. Changes merge one at a time, and only after the tests pass.

7. Deploy watch. Each merge goes to a staging site, which is a private copy for testing. If that release fails, the lane stops. Only a fix may go through.

8. QA. An AI tester uses the change as a real person would. A confirmed bug becomes a new issue.

The architecture: boring on purpose

The factory is a Node.js program. macOS restarts it if it crashes. Every 60 seconds it does the same thing: look, decide, act.

The loop reads GitHub, the Mac and your commands into a snapshot. A decide function returns actions. Small adapters carry them out.

The middle box is the key idea. decide is ordinary code. It takes a description of the world and returns a list of actions. It uses no AI and never touches the network.

That makes it easy to test. We can write “the queue has four issues, usage is at 81%” and check that nothing starts. No real agent is needed.

The factory has about 37,500 lines of program code and about 50,500 lines of tests. The tests are the larger half for a reason. This code can merge to our main branch.

The main parts

Part Its job
Agent loop Runs a pass every 60 seconds
Decide function Chooses what happens next
Harness Starts an agent using Claude Code or a second AI tool
Floor Fixed safety rules in code
Judge An AI that reads each change
Merge lane Merges changes one at a time
State file Remembers every task
Command inbox Holds requests from people
Console The web page and API for watching and steering
Heartbeat Alerts us if the factory goes silent

Why AI does not run the loop

We could have let an AI agent run everything in one endless chat. We chose not to. Each wake-up would cost money, and the chat would keep growing. A script can wait for free. It then starts a fresh agent for each job.

Use AI for work that needs judgment. Use ordinary code for work that needs to be right every time.

The gate: how it earns trust

If every change waits for a person, the factory moves at the speed of one tired human. If no change waits, one bad night can break everything.

Our answer has two layers.

Fixed rules come first. An AI judge then clears a change, sends it back to the agent or holds it for a person.

Layer 1: fixed rules

We call these rules the floor. No AI can overrule them. A change always waits for a person if it:

  • edits the factory’s own code;
  • edits build checks, git hooks or agent settings;
  • deletes or renames data in the database;
  • forgets to list the steps a person must do; or
  • contains a file path the factory cannot read.

The first rule matters most. The factory cannot loosen its own rules.

Layer 2: an AI judge

Changes that pass the floor go to a fresh AI judge. It did not write the code. A fast model reads everyday changes. A stronger one reads sensitive or very large changes. It also gives a second opinion before the fast judge can hold a change for a person.

The judge has four possible answers:

  1. No person is needed.
  2. Merge it, then give a person a follow-up step.
  3. Send it back to the agent to fix.
  4. Hold it for a person.

If the answer is unclear, the change does not merge.

One change at a time

Agents build at the same time, but changes merge in a single line. The factory updates the next change with the latest code, runs the tests and merges that exact version.

This sounds slow. But two changes can each work alone and still break when combined. A single line catches that. It also avoids running the tests again and again for changes that keep falling behind.

If you approve a held change, your approval covers that exact version only. If an agent adds a commit, the hold comes back.

The merge lane with one change next to merge, two queued and one held for a person

What happens when things go wrong

Most of the code is not about writing software. It is about failure.

What happened What the factory does
Tests fail Sends the change back and lets the next one go
Two attempts fail Tries once with a stronger model, then asks a person
The agent crashes at once Restarts it without counting a failure
The agent is silent for 30 minutes Restarts it once
The main branch is already broken Files an urgent fix and parks the task
The AI usage limit is near Starts nothing new
A reading cannot be trusted Waits
A release fails Stops the lane and starts a diagnosis
The whole Mac goes offline An outside service alerts us

Notice what most of these share. When the factory is unsure, it does less.

It also asks who caused the failure. An agent should not lose an attempt because GitHub was slow or someone else broke the main branch.

Factory iOS: a factory in your pocket

The factory works all day, but we are not always at a desk. Our web console worked on a phone, but not well enough to use all day. So we built a native iPhone app with SwiftUI, Apple’s toolkit for building screens.

It has five tabs:

  • Needs you: decisions only a person can make.
  • Running: active work, controls, QA, history and charts.
  • Queue: what builds next and what is about to merge.
  • Owner queue: ideas and bugs that still need triage.
  • Chat: conversations with agents, including photos and question cards.

The Needs you screen listing held changes, handed-over tasks and an agent waiting for a reply

How the app works

iPhone screens read a store, which talks to a console server on the Mac over a private network. Commands go to an inbox that the loop reads.

It uses a private network. The Mac is not open to the public internet. The phone reaches it through Tailscale, which links your own devices. You also need a password. Some people can only watch, while others can act.

It updates live. The Mac sends a small “something changed” message, and the app fetches the new state. If the link drops, it retries after 1 second, then 2, then 4, up to 30.

It is honest when offline. It shows the last state it saw, says when that was and turns off every button. It never saves up a tap to run later.

That last rule comes down to one line of Swift:

var canAct: Bool {
    reach == .reachable && hasLoadedLive && overview?.me.canChange == true
}

In plain words: you can act only if the Mac is reachable, the screen is fresh and you have permission.

It leaves requests. A tap does not change the factory directly. It places a small file in an inbox. The loop reads the file and records the result. A request that waits more than 15 minutes usually expires, so an old tap cannot cause a surprise. Stop commands are the exception. They kill the agents right away.

Risky taps are harder. To clear a change that the floor held, you must type its pull request number.

Two practical tricks

It avoids a paid Apple account. An app signed with a free Apple ID stops opening after 7 days. Our Mac reinstalls it over home Wi-Fi once it is 5 days old. It warns us on day 6 if that has not worked.

It stays in step with the server. The app and the server live in one repository. Both test against the same saved examples of server replies. If the server changes shape, a test fails before the app breaks.

The app is about 14,000 lines of Swift, including 366 tests.

The results

Daily merged pull requests from November 1 to December 3. The factory starts on November 18. The busiest day is November 24 with 61.

Nov 1 to 17 Nov 18 to Dec 3
Days 17 16
Pull requests merged 171 391
Average per day 10 24
From factory branches 0 237

The busiest day was November 24, with 61 merges. Of those, 45 came from the factory.

The factory’s own records add more detail:

  • 243 tasks on record, and 227 of them merged.
  • 172 of the 227 merged tasks show one attempt. That is 76%.
  • 68 of the 243 tasks were held for a person at some point. That is 28%.
  • 29 of the 30 releases on record passed. The other had nothing to release.

What these numbers do not prove

  • More merges does not mean more value. A merge can be one word or 7,000 lines.
  • This is a before-and-after view, not an experiment. Other things changed in those weeks too.
  • Some retries are hidden. A manual retry resets the attempt count, so 76% may be a little high.
  • Testing is behind. Only 4 of 148 test tickets had fully passed on December 3. The automatic tester was switched off that day.
  • There was little real-world risk. With no full launch, a missed bug cost us less than it would cost you.

We now write code faster than we can test it as users. That is our next problem.

Six case studies

1. The factory builds its own remote

Two large parts of the iPhone app were built overnight by the factory. The first took 27 minutes of agent time and added 3,126 lines. The second took 24 minutes and added 2,822.

Both were held because they touched the factory’s own test files. A person cleared each one within five minutes of the build ending.

Lesson: a good gate can be strict and still be quick.

2. Most of a support system in one build

We wanted people to message our support staff, and staff needed an inbox to answer them. One pull request added in-app messages and the inbox. The factory then built the rest of the plan as one job: the contact form, help from our chat assistant and cleanup of old requests. That build took just over two hours and succeeded on the first attempt. It changed 107 files and added 7,554 lines.

Lesson: a clear plan lets an agent do large work.

3. Identity checks, on the third try

Creators verify their identity before a payout. We needed a consent box, a record of each time staff open a file, an adults-only rule and deletion of old data.

This took three attempts and changed 99 files.

Lesson: sensitive work takes longer. Plan for retries and do not hide them.

4. A watchman for background jobs

Some jobs move money records or send emails on a schedule. If one quietly stops, nobody sees an error. The factory built a check that raises an alert when a job fails or goes silent. It took two attempts.

Lesson: “no news” is not the same as “good news”.

5. Three fixes for one GitHub limit

GitHub limits how much data you can request each hour, and the factory used it all up. The first fix made fewer requests and waited for the limit to reset. The second found the correct reset time. The third found the strange part: GitHub’s command-line tool had saved the error and kept repeating it after the limit was fine again.

All three merged within a few hours on the same morning.

Lesson: the first fix often reveals the real bug.

6. Deleting our own clever work

Our first AI tester used the staging site through a browser. It could not create old data, stop a service or run a script. About two in five test steps came back untested.

We rebuilt it to test on the local machine with the tools a developer has. That change added 4,160 lines and removed 9,558.

Lesson: a tester needs real tools. Be ready to delete what does not work.

Why build one for yourself?

Small work finally gets done. Typos, contrast problems and small bugs no longer wait behind big features.

You spend time on better questions. You stop asking “how do I write this?” and start asking “what should exist?”

Your standards become real. To let an agent follow a rule, you must write it down. People benefit from that too.

Every change takes the same path. Nobody skips the tests because it is Friday.

It fits your work. Off-the-shelf tools do not know your product, your risks or your words. Your factory can.

It keeps improving. After a large build, our factory runs a short review called a retro. Useful lessons go back into the guides that agents read.

When you should not build one

Wait if any of these is true:

  • Your tests do not catch real bugs.
  • You cannot undo a bad release quickly.
  • Your tasks are vague.
  • You have less than a few hours of ready work a week.
  • A mistake could hurt someone and nobody would review it.

A factory multiplies what you already have. If that is confusion, you get more confusion.

What you can customize

Most settings live in one file. The loop reads it on each pass, so most changes need no restart.

You can change Example
How many agents run Our default is 3. On our 16 GB laptop we use 2.
Which model does each job A cheap one for notes, a strong one for hard fixes
Which AI tool runs Claude Code or a second tool, for each step
Usage limits Stop starting work at 80% of the 5-hour limit
Machine limits Wait if the CPU is over 85% busy
Number of attempts Two normal tries, then a stronger model
Priority Which labels go first
Daily collection What time it runs and how far back it looks
QA power Only comment, or close tickets and file bugs

One setting only works in one direction. You can add to the list of forbidden commands, but you cannot remove the built-in ones. Make your most important safety rules work this way.

The hard parts

Trust. Every rule is a trade. Too strict, and people become the bottleneck. Too loose, and bad code gets in. We have changed our gate several times.

Shared tools. Agents can each have their own copy of the code, but our machine runs only one full local stack of database and services. Agents take turns, and a person always goes first.

Usage limits. AI plans and GitHub both have limits. A factory can reach them while you are asleep.

Knowing if an agent is alive. A running process may be stuck. A growing log may contain only status updates. We look for real actions, such as a tool call or a message.

Two writers, one file. Our stop command could once be undone by the loop saving old data. Now only the loop writes while it is working. Everyone else uses the inbox.

Security. Agents read text that other people wrote, such as error messages. That text could contain harmful instructions. We block dangerous commands, but a block list is a guard rail, not a locked room. An agent with your access can do a lot of what you can do.

If you need stronger safety, use a separate computer or user account. Give it few permissions and keep production passwords off it.

What we learned

1. People should own the start and the risky end. A person decides what is worth building and approves dangerous changes. The factory does the middle.

2. We trusted automatic bug reports too soon. At first, errors from our tracker went straight to the agents. Many were noise. Now a person checks each one first.

3. Do not make a person do the agent’s job. Our first gate held changes for missing tests and browser checks. Most of those now go back to the agent or to QA.

4. Measure the right thing. We once paused work when the Mac’s load number was high. That number misled us, because small background tasks raised it. We switched to real CPU use and free memory.

5. A cage can be too small. We put one AI tool in a strict sandbox, a closed space with no passwords. It kept blocking ordinary work, so we removed it and accepted more risk. That was right for our laptop. It may be wrong for yours.

6. Write down why. We changed our minds often. The decision records let us do that without forgetting what we had already tried.

7. The slow step moves. First it was writing code. Then it was review. Now it is testing. Fix one, and the next appears.

Best practices

  1. Keep decisions in plain code. Let AI do the work, not run the controls.
  2. Fail safe. If something cannot be read, wait.
  3. Protect the factory from itself. Changes to its rules always need a person.
  4. Use a fresh judge. The agent that wrote the code should not approve it.
  5. Give each task its own space. Use one worktree and one branch.
  6. Merge one at a time.
  7. Limit retries. Then ask a person, with a clear reason.
  8. Tie approval to one exact version.
  9. Make stop instant. Everything else can wait a minute.
  10. Save every transcript. You will need it to find out what happened.
  11. Alert on silence as well as on errors.
  12. Run the factory from merged code, never from the folder you are editing.

How to build your own

Do not start with our 37,000 lines. Start with one task and add one step at a time.

Step 1: do one task by hand

Pick a small issue. Make a separate worktree and run an agent without a chat window:

git fetch origin
git worktree add ../task-42 -b task-42 origin/main
cd ../task-42
claude -p "Fix issue #42. Write a test first. Open a draft pull request. Never merge." \
  --permission-mode acceptEdits \
  --allowedTools "Bash(npm test *)" "Bash(git add *)" "Bash(git commit *)" \
    "Bash(git push -u origin task-42)" "Bash(gh issue view *)" "Bash(gh pr create --draft *)" \
  --disallowedTools "Bash(gh pr merge *)" "Bash(git push origin main *)"

Change npm test to your own test command. Repeat this ten times. Each time it fails, improve your instructions or your tests.

Step 2: write the decide function

Keep it free of network calls so you can test it:

export function decide({ mode, slots, running, issues, usagePercent }) {
  if (mode !== 'running') return [{ type: 'wait', why: 'the factory is stopped' }];
  if (usagePercent === null) return [{ type: 'wait', why: 'usage cannot be read' }];
  if (usagePercent >= 80) return [{ type: 'wait', why: `usage is at ${usagePercent}%` }];

  const free = slots - running.length;
  return issues
    .filter((issue) => !running.includes(issue.number) && !issue.assigned)
    .sort((a, b) => a.priority - b.priority || a.number - b.number)
    .slice(0, Math.max(0, free))
    .map((issue) => ({ type: 'start', issue: issue.number }));
}

Step 3: add the loop

Every minute, read the world, call decide and carry out the actions. Start with one agent. Save the state to a file. Add a stop command before anything else.

Step 4: add the floor

Do this before you automate any merge:

const NEVER_WITHOUT_A_PERSON = [
  { why: 'changes the factory itself', test: (path) => path.startsWith('factory/') },
  { why: 'changes the build checks', test: (path) => path.startsWith('.github/workflows/') },
];
const DESTROYS_DATA = /\bdrop\s+(table|column)\b|\btruncate\b|\brename\s+(to|column)\b/i;

export function floor(files) {
  const reasons = [];
  for (const { path, added } of files) {
    for (const rule of NEVER_WITHOUT_A_PERSON) {
      if (rule.test(path)) reasons.push(`${path}: ${rule.why}`);
    }
    if (path.endsWith('.sql') && DESTROYS_DATA.test(added)) {
      reasons.push(`${path}: deletes or renames data`);
    }
  }
  return reasons; // any reason at all means: hold for a person
}

This is a starting point. Add your own risky areas, such as payments, sign-in and private data. Check the old path too when a file is renamed.

Step 5: add the judge, but do not let it act

Ask a fresh agent whether a person is needed. For two weeks, only write down its answer while you keep reviewing everything. Compare its answers with yours.

Step 6: let it merge the safest work

Start with documents or small text changes. Merge one at a time, and only when the tests pass. Allow more as the record improves.

Step 7: watch releases and silence

Stop the lane when a release fails. Use an outside service to alert you when the factory goes quiet.

Step 8: add a screen, then a phone

Start with a command that prints the status. Then build a web page. Build a phone app only if you really steer the factory from your phone.

Stage You are ready for the next one when
By hand 8 of 10 small tasks need no rescue
Loop It runs for a week without getting stuck
Floor and judge The judge never clears something you would have stopped
Merge lane A month passes with no serious mistake
QA and phone Review is no longer your slowest step

These targets are our advice, not an industry standard. Set stricter ones if your mistakes cost more.

Final thought

AI made writing code cheaper. It did not make being right cheaper.

A software factory is a way to spend the time you save on what still needs people: choosing what to build, setting the rules and handling the risky calls.

You do not need a big team to start. Pick one small issue, give it a clear description and let one agent try. Then build the rule that would let you trust it a little more.


Numbers were taken on December 3, 2026, from the project’s git history and the factory’s own records. “Factory branches” are branches named after the issue the factory picked up. Merge counts include only pull requests merged into the main branch.

Ready to turn your backlog into merged pull requests?

Book a 30-minute walkthrough of our autonomous software factory, or send us a work order to discuss your stack.