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.
Your smartest model interrogates the idea and writes a build-ready plan.
A cheaper model implements the plan and proves it works by running it.
An independent agent re-verifies everything. Only review can mark work done.
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:
| Element | Convention |
|---|---|
| Queue | A Linear team (free tier is fine). Every factory work item is a Linear issue. |
| Label | Factory Queue — agents only ever touch issues carrying this label. |
| States | Todo (specced) → In Progress (building) → In Review (awaiting QA) → Done |
| Golden rule | Only 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 format | Every spec starts with a Repo: header naming the working directory, and ends with testable acceptance criteria. |
| Identity | Every build/review report opens with Agent: <platform / model> so you always know who did what. |
YOUR_TEAM_NAME in everything below.Factory Queue (Settings → Labels). This is the conveyor belt — it's how factory work stays separate from everything else in your workspace.Todo, In Progress, In Review, Done. No custom states needed.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:
[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.
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.
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.
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.
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.
--- 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.
# <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>
---
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.
--- 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.
\r in the frontmatter makes the skill silently fail to register. If a skill won't appear, check this first.factory-) because a bare name like review can collide with your platform's built-in commands and get shadowed.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.
/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.
/factory-build. Watch it claim the issue, branch, implement, run the tests, post its BUILD REPORT, and move the issue to In Review./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.
The factory becomes an assembly line when build and review run on timers instead of by hand. In Claude Code, open two persistent sessions:
| Session | Where | Command | Model |
|---|---|---|---|
| Build line | In the target repo | /loop 5m /factory-build | Cheaper executor |
| Review line | Anywhere with repo access | /loop 5m /factory-review | Your 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.
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.
/loop 5m /factory-build webapp makes a session work only issues whose Linear project or labels match "webapp". Run one lane per repo.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.
| Symptom | Fix |
|---|---|
| Skill doesn't appear after install | Restart 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 fail | The Linear connection isn't authorized yet — rerun the connector/OAuth step and ask the agent to list your teams. |
| Build grabs the wrong things | Check 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 agents | Someone 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 done | A build stage set Done directly. Re-read the golden rule into your build skill: build ends at In Review, always. |