SYS // FACTORY-OPS
DOC.V1 · FIELD MANUAL
Field Manual // Build Your Own Factory

Build Your Own
AI Software Factory

Stop prompting your AI agent to build things one chat at a time. Build the assembly line instead: three specialized stages, one shared queue, and agents that hand work to each other — with proof at every step. This guide takes you from zero to a running factory in about 30 minutes.

Stage 01

Spec

Your smartest model interrogates the idea and writes a build-ready plan.

Stage 02

Build

A cheaper model implements the plan and proves it works by running it.

Stage 03

Review

An independent agent re-verifies everything. Only review can mark work done.

Briefing

Why a factory beats a chat window

When one AI session does everything — planning, coding, and judging its own work — quality drifts and expensive model time gets burned on grunt work. A factory separates the concerns:

The contract — the only thing every agent must agree on

ElementConvention
QueueA Linear team (free tier is fine). Every factory work item is a Linear issue.
LabelFactory Queue — agents only ever touch issues carrying this label.
StatesTodo (specced) → In Progress (building) → In Review (awaiting QA) → Done
Golden ruleOnly the review stage sets Done. Failed reviews go back to Todo with a numbered defect list — which becomes the next build's work order.
Spec formatEvery spec starts with a Repo: header naming the working directory, and ends with testable acceptance criteria.
IdentityEvery build/review report opens with Agent: <platform / model> so you always know who did what.
Loadout

What you need

01

Set up your Linear queue

  1. In Linear, create (or pick) a team. Write down its exact name — you'll substitute it for YOUR_TEAM_NAME in everything below.
  2. Create a label named Factory Queue (Settings → Labels). This is the conveyor belt — it's how factory work stays separate from everything else in your workspace.
  3. Confirm your team's workflow has these four states (Linear's defaults include them): Todo, In Progress, In Review, Done. No custom states needed.
02

Connect your agent to Linear

Your agent needs to read and write Linear issues. In Claude Code, enable the Linear connector: run /mcp in a session (or add Linear in your claude.ai connector settings) and complete the OAuth login. In Codex CLI, add this to ~/.codex/config.toml and log in on first use:

codex // config.toml addition
[mcp_servers.linear]
url = "https://mcp.linear.app/mcp"

Quick test before moving on: ask your agent "list my Linear teams." If it answers with your team name, you're wired.

03

Install the three skills

This is the heart of the factory. You have two paths — the fast path lets your agent build its own factory (it takes one paste); the manual path gives you our exact battle-tested skill files.

Fast path — one prompt, your agent builds it

Paste this into your strongest model (in Claude Code: your best available Claude model). It will create all three skills in your agent's native format, then tell you how to invoke them. Replace YOUR_TEAM_NAME first.

prompt // factory installer
I want you to build me a three-stage "software factory" as three custom skills
(or custom prompts, whichever this platform supports), named factory-spec,
factory-build, and factory-review. They coordinate through my Linear workspace.

THE SHARED CONTRACT (encode this in all three skills):
- Linear team: YOUR_TEAM_NAME. Queue label: "Factory Queue" — only ever touch
  issues carrying this label.
- States: Todo (specced) -> In Progress (building) -> In Review (awaiting QA)
  -> Done. Done may ONLY be set by the review stage. A failed review returns
  the issue to Todo with a numbered defect list.
- Every spec begins with a "Repo:" header line naming the absolute path of the
  working repository. Build and review refuse to guess at it.
- Every build/review report posted to the issue opens with
  "Agent: <platform / model>".

STAGE 1 — /factory-spec (runs on the strongest model):
Interrogate me in batches of max 4 questions until you could fill every spec
section without inventing anything. Then draft a spec with sections: Repo
header (+ Priority + Estimate), Problem, Goals, Non-goals, User flow,
Technical approach (real file paths, verified if the repo is readable),
Acceptance criteria (each independently testable, include at least one
failure case), Test plan (exact commands + expected results), Build notes.
No placeholders or TBDs allowed. Show me the draft for one go/no-go, then
file it as a Linear issue: team YOUR_TEAM_NAME, state Todo, label Factory
Queue. Never write code in this stage. One feature per issue.

