Skip to Content
turbo-12f
Development

Extend the factory

Step-by-step recipes to add CLI verbs, UI actions, project settings, prompts, role skills, review rules, catalogues, and diagrams.

How-to guide

Follow these code-anchored recipes to add commands, settings, prompts, rule packs, catalogues, and diagrams to factory/. Run the matching unit test package after each change.

Pick your recipe

What you want to addPrimary files touchedVerification test
CLI verb & UI actioninternal/cli/, internal/ui/, internal/ui/web/go -C factory test -short ./tests/unit/cli/... ./tests/unit/ui/...
Project preferenceinternal/project/{project,schema}.go, internal/ui/prefs.gogo -C factory test ./tests/unit/project/...
Prompt or role skillprompts/*.md, skills/*/SKILL.md, skills/map.jsongo -C factory test ./tests/unit/skillmap/...
Deslop or Code review ruledeslop/*/rules.json, codereview/packs/*.jsongo -C factory test ./tests/unit/{deslop,codereview}/...
Project cataloguecatalogue/<type>.json, catalogue/templates/, project.gogo -C factory test ./tests/unit/project/...
Architecture diagramdocs-site/components/mdx/diagrams/specs/bun run verify:diagrams && bun run check:llms

Add a CLI verb and UI action

CLI-backed UI actions shell out to t12 with --by <email>, while t12-ui writes host control files (access/, approvals/, observer/) directly. Implement and test the CLI verb first.

Implement and register the CLI verb

  1. Add the verb under factory/internal/cli/ using flag.FlagSet and parse(set, args, ...) (cli.go), accepting --home and --by.
  2. Keep net/http out of internal/cli/ so TestTheCoreAndTheCageProgramsLinkNoNetworkCode keeps passing; place direct HTTP calls under factory/cmd/t12-adapter/ or factory/cmd/t12-<name>/ (v2 t12 invokes local harnesses and subprocess adapters).
  3. Register the verb in commands in cli.go or via init(), matching ask.go (ask), confirm.go (confirm), factory.go (run), and requests.go (conversation, request).

Add the UI handler and control

  1. Add a POST route to Server.Handler() in factory/internal/ui/server.go wrapped with s.signedIn(...) (plus s.operator(...) if Operator-only).
  2. In factory/internal/ui/, resolve s.requestOf or s.projectOf, check a.Editor/a.Acceptor/a.Run, and call s.command(...) or s.start(...) with --by set to v.User.Email.
  3. Update types in factory/internal/ui/web/src/api/types.ts and add a <Button> or <Confirm> in src/pages/ calling run(path, form, success) from useActions (lib/use-actions.ts).

Rebuild and test

factory/scripts/build-ui.sh
go -C factory build -o bin/ ./cmd/...
go -C factory test -short ./tests/unit/cli/... ./tests/unit/ui/...

Add a project preference

  1. Add struct field: Add the exported field and json tag to Preferences in factory/internal/project/project.go and set any non-zero default in DefaultPreferences().
  2. Register schema rule: Add a setting entry to preferenceSettings in factory/internal/project/schema.go (key, kind in kString/kSlug/kInt/kEnum/kArgv/kStrings/kGlobs/kBool, bounds/enum, help).
  3. Mark safety keys: Set safety: true whenever relaxing the key could hide defects (non-Operator edits write <home>/proposals/ until approved).
  4. Expose in UI (optional): Add the key to plainKeys in factory/internal/ui/prefs.go to show it on the plain Preferences tab.
  5. Test:
go -C factory test ./tests/unit/project/...

Add or edit a prompt or role skill

factory/factory.go embeds prompts/ and skills/ into factory.Files. Keep phrasing neutral so wording_test.go passes.

  1. Start factory/prompts/<name>.md with # <Title> on line 1, a blank line on line 2, and Version: <N> on line 3 (promptinfo.go).
  2. Increment <N> on every edit; if editing a prompt in lockedPrompts, update its version and 12-char SHA-256 prefix in factory/tests/unit/contextcreator/prompts_test.go.
  3. Test:
go -C factory test ./tests/unit/contextcreator/... ./tests/unit/skillmap/...

Add a Deslop or Code review rule

  1. Add a rule to "rules" in factory/deslop/typescript/rules.json (or factory/deslop/<stack>/rules.json matching project.Stack) with "fixtures": { "must_catch": [...], "must_not_catch": [...] }:
FieldAllowed values
id^DS-[A-F]\d+-[a-z][a-z-]*$
manifestoNon-empty array from #2, #5, #6, #8, #14, #15, #17, #18, #19, #21
tooldiff-regex, test-literal, vi-mock, clone, dead-weight, prose
action / severityaction: finding | autofix; severity: blocking | should-fix
  1. Set "status": "advisory" so Rule.FindingSeverity() emits should-fix while <home>/deslop/stats.json tracks precision (proposes promotion at >= 20 hits with 80% kept, demotion at > 25% dismissed across >= 10 hits, and guardrail-*.json after >= 3 recurring runs).
  2. Test:
go -C factory test ./tests/unit/deslop/...

Add a project catalogue

  1. Create factory/catalogue/<type>.json (^[a-z0-9][a-z0-9-]*$) with type, version (1 or higher), title, template, project, defaults, and must_haves.
  2. List must_haves in exact order (goal, users, pages, core-journey, look, out-of-scope), each with question and why_ask plus recommended on pages and look. Populate defaults with id, topic, question, default, alternatives, reason, and evidence (keeping strings compliant with wording_test.go).
  3. For buildable types, add factory/catalogue/templates/<template-name>/ (package.json, no node_modules/); leave template empty for plan-only types like desktop.json. Register <type> in ProjectTypes (factory/internal/project/project.go).
  4. Test:
go -C factory test ./tests/unit/project/...

Add or update an architecture diagram

Architecture diagrams render as theme-matched animated SVGs defined under factory/docs-site/components/mdx/diagrams/ and embed via <FactoryDiagram />.

  1. Create factory/docs-site/components/mdx/diagrams/specs/<name>.ts (or edit an existing spec) and register it in factory/docs-site/components/mdx/diagrams/index.ts.
  2. Keep zones, nodes, edges, and playback scenarios inside viewBox with zero overlaps and valid codeRef targets.
  3. Embed <FactoryDiagram name="<name>" /> (optionally with caption="...") in an MDX page, then run bun run verify:diagrams and bun run check:llms from factory/docs-site/.

Next steps

On this page