# Inside a Software Factory: 8-Stage Line and Anti-Overbuilding Lessons

> Standardize your engineering pipeline with a software factory using an 8-stage assembly line, model tier economics, and LLM wikis.

Source: https://camnangai.com/en/for/developers/inside-a-software-factory  
Published: 2026-11-15

A **software factory** is an automated system of networked agent loops and rigid verification
  harnesses operating over a shared context layer to continuously turn intent and production signals
  into shipped code.

As AI coding tools mature, software engineering is undergoing a fundamental shift away from manual
syntax writing and unstructured "vibe coding."

Instead of guiding an agent turn-by-turn through prompt-by-prompt interactive development, you are moving toward meta-engineering: building the system that builds the product. The focus transitions from reviewing individual code diffs to designing automated development lines, configuring environment harnesses, and setting up strict verification gates.

This guide breaks down the architectural mechanics, economic trade-offs, and operational guardrails required to engineer a reliable software factory at scale.

![Inside a Software Factory: Automated AI software engineering line](https://camnangai.com/articles/ben-trong-nha-may-phan-mem/01-infographic-en.webp)

## From Vibe Coding to the Software Factory: Why Software Engineering Is Becoming Factory Engineering

The software factory concept is not a novel invention of the generative AI era. Its roots trace back to Robert Bemer’s 1968 paper, "The economics of program production," and Hitachi’s establishment of its Software Works in 1969, both of which sought to transform software creation from an isolated craft into a repeatable, instrumented manufacturing process. Modern agentic systems realize this vision by replacing unscripted "vibe coding"—where developers manually prompt models back and forth in an ad-hoc terminal session—with disciplined factory engineering. As industry leaders like Paul Iusztin and Zach Lloyd highlight, software engineering is transitioning into factory engineering, where your primary output is no longer the application code itself, but the automated assembly line that produces it.

To understand this paradigm, you must analyze the architecture through Addy Osmani’s three-tier stack: the loop, the harness, and the factory. The loop is the fundamental atomic unit of agentic work: a single agent executing a continuous cycle of gathering context, taking an action, checking the result, and iterating until a specific completion condition is satisfied. The harness forms the rigid operational environment around that loop, providing the sandbox execution layer, tool integrations, persistent memory, and automated gates that define what "done" means. Finally, the factory represents an entire organizational chart composed of multiple harnessed loops running at scale, fed continuously by a work queue and drained through strict verification and review gates before reaching production.

As teams deploy these assembly lines, an operational tension emerges between "Dark Factories" and "Lit Factories." A dark factory operates completely lights-out: AI agents scope, build, test, and ship pull requests to production without a single human ever reading the code diffs. While dark workflows dramatically boost initial throughput, they rapidly accumulate comprehension debt—the widening, unmonitored gap between the total volume of code in the repository and the human team's actual understanding of the system's internal mechanics. Field experience demonstrates that fully dark workflows inevitably fail within three to four months; when an unhandled edge case or architectural drift breaks the system, the team finds itself drowning in millions of lines of unread code with green test suites but zero mental model of how to fix the failure.

To prevent structural collapse, you must govern your software factory using the principle of back pressure: autonomy cannot expand beyond what can be cheaply and reliably verified. Text generation capacity has become virtually infinite and economically trivial, whereas human review attention remains strictly bounded, expensive, and non-scalable. If your verification bottleneck does not scale alongside your generation volume, unverified pull requests back up, defects proliferate, and codebase quality decays. A lit factory keeps human judgment active upstream during architecture and design, while maintaining targeted review gates to ensure that agent autonomy never exceeds mechanical verification limits.

![The Three-Tier Architecture: Loop, Harness, and Software Factory](https://camnangai.com/articles/ben-trong-nha-may-phan-mem/02-en.webp)

## The 8-Stage Factory Architecture: From Intake to Continuous Production Feedback

A complete software factory standardizes the software development lifecycle into an eight-stage assembly line spanning three operational buckets, anchored by a shared context layer.

### Stage Bucket 1: Intent Definition and Planning

The first phase of the factory determines what to build through three read-only stages. Stage 1 (Triage/Intake) ingests raw incoming work—such as user feedback, bug reports, market signals, and system incidents—classifying, deduplicating, and routing each item. Stage 2 (Brainstorming) processes user activity analytics and competitor data to isolate high-impact feature specifications that solve business problems without dictating implementation details. Stage 3 (Planning) takes those specifications and transforms them into concrete execution plans. During Planning, the agent operates strictly in read-only mode over the codebase, repository instructions, and context layer, allowing you to refine the architectural plan, log Architecture Decision Records (ADRs), update project glossaries, and break work down into explicit, agent-executable tickets.

### Stage Bucket 2: Execution, Verification, and Release

Once the plan is locked, work moves into Stage 4 (Implementing), where a software engineering agent picks up tasks and generates code. Implementation relies on a strictly decoupled loop featuring an isolated software engineering agent writing code and a separate QA agent stress-testing the output. Decoupling these roles is essential because the model that generates the code exhibits a systematic positive bias toward passing its own logic; as Addy Osmani notes, the model that wrote the patch is way too nice when grading its own homework.

Verification continues through Stage 5 (Review), Stage 6 (Review-CI), and Stage 7 (Release). Stage 5 evaluates the generated pull request diff against product specifications, architectural boundary rules, and "AI slop" anti-patterns, such as cryptically named functions or redundant, verbose comments. Stage 6 executes automated CI test suites, where any test failure automatically triggers a dedicated fixing agent to repair the patch. Stage 7 orchestrates continuous deployment to staging and production environments, guarded by explicit human approval controls for high-risk changes to ensure high-stakes systems remain safe.

### Stage Bucket 3: Continuous Operations and Feedback

The final bucket completes the operational cycle through continuous monitoring and automated feedback. Stage 8 (Monitor/Incident Response) captures runtime metrics, application logs, error traces, and production alerts, automatically feeding them back into Stage 1 (Triage) as fresh inputs. Advanced operational implementations, such as Factory.ai’s Droids and Missions architecture, orchestrate complex multi-feature initiatives by validating holistic milestone achievements rather than individual diffs. Similarly, OpenAI's internal production harness demonstrates complete lifecycle autonomy: given an issue prompt, an agent autonomously reproduces the bug, records a video of the failure using Chrome DevTools Protocol, implements the code fix, validates the resolution by driving the application UI, records a verification video, opens a pull request, resolves automated review feedback, and merges the change.

To maintain structural integrity across all eight stages, mechanical architectural linters enforce strict, unidirectional domain dependency chains across the assembly line, ensuring that agents cannot introduce cyclic dependencies or violate system boundaries.

![The 8-Stage Software Factory Assembly Line and Decoupled QA Loop](https://camnangai.com/articles/ben-trong-nha-may-phan-mem/03-en.webp)

```text
# Strict Domain Layering Rules (Enforced by Custom Linters)
Types  -->  Config  -->  Repo  -->  Service  -->  Runtime  -->  UI
  ^
  |--- Cross-cutting Provider Interface (Auth, Telemetry, Flags)
```

## The Context Layer: Powering the Assembly Line with LLM Wikis as Living Memory

Context windows are a scarce operational resource. Attempting to manage an agentic codebase by jamming every rule, coding standard, and domain detail into a single monolithic instruction file (such as a 1,000-page `AGENTS.md`) causes immediate system failure. Monolithic files suffer from context crowding—where critical instructions compete with task-specific code—rapid documentation rot, and an inability to run mechanical verification checks. OpenAI's harness engineering team resolved this by restricting `AGENTS.md` to a strict, ~100-line table of contents map that points agents to structured, modular documentation stored in a dedicated `docs/` repository directory.

To maintain persistent memory without the maintenance overhead of complex vector databases, software factories utilize the LLM Wiki pattern formulated by Andrej Karpathy and formalized in Google's Open Knowledge Format (OKF). Rather than running heavy vector-indexing pipelines or re-parsing raw repositories on every execution, the factory continuously compiles raw notes, transcripts, and source code into plain Markdown wiki files backed by YAML frontmatter. These derivative files synthesize raw input into queryable entities, concepts, cross-repo comparisons, and decision logs, producing an inspectable, human-readable knowledge graph directly within the file system.

The context layer reconciles this knowledge base by co-locating Karpathy's three-tier format directly inside the repository's `docs/` folder alongside structural execution files. Raw source notes reside in `docs/raw/`, generated derivative summaries and entity pages live in `docs/wiki/`, and `docs/index.yaml` acts as the central catalog indexing all metadata, file pointers, and cross-references.

```text
repository-root/
├── AGENTS.md (Table of contents map, ~100 lines)
├── ARCHITECTURE.md
└── docs/
    ├── index.yaml (Central catalog & metadata)
    ├── raw/ (Immutable source materials)
    ├── wiki/ (LLM-generated derivative summaries)
    ├── design-docs/
    ├── exec-plans/ (active/, completed/, tech-debt-tracker.md)
    └── references/
```

Agents query this memory structure using progressive disclosure. When assigned a task, an agent inspects `docs/index.yaml` first to gather low-token metadata. If deeper context is required, it drills into specific `docs/wiki/` summary pages, where the vast majority of queries are resolved. The agent reads immutable source files in `docs/raw/` only as an extreme last resort, minimizing token consumption while maintaining precise retrieval.

To keep global context clean, personal second brains (such as 10,000-note Obsidian vaults) are integrated as read-only, immutable snapshots organized via the PARA method (Projects, Areas, Resources, Archive). Individual software factory runs clone or reference relevant snapshot subsets into project-scoped wikis. This prevents agents from mutating global personal notes while granting them precise, localized domain memory to drive active feature development.

## The Economics of Model Tiers: Why Investing Heavily in Planning Makes Execution Truly Cheap

Managing the financial economics of a software factory requires understanding a simple equation: Total Cost = Tokens × Price. Selecting the appropriate model tier for each specific SDLC stage is an architectural necessity; using a top-tier model for simple tasks wastes capital, while using a low-tier model for complex reasoning causes token inflation through repeated failure loops.

Frontier reasoning models (such as Fable or top-tier reasoning engines) should be deployed exclusively during Stage 2 (Brainstorming) and Stage 3 (Planning). Although these high-tier models command a higher per-token price, early planning stages consume a tiny fraction of the total token volume of a project. Spending heavily on deep reasoning up front pays off exponentially by establishing absolute architectural boundaries, comprehensive ADRs, and rigid step-by-step task specifications before any code is generated.

When work moves to Stage 4 (Implementing), execution economics flip. A thoroughly refined plan, supported by explicit schema contracts and project glossaries, eliminates ambiguity. This allows cheaper standard execution models (such as Opus or Sonnet) to implement code cleanly in short, deterministic passes without getting trapped in expensive reasoning loops or wandering off-spec.

Conversely, attempting to save money by starting with a weak, unrefined plan triggers the "weak plan penalty." When an execution model receives vague requirements, it repeatedly fails verification gates, accumulates bloated context histories, and attempts multiple high-reasoning retries. Paul Iusztin demonstrated this benchmark in practice: a weak plan caused Anthropic's Sonnet model operating in high-reasoning mode to out-cost Opus on the exact same implementation task. The smaller model required repeated retry loops to reach the completion gate, accumulating massive context histories that erased the base model price differential. Total expense is driven by token volume accumulated through retries, not the base price tier of the model.

## Don't Overbuild the Factory: Hard Lessons in Autonomy and Control from Project Squid

Building a software factory carries significant architectural risks if you prioritize total autonomy over control. Paul Iusztin’s experience with Project Squid highlights a common engineering anti-pattern: attempting to deploy an end-to-end fully autonomous factory powered by unconstrained remote multi-agent swarms. The initial build produced a monolithic, un-debuggable graph. When an agent deviated from the intended plan mid-run, the operator could neither inspect the internal state, halt execution safely, nor redirect the swarm without discarding the entire run's output.

To maintain operational control, your factory orchestration engine must support dual-mode execution control. Engineers must retain granular, modular CLI commands (`/plan`, `/implement`, `/review`) that can be triggered individually to inspect and redirect work at specific stage boundaries. Optional end-to-end chained workflows (`/plan-and-implement-all`) should only be executed once individual stages have proven reliable. Planning must remain a distinct, human-steered checkpoint; chaining planning directly into automated execution without human validation risks generating large volumes of misaligned code.

Local agent execution using Git worktrees provides vastly superior isolation compared to unconstrained remote swarms. As illustrated in the worktree sandbox layout below, pairing each isolated branch with dedicated telemetry tools—such as Chrome DevTools Protocol for UI inspection, LogQL for log parsing, and PromQL for metrics—allows agents to independently run micro-services, reproduce bugs, and verify fixes in complete isolation without polluting the primary workspace or conflicting with parallel runs.

```text
Worktree Sandbox Isolation:
[Main Repo Branch]
       ├── (Worktree A) --> Agent Loop A + Ephemeral LogQL/PromQL Stack
       └── (Worktree B) --> Agent Loop B + Ephemeral Chrome DevTools Stack
```

Furthermore, managing code entropy and "AI slop" cannot rely on manual effort. Manual cleanup sessions (such as dedicated engineer cleanup days) fail to scale as agent output expands. Instead, software factories implement automated, recurring "doc-gardening" and "garbage collection" agents. Running on background schedules, these cleanup loops scan the codebase against encoded "golden principles," update component quality scores, detect stale documentation, and submit isolated refactoring PRs to fix structural drift before it compounds.

![Modular Granular Commands and Back Pressure vs Monolithic Autonomy](https://camnangai.com/articles/ben-trong-nha-may-phan-mem/06-en.webp)

## Build vs. Buy: Sizing Your Software Factory to Match Your Team's Scale

Determining whether to build custom factory infrastructure or buy off-the-shelf platforms depends strictly on team scale, operational complexity, and supervising capacity.

```text
The Factory Scale Curve:
Solo / Small Teams  -->  Mid-Sized Teams  -->  Enterprise Organizations
(Custom Skills over      (Buy Managed          (Build Custom Internal
 Off-the-Shelf Harness)   Platforms)            Harnesses & Linters)
```

### Small Team / Solo Scale (Custom Skills on Prebuilt Harnesses)

Individual engineers and small teams should avoid building custom orchestration platforms. The optimal strategy is to leverage established off-the-shelf harnesses (such as Claude Code, Codex CLI, OpenCode, or Pi) augmented with repository-local Markdown skill files, custom prompts, and lightweight agent configurations (e.g., Squid, Pocock skills, or the BMad method). At this scale, running local agents inside Git worktrees provides sufficient parallelism without incurring massive infrastructure overhead.

### Mid-Scale / Organization Buy Phase (Managed Factory Platforms)

The buy threshold is crossed the moment engineers who are not personally supervising agent loops begin executing automated workflows. At this stage, tracking token costs, maintaining distributed agent observability, orchestrating background swarms, and managing integrations across Linear, Slack, and CI pipelines become major infrastructure burdens. Mid-sized teams should buy managed software factory platforms—such as Factory.ai (utilizing Droids and Missions) or Warp (utilizing Oz). Purchasing off-the-shelf platform infrastructure allows engineering organizations to automate development workflows without diverting core engineering resources to maintain agent orchestration backends.

### Enterprise Custom Build Phase (In-House Factory Infrastructure)

At extreme organizational scale, companies cross back into building custom internal factory infrastructure. This transition occurs when off-the-shelf platform constraints limit velocity, or when unique security, compliance, and repository requirements demand deeply integrated tooling. OpenAI’s internal five-month experiment demonstrates this enterprise tier: a team scaling from three to seven engineers built a complex production product comprising ~1 million lines of code across ~1,500 merged PRs with zero hand-written lines of code, maintaining an average output of 3.5 merged PRs per engineer per day. Operating at this volume requires building custom internal execution harnesses, specialized domain linters, ephemeral sandboxed runtimes, and automated agent-to-agent review gates built directly into the core engineering repository.

![The Build vs Buy Decision Curve Across Team Scales](https://camnangai.com/articles/ben-trong-nha-may-phan-mem/07-en.webp)

## Starting from Your Single Most Painful Bottleneck: Practical Advice for Engineers

Do not attempt to transform your entire engineering workflow into a fully autonomous software factory overnight. As Zach Lloyd pragmatically advises, identify your team's single most annoying, repetitive, or time-consuming bottleneck—whether that is fixing flaky integration tests, managing third-party dependency updates, or triaging raw incoming bug reports—and build the smallest possible single-agent loop to automate that isolated task.

Software factories are not rigid, static scripts; they are continuous, evolving feedback loops. Focus on engineering robust environment harnesses and deterministic verification gates first, and gradually expand agent autonomy only as your automated evaluation layers earn complete operational trust.

## References

- [Inside a Software Factory: Go from vibe coding to generating clean, maintainable code — Paul Iusztin](https://oreillyradar.substack.com/p/inside-a-software-factory)
- [Software Factories, Light and Dark — Addy Osmani](https://addyosmani.com/blog/software-factories/)
- [Why Software Factories Are the Next Phase of Coding — Zach Lloyd & Latent Space](https://www.latent.space/p/software-factories)
- [Inside the Software Factory, and What It Takes to Build One — Factory.ai](https://factory.ai/articles/what-is-a-software-factory)
- [Harness Engineering: Leveraging Codex in an Agent-First World — OpenAI](https://openai.com/index/harness-engineering/)
- [LLM Wikis as Living Memory for AI Agents — Paul Iusztin & Louis-François Bouchard](https://www.decodingai.com/p/llm-wiki-agent-memory)
- [AIEWF Daily Dispatch: Loops, Software Factories & Forward Deployed Engineers — Latent Space](https://www.latent.space/p/aiewf-daily-dispatch-loops)