STAGE 2 — /factory-build (safe to run looped on a cheaper model):
Pick the highest-priority Todo issue labeled Factory Queue (skip issues whose
latest comment starts "BLOCKED:", issues with unresolved blocking relations,
and — silently, no comment or state change — issues whose Repo path is not
reachable from this session). Claim it: state In Progress, assignee me. Read
the FULL spec and ALL comments (a prior failed-review defect list is the
primary work order). Work on a feature branch named after the Linear issue —
never commit to main. Implement exactly what the spec says: no scope creep,
secrets only in env vars, and if the spec is ambiguous on a load-bearing
decision, post "BLOCKED: <question>" and return it to Todo instead of
guessing. Verify by EXECUTING the spec's test plan — "the code looks right"
is not verification. Check the staged file list before committing (no build
artifacts). Post a BUILD REPORT comment (Agent line, what was implemented,
exact commands run + results per acceptance criterion, branch + commit SHAs,
deviations, notes for review), then set state In Review. One issue per
invocation, then stop.

STAGE 3 — /factory-review (the only stage allowed to set Done):
Take the oldest In Review issue labeled Factory Queue. Read the spec, all
comments, and the actual diff on the branch. Re-run the ENTIRE test plan
from scratch — never trust the build report's claims. Walk every acceptance
criterion pass/fail with observed evidence. Baseline checks regardless of
spec: no hardcoded secrets, no debug leftovers, input validation on new
endpoints, no unrelated files in the diff. Verdicts: PASS -> tick the
spec's checkboxes, post a REVIEW REPORT, set Done. PASS WITH FIXES (only
minor, low-risk defects totaling ~15 min) -> fix on the same branch, commit,
re-verify, report, set Done. FAIL -> do NOT rework it yourself; post a
numbered defect list (what's wrong / how to reproduce / expected vs actual)
and set state Todo. One issue per invocation.

After creating all three, tell me exactly where you put the files and how I
invoke each stage on this platform.

Manual path — install the exact files

For Claude Code: create one folder per skill under ~/.claude/skills/ and put the matching SKILL.md inside (plus the spec template in the factory-spec folder). Expand each block, copy, and save. Replace YOUR_TEAM_NAME in all files, then restart your session — skills load at startup.

~/.claude/skills/factory-spec/SKILL.md
skill // stage 1: spec
---
name: factory-spec
description: Factory stage 1 — turn a feature idea into a build-ready spec through structured questioning, then file it as a Linear issue in the factory queue (team YOUR_TEAM_NAME, state Todo, label Factory Queue). Use when the user wants to spec out a feature, fix, or task. Produces a Linear issue only; never writes code.
---

# /factory-spec — Stage 1: specification

Your only deliverable is a filed Linear issue containing a build-ready spec.
You never write code in this stage.

## Factory constants
- Linear team: **YOUR_TEAM_NAME**
- Queue label: **Factory Queue** (how /factory-build and /factory-review find work)
- Filed state: **Todo**
- Conveyor: `Todo` (specced) → `In Progress` (building) → `In Review` (awaiting QA) → `Done` (set ONLY by review)

## Procedure

### 1. Understand the ask
The skill arguments are the raw feature idea. If empty, ask.
Interrogate the user in batches of at most 4 focused questions until you could
defend every section of the spec template without inventing anything: the
problem and who has it, success criteria, scope boundaries, technical
constraints, verification. If the working directory is the target repo, ground
the Technical approach in real file paths — read the repo's docs and the files
the feature touches. Stop asking when further answers wouldn't change the build.

### 2. Draft the spec
Fill in every section of `spec-template.md` (in this skill's folder). Rules:
- No placeholders, no "TBD". Can't fill a section → back to step 1.
- Acceptance criteria must be independently testable by someone who didn't build it.
- Work honestly larger than ~8 points → split into multiple linked issues.

### 3. One approval pass
Show the user the draft, ask a single go/no-go, accept edits, then file.

### 4. File to Linear
- Duplicate-check first (search open issues by title keywords).
- Create the issue: team YOUR_TEAM_NAME, state Todo, label ["Factory Queue"],
  imperative title, description = the full spec, priority (default Medium),
  estimate in points.
- The repo path MUST be in the spec's **Repo:** header — /factory-build
  cannot work without it.

### 5. Report
Output the issue identifier and URL, then stop. Building is /factory-build's job.

## Guardrails
- Never file a spec with unresolved questions.
- One feature per issue.
- This is the expensive-model stage — depth here pays for itself downstream.
  A vague spec wastes three sessions instead of one.
~/.claude/skills/factory-spec/spec-template.md
template // spec format
# <Imperative feature title>

**Repo:** <absolute path or git URL> | **Priority:** <Urgent/High/Medium/Low> | **Estimate:** <points>

## Problem
What's broken or missing, for whom, and why it matters now. One tight paragraph.

## Goals
- Concrete outcomes that define success. Each one observable after shipping.

## Non-goals
- Explicitly out of scope. This section protects the build stage from scope
  creep — be generous here.

## User flow
Step-by-step of what the user sees and does once this ships. Number the steps.

## Technical approach
- **Entry points / affected files:** real paths verified against the repo
- **Data model:** tables/fields added or changed; migrations needed?
- **APIs / interfaces:** endpoints, params, auth requirements
- **Key decisions:** chosen approach and why; alternatives rejected
- **Dependencies:** libraries, env vars, external services

## Acceptance criteria
- [ ] Each criterion independently testable by a reviewer who didn't build it
- [ ] Prefer "user can X and sees Y" over "code does Z"
- [ ] Include at least one failure/edge case criterion

## Test plan
Exact commands to run and expected results — how build proves it works and
review re-proves it independently. Cover happy path, edge, and failure cases.

## Build notes
- Branch: use the Linear-generated branch name for this issue.
- Secrets go in .env / env vars — never hardcoded (checked at review).
- Match repo conventions: read the repo's own docs before writing code.
- <anything environment-specific: ports, services, test data>
~/.claude/skills/factory-build/SKILL.md
skill // stage 2: build
---
name: factory-build
description: Factory stage 2 — pull the highest-priority Todo issue labeled Factory Queue from Linear (team YOUR_TEAM_NAME), implement it on a feature branch per its spec, verify it, and move it to In Review with a build report. One issue per invocation. Designed for looped runs (/loop 5m /factory-build) on a cheaper model.
---

# /factory-build — Stage 2: execution

Take ONE specced issue from the queue, implement it exactly to spec, prove it
works, hand it to review.

## Factory constants
- Linear team: **YOUR_TEAM_NAME** • Queue label: **Factory Queue**
- You consume state **Todo**; you produce **In Review**.
- `Done` is set ONLY by /factory-review — never by you.
- Reports open with `**Agent:** <platform / model>`.

## Procedure

### 1. Pick up work
- List issues: team YOUR_TEAM_NAME, state Todo, label Factory Queue.
- Lane filter: if invoked with an argument (e.g. `/factory-build webapp`), only
  consider issues whose Linear project name or labels contain it.
- Pick highest priority, oldest first on ties. Skip:
  - issues whose most recent comment starts `BLOCKED:` (they need a human),
  - issues with unresolved blocking relations,
  - issues whose **Repo:** path is unreachable from THIS session's environment —
    skip these SILENTLY (no comment, no state change); another session will
    take them.
- Queue empty → say "Factory queue: nothing buildable" and stop cleanly.

### 2. Claim it
Set state In Progress, assignee me. Read the FULL spec and ALL comments —
a prior REVIEW REPORT (FAIL) defect list is your primary work order.

### 3. Locate the repo
The spec's **Repo:** header names the working directory. Verify it exists and
is a git repo. Header missing/ambiguous (a spec defect) → comment
`BLOCKED: <what's unclear>`, set state back to Todo, stop.

### 4. Branch
Work on the issue's Linear-generated branch name. Never commit to main/master.

### 5. Implement — with guardrails
- Read the repo's own agent docs (CLAUDE.md / AGENTS.md) first; match conventions.
- Build exactly what the spec describes. NO scope creep — tangents go in your
  report as "suggest /factory-spec", not built.
- Secrets in env vars, never hardcoded — review checks this.
- Spec ambiguous on a load-bearing decision → `BLOCKED: <questions>` comment,
  state back to Todo, stop. Do not guess.

### 6. Verify
Execute the spec's Test plan literally. Every acceptance criterion needs
evidence from RUNNING code — "the code looks right" is not verification.

### 7. Commit
Descriptive messages; record SHAs. Review the staged file list first: never
commit build artifacts (__pycache__/, node_modules/, dist/, logs); add
.gitignore entries as needed.

### 8. Hand off
Post a comment:

**BUILD REPORT**
- **Agent:** <platform / model>
- **Implemented:** <what was built, per spec section>
- **Verified:** <exact commands run and results, per criterion>
- **Branch / commits:** <branch> @ <SHAs>
- **Deviations from spec:** <none, or what and why>
- **Notes for review:** <what the reviewer should check first>

Then set state In Review.

### 9. Stop
One issue per invocation. The loop handles cadence.
~/.claude/skills/factory-review/SKILL.md
skill // stage 3: review
---
name: factory-review
description: Factory stage 3 — QA the oldest Linear factory issue in In Review (team YOUR_TEAM_NAME, label Factory Queue) against its spec's acceptance criteria by actually running the code. Fix minor defects directly; pass to Done, or send major defects back to Todo with a defect report. The ONLY stage allowed to set Done. One issue per invocation. Designed for looped runs (/loop 5m /factory-review).
---

# /factory-review — Stage 3: quality assurance

You are the only stage allowed to mark an issue Done. Default posture:
skeptical. The build report is a claim, not a fact, until you reproduce it.

## Factory constants
- Linear team: **YOUR_TEAM_NAME** • Queue label: **Factory Queue**
- You consume **In Review**; you produce **Done** (pass) or **Todo** (fail → rework).
- Reports open with `**Agent:** <platform / model>`. Prefer reviewing work
  built by a DIFFERENT agent/model than yourself when possible.

## Procedure

### 1. Pick up work
- List issues: team YOUR_TEAM_NAME, state In Review, label Factory Queue,
  oldest first. Lane filter: same as build (argument matches project/labels).
- Skip (silently) issues whose **Repo:** path is unreachable from this session.
- Nothing there → "Factory queue: nothing awaiting review", stop cleanly.

### 2. Gather the evidence
Read the full spec, every comment (especially the latest BUILD REPORT), and
the actual diff: check out the branch named in the build report and read
git log / git diff against the default branch.

### 3. Verify by execution, not inspection
- Re-run the spec's Test plan yourself, FROM SCRATCH. Do not trust the build
  report's claimed results — reproduce them.
- Walk EVERY acceptance criterion: pass/fail with observed evidence.
- Baseline checks regardless of spec: no hardcoded secrets or tokens, no debug
  leftovers, input validation on new endpoints/forms, error paths don't crash,
  no unrelated files in the diff.

### 4. Verdict — three outcomes

**PASS** — every criterion verified, baseline clean:
tick the spec's acceptance checkboxes, post the report, set state Done.

**PASS WITH FIXES** — only minor defects (low-risk, no design change, all
fixable in ~15 minutes total): fix on the same branch, commit, re-verify,
list fixes with SHAs in the report, tick checkboxes, set Done.

**FAIL** — any major defect (criterion unmet, design deviation, security
issue, unreproducible verification): do NOT rework it yourself. Post a
numbered defect list (what's wrong → how to reproduce → expected vs actual),
set state Todo — the build stage treats your list as its work order.

Report format (comment on the issue):

**REVIEW REPORT — <PASS | PASS WITH FIXES | FAIL>**
- **Agent:** <platform / model>
- **Criteria:** <n>/<total> verified — one line per criterion: pass/fail + evidence
- **Test plan reproduced:** <commands run, results>
- **Baseline checks:** <clean or findings>
- **Fixes applied:** <none, or list with SHAs>
- **Defects:** <none, or numbered list>
- **Suggestions (out of scope):** <ideas for a future /factory-spec>

### 5. Stop
One issue per invocation. Improvement ideas go in Suggestions — never into
the code during a PASS.
⚠ Three install gotchas that cost us real debugging time
  • Restart your session after installing. Skills are discovered at startup — an open session will not see new files.
  • Line endings must be LF, not CRLF. On Linux/WSL, a Windows-style \r in the frontmatter makes the skill silently fail to register. If a skill won't appear, check this first.
  • Prefix your skill names. We use a prefix (factory-) because a bare name like review can collide with your platform's built-in commands and get shadowed.
04

Run one piece through by hand

Before turning on any automation, walk one small, real feature through all three stages yourself so you see each hand-off. Pick something tiny — a utility script, a small endpoint, a fix.

  1. Spec it — in a fresh session on your strongest model:
prompt // first spec
/factory-spec I want to add [describe one small feature] to the repo at
[absolute path]. Ask me whatever you need, then file it to the queue.
  1. Build it — open a session in (or with access to) that repo, on a cheaper model, and run /factory-build. Watch it claim the issue, branch, implement, run the tests, post its BUILD REPORT, and move the issue to In Review.
  2. Review it — run /factory-review (ideally a different model than the builder). Watch it re-run the test plan from scratch and either mark it Done or send it back with defects.

Open the issue in Linear when it's over. That comment thread — spec, build report, review report, each signed by the agent that wrote it — is your factory's paper trail. Every piece of work you ever run will look like this.

05

Turn on the loops

The factory becomes an assembly line when build and review run on timers instead of by hand. In Claude Code, open two persistent sessions:

SessionWhereCommandModel
Build lineIn the target repo/loop 5m /factory-buildCheaper executor
Review lineAnywhere with repo access/loop 5m /factory-reviewYour solid mid-tier

Every five minutes each line checks the queue, does at most one issue, and goes quiet if there's nothing to do. Your whole job collapses into the front of the line: have ideas, /factory-spec them, and watch finished work accumulate in Done.

◈ Model economics Spend your premium model where judgment lives — the spec stage — and let cheaper models execute a great plan. You don't need your most expensive model at every station of the factory; you need it at the drawing board. A deep spec makes cheap execution good.

Running unattended — the safety rules

A loop is an unattended worker. Before you leave one running:

Not on Claude Code? Any agent with a non-interactive mode can run a line: wrap its stage prompt in your scheduler of choice — an OS scheduled task, cron, or the agent's built-in scheduler — on a 5–30 minute cadence. The same four rules apply.

06

Level up

Adapting to Codex, or any other agent

The stages are platform-independent. For Codex CLI: save each stage as a markdown file in ~/.codex/prompts/ (e.g. factory-build.md) — they become /factory-build etc. — and add the Linear MCP block from Step 02. For any other agent: paste the fast-path installer prompt from Step 03 and it will translate the factory into its own native format. The only non-negotiables are the contract: the label, the four states, the Repo header, execution-verified reports, and only review sets Done.

Diagnostics

Troubleshooting

SymptomFix
Skill doesn't appear after installRestart the session (skills load at startup). On Linux/WSL, verify LF line endings — cat -A SKILL.md | head -3 must show $, never ^M$.
Skill loads, Linear calls failThe Linear connection isn't authorized yet — rerun the connector/OAuth step and ask the agent to list your teams.
Build grabs the wrong thingsCheck the Factory Queue label filter and your team name in the skill files. Unlabeled issues must be invisible to the factory.
An issue ping-pongs between agentsSomeone used BLOCKED: for "not my environment." Unreachable-repo issues must be skipped silently; BLOCKED is only for genuine spec defects.
Work marked Done that isn't doneA build stage set Done directly. Re-read the golden rule into your build skill: build ends at In Review, always.