Section650

Writing

TopicAI
Reading11 min

What Is a Factory Stack? Layers, factory.yaml, Skills and Governance for AI Coding Agents

A factory stack is everything around an AI coding agent that turns it into a repeatable delivery system. The layers, how to write a factory.yaml, how agents load custom skills, how Claude Code and Codex differ, and the gates that keep bad pull requests from merging.

By Ka Lun Chan · Cloud & AI · AI / Delivery / Engineering judgment

What is a factory stack?

A factory stack is the set of tools and infrastructure that turns an AI coding agent into a repeatable software delivery system. Claude Code or Codex is one layer of it. The rest supplies the context the agent works from, the environment it runs in, the trigger that starts it, the checks that judge its work, and the feedback that improves the next run. You assemble it from parts, and no vendor sells the one correct version.

The AI Software Factory describes the workflow from ticket to approved pull request. This article covers the layers underneath it, from configuration and skills to agent roles and governance.

The short version of all five: the agent is the easy part to buy. The configuration, the skills and the gates are what make the output trustworthy, and they are yours to write and keep up to date.

What are the layers of factory orchestration?

Grouped by responsibility, a factory stack has seven layers: models, the agent harness, context and skills, execution environments, orchestration, validation and governance, and observability and feedback. Treat these as related jobs, not a standard. Different vendors draw the lines differently.

Fig. 746-1 The layers of a factory stackSelect a layer. The coding agent is layer 02; the other six decide whether its work ships.

Models

What it does

Plan the work, write the code, and review it. Many stacks use more than one model, with a cheaper one for routine steps and a stronger one for planning or review.

In a one-person setup

Whatever model your agent subscription includes.

Without it

If every step is tied to one vendor’s model, that vendor’s pricing and outages become your delivery schedule.

In Warp’s grouping Warp

Inference

Warp’s “The Factory Stack”, published in September by its CEO Zach Lloyd, is the most detailed public version. It also names seven layers but cuts them differently: factories-as-code, data and context, compute, inference, improvement, orchestration, and access. Two of those are worth borrowing even if you never use Warp. Factories-as-code means the whole setup lives in version control, so a change to the factory can be reviewed, tested and reverted like any other change. Access means people and tools reach the factory through the places they already work, such as Slack, Jira, Linear or GitHub.

What Warp’s list doesn’t have is governance as its own layer. Warp spreads it across scorers, secrets and network policy. Permissions and approvals are the work teams are most tempted to postpone, and a layer of their own makes that harder.

What goes in a factory YAML file?

The only widely documented file actually called factory.yaml is Warp’s. It sits at the root of a Git repository and needs four things: a schemaVersion, a name, the repositories the factory works on, and default settings for its agents under agentDefaults or workerDefaults. If you aren’t on Warp, there is no single file. The same decisions live in a CI workflow, an AGENTS.md file, skill folders and the agent’s settings.

The smallest version, based on the example in Warp’s factory-as-code docs:

factory.yaml (Warp)
schemaVersion: v1alpha1
name: payments-factory
repositories:
  - owner: acme
    name: payments-service
agentDefaults:
  model: auto

Everything else is optional and gets added as the factory grows: secrets, networkPolicy, mcpServers, automations, integrations, scorerDefaults and selfImprovement, among others. Warp publishes JSON Schemas for the format, so an editor can check the file as you type. Its schema version is v1alpha1, a sign that field names may still change.

The YAML file is only the root. The agents, automations and skills live in folders beside it, mostly as Markdown files with YAML frontmatter:

A factory definition tree (Warp)
factory.yaml
agents/foreman/agent.md
agents/reviewer/agent.md
automations/labeled-issue/automation.md
runners/linux-build.yaml
skills/repository-conventions/SKILL.md
scorers/tests-run/scorer.md

An agent file is a description and a role, followed by instructions in plain Markdown. The frontmatter of the reviewer from Warp’s docs is two lines:

agents/reviewer/agent.md (frontmatter)
---
description: Reviews factory-produced pull requests
agentType: REVIEW
---

