/rails-flow:feature <feature description> [--pack small|standard]from rails-flow
Orchestrated feature development — plan, spec-first implementation, quality gates, PR, tool-gated merge
Ships in rails-flow. Installing the plugin adds it to Claude Code.
Agents are named by role (developer, migrations, test_runner, reviewer, security, design_auditor), resolved from the project's stack: see reference/stack-roles.md. When the stack names no agent for a role, STOP and ask; never use a Rails agent by default.
Build the requested feature end-to-end using the orchestrated flow below. You are the orchestrator: delegate to the rails-flow subagents, keep your own context lean, and never skip a gate. Hooks enforce the guardrails mechanically — do not fight them.
--pack standard (the default) is the full pipeline. --pack small runs the same phases with
fewer delegated specialists, for a change whose blast radius is genuinely small — a copy fix, a
one-line guard, a rename.
small | standard | |
|---|---|---|
| plan, criteria, spec-first loop | yes | yes |
| Phase 4 quality gates | all of them | all of them |
the reviewer role | yes | yes |
spec-reviewer | yes | yes |
the security role, the design_auditor role | only if their trigger fires | only if their trigger fires |
substantial units delegated to the developer role | you may do them directly | delegated |
Three things this is not. It does not skip a gate — Phase 4 is identical at every size, because
pack size is about how many specialists review, not whether the work is proven. It is not three
plugins that differ by subsetting, which plugin-boundaries rule 2 forbids. And the agent does not
choose its own size: scope is the human's call, and an agent that downgraded itself when a job
looked small would be judging exactly the thing it is worst at.
A smaller pack must say what it did not run. The final report names the specialists that were
skipped — "reviewed by the reviewer role only; the security role not run (no auth/API/data change)". A
run that quietly did less is the failure mode; a run that says so is a decision the reviewer can see.
The default is unchanged, deliberately. A flag you must opt out of to get rigour is the wrong way round.
CLAUDE.md and GUARDRAILS.md. If either is missing, tell the user and offer
/rails-flow:setup-flow before proceeding.dev if it exists, else the repository default. All work
branches from and PRs into the base. Feature PRs never target main when dev exists.git status); stash/park anything unrelated.If the issue is a slice (its body opens Slice S<n> of <spec>, or Slice S<n>. when the plan
named no source; filed by /rails-flow:slice,
#1369), its AC-n lines are this unit's criteria, copied verbatim into
docs/product/acceptance/<unit-slug>.md. They are the criteria the owner approved for this slice
alone. The spec then supplies only the Seam:, the Out of scope and the decisions, never more
criteria; turning every story in the spec into criteria would build other slices' work on this
branch and break the order /slice filed.
Otherwise, if a spec exists, plan from it (docs/product/specs/<slug>.md, written by /rails-flow:spec,
#1375). Its stories become the criteria, its Testing decisions' Seam: is where the specs go, and
its Out of scope bounds the plan. Do not re-derive in the session what the spec already decided. If
the feature needs decisions no spec records, and it is more than one slice, offer
/rails-flow:spec first.
Delegate codebase exploration to a subagent so raw file contents stay out of your context: which models/controllers/views/jobs the feature touches, existing patterns to reuse, and schema impact. Then produce a short plan:
migrations role)${CLAUDE_PLUGIN_ROOT}/scripts/security_scope.py over the plan text and the planned paths (#2117). Exit 0: record Security: no new boundary. Exit 1 (a public or token route, upload, webhook, MCP tool, outbound fetch, auth or role change, personal column): run /rails-flow:secure-design NOW, before the criteria below; its Security requirements become criteria. Exit 2 is "could not classify", not "none".Every unit gets criteria, recorded in docs/product/acceptance/<unit-slug>.md (the layout's home for WHAT we are building; a pre-layout docs/product/acceptance/ is still recognised by the gate, #910) — the slug is the
branch name after feature/, with any remaining / flattened to - (so feature/team/foo
→ docs/product/acceptance/team-foo.md). One ## section per unit:
## Invoice totals
- **AC-1** Given an invoice with two line items, when the user opens the invoice page, then
the footer shows the summed amount formatted as currency
- **AC-2** Given an invoice with no line items, when POST /invoices runs, then the response is
422 and the modal re-renders with "must have at least one line item" [error]
The shape is fixed: Given <state>, when <action>, then <observable>. Each
criterion carries a stable id (AC-1, AC-2, …) — the id is what the proving spec cites, and
what makes "the spec proves the criteria" checkable rather than a claim.
Every criterion must name an action and an observable. If it names neither, it will be rubber-stamped:
| Bad | Why | Good |
|---|---|---|
| "handles invalid input" | no action, no observable | "Given a blank email, when the user submits the form, then the field shows 'can't be blank' and no user is created" |
| "login works" | asserts nothing | "Given a wrong password, when the user submits the sign-in form, then the page shows 'wrong email or password' and does NOT redirect to the dashboard" |
| "errors handled gracefully" | unfalsifiable | "Given an invoice with no line items, when POST /invoices runs, then the response is 422 and the modal re-renders with 'must have at least one line item'" |
At least one error-path criterion per unit — tag it [error] or state a failure case.
Happy-path-only criteria are rejected: most real defects live on the error path, and every
security finding this flow has produced downstream was an error or edge path.
Security criteria (#2118). When the unit has a threat model (/rails-flow:secure-design,
docs/security/threat-models/<slug>.md), every row it marks mitigate needs a criterion tagged [security] that cites the row's ID as (TM-n) or covers: TM-n at the end of the criterion. check_criteria.py finds the model beside the acceptance file and refuses a mitigate row no
[security] criterion cites, and a [security] criterion that cites no row or an accept, transfer or eliminate row.
Validate before implementing, and again once specs exist:
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/check_criteria.py" "docs/product/acceptance/<slug>.md"
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/check_criteria.py" "docs/product/acceptance/<slug>.md" --specs spec
Exit 0 clean · 1 findings · 2 unusable (no file, or no criteria in it). On findings,
rewrite the criterion — never soften the check. The Stop gate runs this too, so a branch whose
criteria do not hold cannot finish.
Why this precedes code: a criterion written afterwards asserts what the code happens to do rather than what was required, which is unfalsifiable — the same defect class as a gate that cannot fail, moved from the gate to the goal. If you cannot evaluate it, you cannot iterate on it unattended. The checker proves each criterion is traceable to a spec; it cannot prove the spec truly asserts the observable, so that judgement stays yours.
Run /rails-flow:handoff (or write docs/product/handoff/<slug>.md in its shape) before Phase 3. It is the
one file an executor can work from with no conversation history: the goal, the criteria ids it is
graded by, the files in and explicitly out of scope, the guardrails in play, the stop conditions,
how to verify, and what to record on completion.
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/check_handoff.py" "docs/product/handoff/<slug>.md" \
--criteria "docs/product/acceptance/<slug>.md"
Why it comes after the criteria and before the code: the work order cites the criteria rather
than restating them, so writing it first would either duplicate a contract that does not exist yet or
invent one. And its stop conditions bind Phase 3 and Phase 4 — the attempt cap, the no-progress
detector, and the four forbidden escapes (weakening a failing spec, reverting a passing unit to
unblock this one, editing outside the declared scope, disabling a guardrail or hook) govern the loops
below, and an executor cannot honour a bound nobody wrote down. See /rails-flow:handoff for the
defaults and the reasoning.
Once the criteria (and the work order, spec or threat model, when they exist) are written, ask whether the plan owes a Fable design review before anything is built:
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/advisory_scope.py" --slug <slug>
Exit 0: optional, or already recorded. Exit 1: REQUIRED. The plan crosses a security boundary, changes structure (a
plugin, agent, command, skill, hook, gate or descriptor key), the data model or a dependency, or spans six or more components.
Then:
advisory_scope.py --begin --slug <slug> writes the record header and a snapshot of the plan as reviewed.plan-advisor agent (model fable) on the plan files; append its answer verbatim to
docs/evidence/reviews/plans/<slug>/plan-advisor.md.Disposition A-n: accepted | <what changed in the plan>, rejected | <why>, or
deferred | #<issue>. Never drop one.advisory_scope.py --stamp --slug <slug>. It refuses when a finding is
undisposed, the revised plan triggers a category the review did not see, or more than 30% of it changed: run a new pass.VERDICT: RETHINK blocks until a fresh pass on the revised plan says PROCEED, or an
Override: <who> | <reason, 20+ characters> | #<issue> line records who decided.The Stop gate runs this check once criteria exist, and project_gates.py runs it in the sweep gh pr ready requires, so a
required advisory cannot be skipped. Exit 2 means no plan files for the slug: write the criteria first.
Post the plan and the criteria to the user, then proceed — the gates below are the control points, not a plan-approval pause. The one exception is a change a user can see; see the mock-up gate below. If the plan reveals genuine ambiguity about intent, ask first: criteria are the place ambiguity surfaces cheapest.
The owner's rule: a user-visible change is not built until the owner has approved a clickable mock-up of it. The trigger is what the change touches, not the issue's label: a feature, an enhancement and a bug fix that alters a screen all count. Classify the plan's files:
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/check_mockup_gate.py" --paths <each file the plan names>
mockup-gate: off in GUARDRAILS.md.
Proceed./design-flow:canvas, /design-flow:port) is an optional way to draw it, not the way a
screen enters the project. No recorded shell yet? (docs/product/mockups/shell.md
missing, which the gate reports.) The first change is the shell: mock up the core layout,
navigation and foundation screens, following the design system, get them approved, then
record them with check_mockup_gate.py --adopt-shell. Format and rules:
${CLAUDE_PLUGIN_ROOT}/reference/mockup-record.md.docs/product/mockups/<slug>.md (committed on the branch once Phase 2
creates it), one line each:
Mock-up: (link or committed file), Issue:, Approved-by:, Approval: (the link to the
comment where the owner approved), Widths:, States: (;-separated, every state designed
or n/a: <reason>), Shell: (always docs/product/mockups/shell.md), Template:, Screen:
and Nav:. Then proceed. Once the screen is built (before Phase 6) add Story:, the story
file or view that implements it; the gate on the real diff refuses a record without one. The plan and the PR
cite the record.The same check runs again on the branch's real diff before merge (Phase 6), so a view the plan did not name cannot slip past it.
For a feature whose shape the owner has to live with — a new billing model, a state machine, a
tenancy change — offer /rails-flow:explain plan before Phase 2. It restates the plan in plain
language for a non-specialist, so a wrong premise is caught for the price of a paragraph
instead of a build cycle. It writes nothing; it is a go/no-go, not a document.
git checkout <base> && git pull
git checkout -b feature/<kebab-slug>
The work order's stop conditions apply from here to the end of Phase 4. On a stop: write the diagnosis (what was tried, the exact failure signature, the suspected cause), move to the next independent unit, and say in the final report that the run was partial. A partial run reported as complete is worse than a stop, because it spends the reviewer's trust as well as their time.
it "AC-2 rejects an invoice with no line items" do — so the
mapping from criterion to proof is mechanical, not remembered. The spec must prove the NEW
behavior (wrong-role rejection for new filters, concern behavior, state transitions), not
merely execute the code. Run it; confirm it fails for the right reason.
A criterion no spec cites is an unproven criterion, and the Stop gate says so.
A project with a QA catalogue (qa/test-cases.csv) also gets the manual case that proves the new behaviour, in this same PR: add or update the case, and put the issue
in its Source (defect:#n). No feature is built without a way to test it in QA (owner rule, #1853); see reference/case-per-change.md.developer role; schema changes to
the migrations role (round-trip proven). Small edits you may do directly.git add <specific files> and commit with an
imperative message. One unit per commit.Run in order; loop fixes back through Phase 3 until every gate passes:
reviewer role on the branch diff → must end VERDICT: CLEAN
1b. spec-reviewer with docs/product/acceptance/<slug>.md, the base, and its own file
docs/evidence/reviews/prs/<branch-slug>/spec-reviewer-findings.jsonl → must end VERDICT: CLEAN, with
check_spec_review.py exit 0 (#1370). It asks only whether the diff does what the criteria
say: criteria missing, partial or misread, and behaviour nobody asked for. Report it under its
own Spec heading beside the reviewer role's Standards, and never merge or re-rank the two.
A change can pass one and fail the other, and a merged list lets one hide the other.test_runner role → FULL suite, 0 failuressecurity role → only if auth, authorization, APIs, or data handling changeddesign_auditor role → only if views/partials/Stimulus changedthe test_runner role proves the suite is green. Green says nothing about whether the specs would catch a
regression: expect(invoice).to be_present passes forever and proves nothing. Phase 3 already makes
the mapping from criterion to proof mechanical — the spec cites AC-2 — and the citation is
enforced while the proof is not. A spec can cite AC-2 and assert something trivially true.
So, for the unit's changed code only, mutate it and re-run the specs that cite its criteria:
bundle exec mutant run --since HEAD~1 # or the project's tool, from config
A surviving mutant is reported against the criterion whose spec missed it, never as a bare number:
AC-2's spec passes withline_items.any?inverted — the criterion is cited but not proven.
That wording is the deliverable. "Coverage is 78%" tells you nothing you can act on; the sentence above names the criterion, the mutation, and what to write next.
It is advisory on purpose, and this is not timidity. Equivalent mutants — changes that do not
alter behaviour — survive legitimately, and no tool eliminates them. A blocking gate would refuse
correct code on its first real input, which is exactly what killed the monotony gate in #476:
"a gate that needs a carve-out on its first real input is taste wearing a count."
Scope it strictly to the changed unit. A whole-suite mutation run takes long enough that a flow demanding one gets skipped, and a skipped gate is worse than an advisory one. The tool and its flags live in project config, never here — tool names rot inside a quarter, which is why the model ladder lives there too.
The project may not have a mutation tool configured. Then say so in one line and move on: "no mutation tool configured; the specs are green and unproven." That is an honest statement, and inventing a tool name would not be.
small, name what did not runOne line in the report, listing the specialists skipped and why. Absent, the reader cannot tell a small pack from a standard one that quietly did less — which is the whole risk this flag carries, and the reason it is stated rather than inferred.
git push -u origin feature/<slug>
gh pr create --base <base> --title "feat: <summary>" --body "<the PR Documentation Contract — see below>"
<branch-slug>, used for every review record below (docs/evidence/reviews/prs/<branch-slug>/…), is the branch name with each / replaced by
-, the prefix kept: feature/team/foo is feature-team-foo. It is NOT the <unit-slug> of the criteria files (the name after feature/).
risky_diff.py derives it the same way, so a record written at that path is the one the gate looks for (#2264).
If the code-review-graph CLI is present with a built graph
(command -v code-review-graph && [ -d .code-review-graph ]): run its review-pr
skill with the PR number (installed per-project by code-review-graph install;
since v2.x it is a plain skill — no plugin namespace). Supplement with
code-review-graph impact on the changed files for blast-radius evidence.
Otherwise: delegate to pr-reviewer with the PR number.
A self-written review comment is the OUTPUT of a review, not the review. BLOCKED → fix on the same branch, push, re-run the gate. Repeat until CLEAN.
On CLEAN, check the mock-up gate on the real diff (#1376):
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/check_mockup_gate.py" --base <base>. Exit 1 means the
diff changes what a user sees and no approved mock-up is recorded: stop, and run the Phase 1
mock-up gate. Exit 2 means it could not classify; stop and hand the merge to the user.
On CLEAN, check the requirement registry when qa/requirements.yml exists (#1857): save the PR body to a file (the draft you gave gh pr create --body-file, or
gh pr view <n> --json body -q .body > <file>) and run python3 "${CLAUDE_PLUGIN_ROOT}/scripts/check_registry_closed.py" --closes-from-body <file>. It reads every closing
keyword GitHub honours (Closes #12, fixes #12, Resolved #12, any case), not only Fixes. A registry row that points at an issue this PR closes must be updated in this
same PR: status done and closed: true once its spec proves it, or, for an issue closed as not planned, owner-decision or deviates (never done), or issue pointed at
the issue that tracks the rest. Exit 1: update those rows, push, run it again. Exit 2: it could not check (no gh, GitHub unreadable, a repeated key in the registry): say what
it could not read; an unchecked registry is not a clean one. Exit 3 is only "no registry", and exit 0 continues.
On CLEAN, check the case is in the diff when qa/test-cases.csv exists (#1858): python3 "${CLAUDE_PLUGIN_ROOT}/scripts/check_case_in_diff.py" --base <base> --closes-from-body <PR body file> --kind feature.
Every issue the PR closes needs a catalogue case that THIS diff adds or changes, with the issue in its Source. Exit 1: add the case, push, run it again. Exit 2: it could
not check (say what); exit 3: no catalogue, nothing to check against.
On CLEAN, classify the door (#1338):
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/classify_door.py" --base <base>. Exit 1 (ONE-WAY: a
destructive migration, an auth or permission change, a removed route or API field, a new outside
call) or exit 2 (could not classify) means stop and hand the merge to the user, quoting the
reasons it printed. A dropped column's data does not come back with git revert. Exit 0 continues.
On CLEAN, check whether the diff is risky (#1819):
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/risky_diff.py" --base <base> --record docs/evidence/reviews/prs/<branch-slug>/adversary.md.
A diff that touches authentication, sessions, access rules, input parsing or a privacy filter needs one adversarial pass before
the PR is marked ready: exit 1 means run the adversary agent (it runs on Fable, the owner's model for attack passes) with the
printed reasons and the base, save its answer verbatim to that path (its first line is Head: <sha>, its last is
VERDICT: CLEAN or VERDICT: BLOCKED), and run the check again. Exit 0 continues. A BLOCKED record also exits 1 (never 3: the project
gates read 3 as not applicable, #1873): that is a finding for the user, so stop, quote the findings and hand the merge over; you do not decide
its disposition. Only the user's line Override: <who> | <reason, 20+ characters> | #<issue> in that record lets it through. Exit 2 means it
could not classify: stop. The check is registered as adversary-review (checks.json), so the sweep gh pr ready requires fails without it
(#2264); risky_diff.py with no --record finds the record from the branch name. Mark the PR ready with risky_diff.py ... && gh pr ready,
never ;. A record is tied to the commit it names, so a push after the pass needs a new one.
On CLEAN, verify the threat model when the change adds or edits one (docs/security/threat-models/<slug>.md, #2119):
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/check_security_review.py". security-auditor is MANDATORY then, not "if auth changed": give it the model and the
base, and save its answer verbatim to docs/evidence/reviews/prs/<slug>/security-audit.md: first line Head: <sha>, one line per mitigate and accept row
(TM-n: implemented <file:line>, TM-n: not implemented, TM-n: holds <why>, TM-n: stale <what changed>), last line VERDICT: CLEAN or VERDICT: BLOCKED.
Exit 1: run the pass on this HEAD (the record is missing, stale or leaves a row out). Exit 3: a mitigate row is not implemented, an accept row has gone stale
or the verdict is BLOCKED; that is a finding for the user, so stop and quote it. Exit 2: it could not read the model or the base. The check is also a project_gates.py gate,
so a missing or stale record turns the sweep red and gh pr ready is refused without a green sweep for HEAD; a push after the pass needs a new one.
On CLEAN and a two-way door: if the base is dev, merge (gh pr merge --squash), then post a summary
comment citing the gate's findings. If the base is the default branch (no dev), stop
after CLEAN and hand the merge decision to the user — and offer them a PR babysitter:
/loop "Check PR #<n>: if CI failed, read the log, fix on the branch, push; address new review comments; if merged, say MERGED" --interval 10m --expires 8h.
Close-out rule: a PR is finished only when every review thread is resolved —
each actionable comment fixed on this branch (push, reply with the commit) or folded
into a tracked repo issue and linked back. Sweep with /rails-flow:pr-comments <n>
after the gate and after any human review lands. Do not start the next unit, phase,
or task while the current PR has unresolved feedback.
Run doc-updater for the session's changes. Report to the user: plan → commits → gate
results → PR link → docs touched. State the outcome as complete, partial, or stopped — and if it
is not complete, list by name what was not attempted. Record on completion what the work order's last
section asks for; a work order whose completion is never recorded taught nobody anything.
If this feature changed how the product behaves for its owner — not merely how it is built —
run /rails-flow:explain <area> so docs/GUIDE.md moves with the code. doc-updater reports
when an area has gone stale but deliberately does not rewrite the explanation itself.
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
26 commands in this plugin
/brain/rails-flow:brain — $ARGUMENTSInstitutionalize a lesson or decision as a docs/brain memo, indexed in MEMORY.md/brain-review/rails-flow:brain-review — $ARGUMENTSWeekly maintenance sweep of docs/brain — flag stale STATUS/evidence, surface decisions-vs-PRD drift and contradictions, compress patterns, and check hypotheses against evidence. Read-only analysis + proposed edits; never rewrites silently./brain-sync/rails-flow:brain-sync — $ARGUMENTSnpx claudepluginhub fmanimashaun/claude-skills --plugin rails-flowOther plugins' commands for the same job