factory-next

A command that examines the current repository workflow and recommends its next factory stage, such as diagnosis or another defined action. It can run one stage when given the apply option.

In plain words
What is it for?
Use it to inspect recent stage history, see the reason for a recommendation, review alternatives, and optionally start one bounded stage.
Why use it?
It prevents developers from having to work out the next step from separate queue, state, and constraint information, and stops when the daily agent budget is blocked.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/watt-mind/factory/factory-next
Clone the repo
git clone --depth 1 https://github.com/watt-mind/factory
Per session 11 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 787 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00011 $0.00787
Opus 5 $0.00005 $0.00394
Sonnet 5 $0.00002 $0.00157
Haiku 4.5 $0.00001 $0.00079

Measured 2d ago against content hash 26d5a4f03b30, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

factory-next scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/core/commands/factory-next.md · 72 lines

How it starts

The opening of the file, as written. The whole thing — 72 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Pick one next step in the factory loop for the current repository — diagnose by default, run only when asked.

The mechanical routing lives in factory next, which reads the same queue snapshot as factory queue. Do not re-derive gates from Linear yourself.

1. Resolve repo

Default: match the current working directory against config/repos.yaml. $ARGUMENTS may name a repo (bj29) or pass flags (--apply, --orchestrated, --include-sweep, --harness pi).

2. Diagnose

From the factory checkout (or any cwd with factory on PATH):

factory state --repo <repo>
factory next --repo <repo> $ARGUMENTS

Show session history from factory state (what ran earlier in this harness window), then constraint, recommend, because, and any also alternates from factory next. Both record events to ~/.factory/state/events.jsonlrecommend on every next run, start on --apply.

If budgetBlocked is set, stop — no new agent stages today.

3. Apply (only when $ARGUMENTS contains --apply)

One bounded stage, then stop. Do not loop until idle — that is the supervisor's job, not /factory-next.

  • If the recommendation is a slash command (/factory-merge, /factory-triage, /factory-work, …), run that command's skill/body in this session — one pass, default caps (5 triage, 3 at a time work, 10 unblock).
  • If --orchestrated is present and the recommendation is tick or reconcile, run the printed exec line instead.
  • If the recommendation is (wait) with no command, report why and do not spawn work.

Alternatively, delegate execution to the script:

factory next --repo <repo> --apply [--orchestrated] [--harness <harness>] $OTHER_FLAGS

Use the script path when running headless via run-agent.sh; use the slash command path when you are already in an interactive harness.

4. Report

State what ran (or what was recommended), the queue constraint in one line, and anything waiting on a human (blocked holds — suggest factory digest --repo <repo>).

Read the full file on GitHub · 72 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 72 lines · 11 tokens per session scan A 26d5a4f03b30

Subscribe to this mod's changes

factory-next is a command published in the GitHub repository watt-mind/factory (10 stars, last pushed 2d ago), licensed Apache-2.0. It adds 11 tokens to every session and 787 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.