Other tools use the same idea without the name. Factory, the company behind the Droid agent, keeps droids, skills and commands in a .factory/ folder as Markdown with YAML frontmatter, and its settings in JSON. If you run Claude Code or Codex in GitHub Actions, your factory definition is mostly a workflow file. This is the minimal Claude Code example from Anthropic’s docs, which starts the agent when someone mentions @claude in a comment:

.github/workflows/claude.yml
name: Claude Code
on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]
jobs:
  claude:
    if: contains(github.event.comment.body, '@claude')
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
      issues: write
      id-token: write
      actions: read
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 1
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

Whichever format you use, the content questions are the same, and they matter more than the syntax:

  • Which repositories the agent may touch, and which branches it may push to.
  • Which model and harness run by default, and where the work runs.
  • Which secrets the run gets. The default should be none, with each one added for a reason.
  • What starts a run: a label, a comment, a schedule or an incoming error.
  • What counts as done, which is usually a set of checks that must pass.

Keep the file in Git and review changes to it the way you review code. Widening a token’s permissions or adding a network host is a security change, even when it’s two lines of YAML.

How do agents use custom skills in a factory?

A skill is a folder containing a SKILL.md file: YAML frontmatter with a name and a description, followed by instructions, plus optional scripts and reference files. At the start of a run the agent sees only the names and descriptions of the available skills. When a task matches a description, it loads that skill’s full instructions, and it runs the bundled scripts instead of reading them into context.

That loading order is what makes skills cheap. A factory can carry dozens of them without filling the context window, because each one costs a line or two until it’s needed. The format started at Anthropic and is now an open standard, Agent Skills, so the same folder works in Claude Code, Codex, Factory’s Droid and Warp’s factories. Each tool looks for it in a different place: .claude/skills/ for Claude Code, .agents/skills/ for Codex, .factory/skills/ for Droid, and skills/ beside factory.yaml for Warp.

A made-up example of the kind of skill that pays off in a factory:

.claude/skills/migration-check/SKILL.md (illustrative)
---
name: migration-check
description: Use when a change adds or edits a database migration. Checks that it can be rolled back and won't lock a large table.
---

1. List the migration files in the diff.
2. Confirm each one has a working down migration.
3. Run scripts/check-locks.sh on each file and include the output.
4. Flag any statement that rewrites a table with more than a million rows.

The description does most of the work. It is the only part the agent reads before deciding, so write it as “use when” plus what the skill checks. Vague descriptions get skipped, and overly broad ones load on every task. People can also run a skill directly: /migration-check in Claude Code, or $migration-check in Codex. For a skill that should never run on the agent’s own judgment, such as a deploy, Claude Code’s disable-model-invocation: true limits it to people.

Guidance works best split between two places. Rules that apply to every task go in AGENTS.md: how to build and test, naming conventions, what never to touch. Procedures that apply to some tasks become skills. If AGENTS.md has grown into a long list of “when you’re doing X, do Y”, most of those lines are skills waiting to be pulled out.

Two cautions. Skills are code. A skill with a script runs that script with the agent’s permissions, so a skill copied from a marketplace deserves the same review as a new dependency. And skills drift. Warp lets a factory reference a shared skill from another repository and recommends pinning it to a full commit SHA, which is good practice anywhere: you choose when the instructions change, rather than finding out after a run behaves differently.

What is the difference between Claude Code and Codex?

Claude Code is Anthropic’s coding agent and Codex is OpenAI’s. They now cover much the same ground: both run in the terminal, the IDE, a desktop app and the cloud, both read AGENTS.md, and both support skills, MCP servers and hooks. For a factory, the differences that matter are the default safety model, the license, and where each one keeps its configuration.

