spec v1.1 · 8 factories · 5 SDKs · 2 tools

Your software process, as a graph agents run

One Factoryfile declares a software factory for coding agents: the agents, the stages they work, the next edges between stages, and loops that go back with an exit condition and a max. Parse it from five languages, lint it, and draw it.

Browse the factoriesRead the spec
samples/xp.factoryfile8 stages · 4 agents · 3 loops
version = "1"

factory "xp" {
  description = "Extreme Programming: short iterations, pairs, test first, the customer on site"
  entry       = "release-planning"

  agent "driver" {
    role    = "pair driver"
    model   = "claude-sonnet-5-5"
    tools   = ["Read", "Edit", "Bash"]
    content = "You hold the keyboard. You write the smallest failing test, then the simplest code that passes."
  }

  stage "write-test" {
    description = "Red"
    agents      = ["driver", "navigator"]
    next        = ["make-it-pass"]
  }
  ...
  loop "tdd" {
    description = "Red, green, refactor"
    from        = "refactor"
    to          = "write-test"
    until       = "every story of the iteration has passing tests"
    max         = "50"
  }
}
tddmax 50 buildmax 5 iterationmax 12 ▶ release-planning iteration-planning write-test make-it-pass refactor continuous-integration acceptance-test small-release

one format, five parsers, two tools

Python 3.15Rust referenceJava 25Go 1.26TypeScript 7 · Bunfactoryfile-lint E001-E010 · W001-W008factory-cli --render · --render-ui82 invalid fixtures4 valid fixturesv1.1 routes · commands · verdictsidentical error messages

how it works

A factory is a graph

Stages are the nodes, next lists are the forward edges, and loops are named back edges that stop when until is met or after max passes. One file can hold several factories, and a tool picks the one it needs.

factory

Factories

A named graph with a description and an entry stage. Without entry, work starts at the first stage.

agent

Agents

A role, a model and tools, with the system prompt inline in content or by source, exactly one of them.

stage

Stages

The agents that work it, the artifacts it produces and its own content instructions.

next

Forward edges

The stages that follow. A stage with no next and no on route ends the factory. Going back through next is a warning.

loop

Bounded back edges

When from finishes and until is not met, work goes back to to, at most max times.

on

Outcome routes

Where work goes for each outcome of a stage, passed or failed, yes or no, with a label, a reason and cycle to start the next cycle.

exhausted

Fallbacks

Where a route sends work once its target ran as often as allowed, chained as deep as needed, so a retry loop always has a way out.

run

Command stages

A stage that runs test, ship, merge, finish or a script instead of an agent, and can end the factory.

verdict

Gates

A stage writes its output, and the verdict map names the field that picks the yes or the no route.

tasks

Parallel stages

One agent per task listed by another stage, at most parallel at once, plus visits, skills and prompt source files per stage.

at

Layout

The column and row of each stage, so a drawn factory keeps its shape in every tool.

<<PROMPT

Heredocs

Multi-line prompts without escaping. The shared indentation is stripped, and ${NAME} stays literal.

the shape

Blocks like main.tf, checked like a compiler

References resolve anywhere in the factory, before or after the block that uses them. A parser stops at the first error and reports it as line L, col C: message.

version = "1"

factory "xp" {
  description = "Extreme Programming with pairs of agents"
  entry       = "test-first"

  agent "pair" {
    role    = "driver and navigator"
    tools   = ["Read", "Edit", "Bash"]
    content = <<PROMPT
      You write the test first, then the code that makes it pass.
      PROMPT
  }

  stage "test-first" {
    agents = ["pair"]
    next   = ["acceptance"]
  }

  stage "acceptance" {
    agents  = ["pair"]
    content = "Run the acceptance tests of every story."
  }

  loop "tdd" {
    from  = "test-first"
    to    = "test-first"
    until = "every test is green and the code is clean"
    max   = "20"
  }
}
1

Start at the entry

entry names the first stage. Agents named in agents must exist in the same factory.

2

Follow next

Stages are laid out in layers by their longest distance from the entry over next edges.

3

Loop back, bounded

A loop may point a stage at itself. max is an integer from 1 to 999999.

4

Fail with the same message

Misspell "acceptance" in next and all five SDKs say line 17, col 14: unknown stage "acceptence" in stage "test-first"

spec v1.1

Everything a runtime needs, nothing lost

v1.1 only adds optional statements, so every v1 file still parses. With command stages, outcome routes, verdict gates, fallbacks, parallel tasks and layout, a Factoryfile carries a whole runnable loop. Softorio runs its factories from the Factoryfile and generates its factory.yaml from it, and both draw the very same loop.

stage "test" {
  run = "test"

  on "passed" { to = "approve" }
  on "failed" {
    to = "fix"

    exhausted "postmortem" {
      reason = "the tests kept failing"
    }
  }
}

stage "approve" {
  agents  = ["approver"]
  output  = "approval.json"
  verdict = {
    field = "approved"
    yes   = "approved"
    no    = "rejected"
  }

  on "approved" { to = "ship" }
  on "rejected" { to = "postmortem" }
}
1

Branch by outcome

A stage uses either the next route, next or on "next", or outcome routes, never both.

2

Bound every retry

A route back to an earlier stage needs a loop, cycle = "true" or an exhausted fallback, or the linter warns W007.

3

Same errors everywhere

19 new fixtures pin every new message, such as verdict requires "field", in all five SDKs.

factory-cli

See the factory before you run it

--render draws the stages layer by layer in the terminal with their agents, artifacts, next edges and loops. --render-ui writes one self-contained HTML page with an SVG graph and opens it.