Fig. 746-2 Claude Code and Codex, side by side
AspectClaude CodeCodex
Made byAnthropicOpenAI
LicenseProprietaryCLI is open source (Apache-2.0); the IDE extension and cloud are not
Where it runsTerminal, VS Code and JetBrains, desktop app, webCLI, IDE extension, desktop app, cloud, mobile
Project rulesCLAUDE.md. Reads AGENTS.md too, but only CLAUDE.md when both exist unless CLAUDE.md imports itAGENTS.md, combined from the repository root down to the working folder
Skills.claude/skills/ or ~/.claude/skills/, run with /skill-name.agents/skills/ or ~/.agents/skills/, run with $skill-name or /skills
Settings.claude/settings.json, plus managed settings for organizations~/.codex/config.toml, plus requirements.toml for admins
Default safetyPermission modes and allow, ask and deny rules. The sandbox is off by defaultAn OS-level sandbox with no network access by default
Headless and CIclaude -p, and anthropics/claude-code-action@v1codex exec (read-only by default), and openai/codex-action@v1
GitHub review@claude through the Action, or the Code Review service on Team and Enterprise plans, which comments but never approves@codex review on a pull request, or automatic reviews
Checked against each vendor’s documentation in November. Both tools change often, so treat the rows as a starting point and confirm in the docs.

The default safety model is the row that matters most for a factory. Codex starts inside an operating-system sandbox with no network access, and you loosen it. Claude Code relies on permission modes and allow, ask and deny rules to decide what needs approval, with its sandbox off until you turn it on. Both can be configured to roughly the same place. The difference is what happens when nobody configures anything, and in CI that is often what happens.

Claude can write the change and Codex can review it, or the roles can be reversed. The author addresses findings and a person approves the merge. Keeping the reviewer separate from the author gives the change another pass from a different starting point. See a proposed two-agent review workflow.

In a factory stack, either one is a replaceable layer. Your AGENTS.md and your skills carry over between them, and so do your tests and branch rules. That is a good reason not to lock your factory definition to one vendor’s features.

How does factory governance prevent bad PRs?

Governance doesn’t stop an agent from writing a bad change. Nothing reliably does. What it does is limit what the agent can damage while it works and stop a bad change from merging: scoped permissions and sandboxes, hooks that block risky commands, required checks, an independent reviewer, code owners, and a human approval that neither the agent nor the person who started it can give.

Fig. 746-3 Seven gates between an agent and mainGates 01 and 06 belong to a person.
  1. Who can start a run

    Only people with write access can trigger the agent. Text from anyone else, such as an outside issue or comment, is data to read and never an instruction to follow.

  2. What the agent can reach

    A sandbox, deny rules for secrets and production, and a GitHub token scoped with permissions: to the few scopes the job needs. Deploy secrets sit behind an environment with required reviewers.

  3. What it’s blocked from doing

    Hooks that refuse specific commands before they run, such as a force push or a write to the migrations folder.

  4. Checks it can’t fake

    Required status checks for build, tests and scans, pinned to the app expected to report them, so nothing else can mark them green.

  5. A reviewer that didn’t write it

    A second agent reviews the diff against the issue and the rules. Code owners must approve changes to the paths they own.

  6. A person who didn’t start it

    Authors can’t approve their own pull requests. Require approval of the most recent push and dismiss stale approvals, so a late commit can’t ride in on an old review.

  7. Rules nobody can switch off

    Managed settings in Claude Code, requirements.toml in Codex, and no admin bypass on the protected branch.

Gates 02 and 03 limit what a bad run can damage. Gates 04 to 06 stop a bad change from merging. Gate 07 keeps the other six from being switched off on a busy day.

A few details from the docs make the difference between gates that work and gates that only look like they do:

  • In GitHub Actions, setting any scope under permissions: sets every scope you didn’t list to none. Listing only what the job needs is the simplest least-privilege control you have.
  • Pull requests opened with the workflow’s own GITHUB_TOKEN don’t run their workflows until someone with write access approves the run, and repositories on personal accounts don’t let workflows create or approve pull requests by default. Leave those defaults alone.
  • Claude Code’s Bash deny rules match commands, not intent. Its docs note that a denied program can still be run by its full path or inside sh -c, and recommend pairing deny rules with the sandbox.
  • Codex keeps .git, .codex, .agents and .aws read-only even when the agent can write to the rest of the workspace.
  • Claude Code Review comments on pull requests and never approves or blocks them. AI review is evidence for the human approver, not a replacement for one.

GitHub’s own rules for its Copilot cloud agent make a good reference design. Only people with write access can trigger it, it pushes only to its own branch, it can’t approve or merge its own pull requests, the person who asked for the change can’t approve it either, and workflows wait for a person to click approve. Whatever agent you use, you can copy that design with branch rules and workflow settings.

The threats behind these gates appear in the OWASP Top 10 for LLM applications. Prompt injection is untrusted text, such as an issue body or a web page, steering the agent. Excessive agency is an agent with more permissions or autonomy than its job needs. Gates 01 and 02 address those directly.

What governance can’t catch is a change that does the wrong thing correctly. If the issue was vague, the agent can write code that passes every test and still isn’t what anyone wanted. That’s why the human gate is about reading the change against the requirement, and why a clear issue, written before any agent runs, does more for quality than any gate after it.

What does a small factory stack look like?

You don’t need a factory platform to start. For one person or a small team, a reasonable first stack is:

  1. Claude Code or Codex as the agent.
  2. An AGENTS.md file and a handful of skills in the repository.
  3. GitHub Issues for intake, and a GitHub Actions workflow that starts the agent on a label or a comment.
  4. Branch protection with required checks and a required human review.
  5. Error monitoring that turns production problems into new issues.

That covers every layer except dedicated orchestration. A small trial can start with repository instructions, validation, separate Git worktrees and human approval before merge.

Automate where it removes more friction than it adds, and leave the thinking at the front alone. Paul Iusztin’s O’Reilly piece on software factories keeps people in brainstorming and planning and hands agents the stages in between. That split makes sense, because the factory multiplies whatever goes into it, so a clear issue gets you a reviewable pull request and a vague one gets you several confident wrong ones.

One naming note, since it confuses people: the generic factory stack is not the same thing as Factory, the company that makes the Droid agent. Factory sells tools for this pattern, and you can build the pattern with other tools.

Sources

Checked in November against Warp’s post and documentation, O’Reilly, the Agent Skills site, Anthropic, OpenAI, Factory and GitHub documentation, and OWASP. The layer grouping, the skill example, the small stack and the opinions are mine.

Short answers

What is a factory stack?

A factory stack is the set of tools and infrastructure around an AI coding agent that turns it into a repeatable software delivery system: models, the agent harness, context and skills, execution environments, orchestration, validation and governance, and feedback. The coding agent is one layer of it.

How is a factory YAML file structured?

The only widely documented factory.yaml is Warp’s. It needs schemaVersion, name, repositories and either agentDefaults or workerDefaults, and it sits at the root of a Git repository next to folders for agents, automations, runners and skills. Other stacks spread the same definition across GitHub Actions workflows, AGENTS.md, skill folders and agent settings files.

How do agents use custom skills in a factory?

A skill is a folder with a SKILL.md file: YAML frontmatter with a name and description, then instructions, plus optional scripts and reference files. The agent sees only the descriptions at the start of a run and loads a skill’s full instructions when a task matches it, or when someone invokes it by name.

What is the difference between Claude Code and Codex?

Claude Code is Anthropic’s coding agent and Codex is OpenAI’s. Both run in the terminal, IDE, desktop and cloud, read AGENTS.md, and support skills, MCP and hooks. The practical differences are defaults and licensing: Codex starts sandboxed with no network access and its CLI is Apache-2.0 open source, while Claude Code relies on permission rules with its sandbox off by default and is proprietary.

How does factory governance prevent bad pull requests?

Governance does not stop an agent from writing a bad change. It stops the change from merging and limits what the agent can damage on the way: scoped permissions and sandboxes, hooks that block risky actions, required status checks, an independent reviewer, code owners, and a human approval the agent and the person who started it cannot give themselves.

Before an agent opens pull requests on its own

Check these first:

  1. The factory definition, whether it’s a factory.yaml or a workflow file, is in Git and changes to it get reviewed.
  2. The agent’s token and secrets cover only what its job needs.
  3. Required checks and a required human review protect the main branch, with no bypass.
  4. The issues going in say what done looks like.

For deciding how much verification a change needs, see How to Verify AI-Generated Code.

Discuss what you’re building The AI software factory