factory-cli --render samples/scrum.factoryfile --no-color
factory scrum
Scrum: a product owner, a scrum master and a team working in sprints
entry backlog-refinement · 6 stages · 4 agents · 2 loops

      ┌──────────────────────────┐
L1    │ ▶ backlog-refinement     │
      │ product-owner, developer │
      │ ▸ product-backlog.md     │
      └──────────────────────────┘
        └▶ sprint-planning
        │
        ▼
      ┌────────────────────────────────────────┐
L2    │ sprint-planning                        │
      │ product-owner, scrum-master, developer │
      │ ▸ sprint-goal.md                       │
      │ ▸ sprint-backlog.md                    │
      └────────────────────────────────────────┘
        └▶ development
        │
        ▼
      ┌───────────────────┐
L3    │ development       │
      │ developer, tester │
      └───────────────────┘
        └▶ daily-scrum
        │
        ▼
      ┌─────────────────────────┐
L4    │ daily-scrum             │
      │ scrum-master, developer │
      └─────────────────────────┘
        └▶ sprint-review
        │
        ▼
      ┌──────────────────────────────────┐
L5    │ sprint-review                    │
      │ product-owner, developer, tester │
      │ ▸ increment                      │
      └──────────────────────────────────┘
        └▶ retrospective
        │
        ▼
      ┌─────────────────────────────────┐
L6    │ retrospective                   │
      │ scrum-master, developer, tester │
      │ ▸ improvements.md               │
      └─────────────────────────────────┘

loops
  ↺ day     daily-scrum ──▶ development  until the sprint time-box ends  max 10
  ↺ sprint  retrospective ──▶ backlog-refinement  until the product goal is met  max 26
The xp factory drawn by factory-cli --render-ui as an SVG graph
--render-uiThe xp factory as a web page: stages in layers, loops as back edges with until and max.
factory-cli --render [path] [--factory NAME] [--no-color]
factory-cli --render-ui [path] [--factory NAME] [--out FILE] [--no-open]

gallery

Eight factories, one file format

Every sample in samples/ plus the repository's own Factoryfile, rendered by factory-cli --render-ui. Open one, or switch between them below.

4 stages · 4 loops

rup

Rational Unified Process: four phases, each one iterative, driven by use cases and architecture.

Open graph
8 stages · 3 loops

xp

Extreme Programming: short iterations, pairs, test first, the customer on site.

Open graph
6 stages · 2 loops

scrum

A product owner, a scrum master and a team working in sprints, with a daily loop.

Open graph
7 stages · 1 loop

xgh

eXtreme Go Horse: think, and it is not XGH anymore.
lints with 4 warnings, on purpose

Open graph
5 stages · 2 loops

kanban

A pull system with work-in-progress limits on every column.

Open graph
5 stages · 0 loops

waterfall

Each phase ends before the next one starts. No back edges at all.

Open graph
5 stages · 1 loop

spiral

Every turn plans, analyses risk, builds and evaluates.

Open graph
v1.1 · 9 stages · 8 routes

gated-release

Plan, build in parallel, test, a verdict gate, ship, and a postmortem before the next cycle.

Open graph
dogfooded · 5 stages

factoryfile

How a change to the spec reaches every SDK, the linter and the visualizer.

Open graph
Open full page

factoryfile-lint

Every rule, with a code

Written in Rust on top of the Rust SDK. It reports every schema error, not only the first, and adds graph warnings a parser should not reject: unreachable stages, unbounded cycles and loops without a max.

CodeLevelRule
E001errorlexical or syntax error
E002errorunknown attribute or unknown verdict key
E003errorunknown block
E004errorduplicate attribute
E005errorwrong attribute kind
E006errorunsupported version, or invalid max, parallel, visits, at or cycle
E007errorduplicate factory, item, on route or exhausted
E008errormissing version, agents or run, from, to, the to of a route, the field of a verdict, or neither source nor content
E009errorunknown stage or agent reference
E010errorboth source and content, or the next route mixed with outcome routes
W001warningthe factory declares no stage
W002warninga source starting with . or / does not exist next to the Factoryfile
W003warninga stage cannot be reached from the entry over next, routes, fallbacks and loops
W004warninga block name is not kebab-case
W005warningan agent is not used by any stage
W006warningan inline content is empty
W007warningnext or a route goes back to an earlier stage, a cycle that no loop, cycle or exhausted bounds
W008warninga loop has no max, so it may never end

sdks

Same model in every language

Each SDK has a lexer, a parser and a schema validator, and returns the same typed model. Every one runs the same 82 invalid and 4 valid conformance fixtures and must produce the exact same error string.

SDKRuntimeEntry point
Python3.15 · uvfactoryfile.parse(text) · load(path)
Rustreference · cargofactoryfile::parse(src) · parse_file(path)
Java25 · MavenFactoryfile.parse(String) · load(Path)
Go1.26factoryfile.Parse(src) · ParseFile(path)
TypeScript7 · Bunparse(src) · load(path)
from factoryfile import load

xp = load("samples/xp.factoryfile").factories[0]
print(xp.entry)
for loop in xp.loops:
    print(loop.name, loop.from_, "->", loop.to, "max", loop.max)
uv run python
release-planning
tdd refactor -> write-test max 50
fix-the-build continuous-integration -> write-test max 5
iteration acceptance-test -> iteration-planning max 12

Lint your Factoryfile

The spec lives in spec/SPEC.md. The fixtures in spec/fixtures pin every error message, so a new SDK can prove it conforms. The xgh factory breaks the rules on purpose.

Open SPEC.md