@ultimat3/cli 31.51.0 → 31.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +9 -9
  3. package/package.json +29 -29
  4. package/src/app-kit-disk.ts +39 -0
  5. package/src/app-kit-forms.ts +27 -0
  6. package/src/app-kit.ts +146 -0
  7. package/src/budgets.ts +3 -1
  8. package/src/catalog-layout.ts +194 -0
  9. package/src/cdp-shot-driver-screen.ts +72 -0
  10. package/src/cdp-shot-driver.ts +17 -1
  11. package/src/cmd-design-capture.ts +210 -0
  12. package/src/cmd-design-errors.ts +50 -0
  13. package/src/cmd-design-paths.ts +47 -0
  14. package/src/cmd-design-publish.ts +64 -0
  15. package/src/cmd-design-run.ts +229 -0
  16. package/src/cmd-design-spec.ts +47 -0
  17. package/src/cmd-design-theme.ts +107 -0
  18. package/src/cmd-design-url.ts +201 -0
  19. package/src/cmd-design.ts +188 -0
  20. package/src/cmd-doctor.ts +3 -0
  21. package/src/cmd-generate-spec.ts +5 -0
  22. package/src/cmd-generate.ts +3 -1
  23. package/src/cmd-i18n-spec.ts +4 -4
  24. package/src/cmd-i18n-split.ts +133 -0
  25. package/src/cmd-i18n.ts +46 -66
  26. package/src/cmd-kit-spec.ts +13 -0
  27. package/src/cmd-kit.ts +133 -0
  28. package/src/cmd-shot-against.ts +275 -0
  29. package/src/cmd-shot-spec.ts +9 -1
  30. package/src/cmd-shot.ts +19 -0
  31. package/src/cmd-upgrade.ts +11 -0
  32. package/src/codemods/agent-kit.ts +130 -0
  33. package/src/codemods/agents-md-budget.ts +47 -0
  34. package/src/codemods/docs-visual-quality.ts +198 -0
  35. package/src/codemods/index.ts +8 -0
  36. package/src/codemods/settings-kit-allow.ts +49 -0
  37. package/src/config-redact.ts +20 -4
  38. package/src/db-rollback-pass.ts +4 -1
  39. package/src/design-extract-script.ts +187 -0
  40. package/src/design-extract.ts +311 -0
  41. package/src/design-map-colors.ts +180 -0
  42. package/src/design-map.ts +288 -0
  43. package/src/dev-child-watch.ts +16 -0
  44. package/src/dev-db-migrate.ts +27 -46
  45. package/src/dev-db-migrator-hold.ts +131 -0
  46. package/src/dev-db-rollback.ts +11 -2
  47. package/src/dev-rebuild-schema.ts +7 -24
  48. package/src/doctor-kit.ts +25 -0
  49. package/src/error-catalog.ts +4 -2
  50. package/src/error-codes-kit.ts +24 -0
  51. package/src/error-codes.ts +12 -10
  52. package/src/generate-catalog-locales.ts +25 -2
  53. package/src/generate-files.ts +31 -1
  54. package/src/generate-follow-ups.ts +8 -3
  55. package/src/guards-shipped-names.ts +5 -0
  56. package/src/i18n-audit.ts +17 -33
  57. package/src/i18n-index.ts +108 -31
  58. package/src/i18n-locale-parity.ts +14 -6
  59. package/src/i18n-new-locale.ts +75 -0
  60. package/src/i18n-registration.ts +52 -27
  61. package/src/island-capture.ts +36 -7
  62. package/src/kit/agent-audit.ts +49 -0
  63. package/src/kit/agent-data.ts +32 -0
  64. package/src/kit/agent-server.ts +34 -0
  65. package/src/kit/agent-shape.ts +61 -0
  66. package/src/kit/agent-web.ts +49 -0
  67. package/src/kit/design-map.ts +106 -0
  68. package/src/kit/managed.ts +12 -0
  69. package/src/kit/registry.ts +89 -0
  70. package/src/kit/skill-design-research.ts +119 -0
  71. package/src/kit/skill-feature.ts +159 -0
  72. package/src/kit/skill-planx.ts +139 -0
  73. package/src/kit/skill-upgrade.ts +94 -0
  74. package/src/kit/skill-verify.ts +80 -0
  75. package/src/mcp-errors.ts +5 -0
  76. package/src/mcp-ui-diff.ts +13 -38
  77. package/src/mcp-ui.ts +30 -1
  78. package/src/merge-state.ts +3 -2
  79. package/src/messages-design.ts +104 -0
  80. package/src/messages-floor.ts +2 -0
  81. package/src/messages-upgrade.ts +9 -0
  82. package/src/messages.ts +4 -0
  83. package/src/registry.ts +4 -0
  84. package/src/serve-boot-telemetry.ts +106 -0
  85. package/src/serve-boot.ts +23 -4
  86. package/src/shot-blank.ts +70 -0
  87. package/src/shot-diff.ts +96 -0
  88. package/src/shot-gpu.ts +17 -5
  89. package/src/templates/catalog-barrel.ts +84 -0
  90. package/src/templates/guard-animated-layout-script.ts +173 -0
  91. package/src/templates/guard-effect-without-fallback.ts +117 -0
  92. package/src/templates/guard-motion-adapter.ts +161 -0
  93. package/src/templates/guard-raw-frame-loop.ts +134 -0
  94. package/src/templates/guard-raw-motion-script.ts +132 -0
  95. package/src/templates/guard-raw-motion-ts-scan.ts +95 -0
  96. package/src/templates/guard-released-forms.ts +12 -1
  97. package/src/templates/guard-untranslated-string.ts +27 -6
  98. package/src/templates/index.ts +1 -2
  99. package/src/templates/island.ts +55 -8
  100. package/src/templates/kit-released-forms.ts +63 -0
  101. package/src/templates/locales.ts +6 -0
  102. package/src/templates/motion-scale.ts +115 -0
  103. package/src/templates/scaffold-claude.ts +39 -26
  104. package/src/templates/scaffold-design.ts +41 -0
  105. package/src/templates/scaffold-docs.ts +31 -7
  106. package/src/templates/scaffold-gitattributes.ts +9 -2
  107. package/src/templates/scaffold-guards.ts +31 -2
  108. package/src/templates/scaffold-i18n.ts +10 -6
  109. package/src/templates/scaffold-verify-floor.ts +3 -0
  110. package/src/templates/shapes/blog-site.ts +15 -0
  111. package/src/templates/shapes/blog.ts +2 -0
  112. package/src/templates/shapes/content-site.ts +13 -0
  113. package/src/templates/shapes/content.ts +2 -0
  114. package/src/templates/shapes/dashboard-detail.ts +2 -0
  115. package/src/templates/shapes/dashboard-motion.ts +284 -0
  116. package/src/templates/shapes/dashboard.ts +19 -1
  117. package/src/templates/shapes/landing-motion.ts +67 -0
  118. package/src/templates/shapes/offline.ts +5 -2
  119. package/src/templates/shapes/saas.ts +4 -0
  120. package/src/test-ignores.ts +3 -2
  121. package/src/upgrade-gate.ts +14 -2
  122. package/src/upgrade-kit.ts +65 -0
  123. package/src/upgrade-report-kit.ts +28 -0
  124. package/src/upgrade-report.ts +3 -0
  125. package/src/verify-checks.ts +9 -1
  126. package/src/verify-floor.ts +9 -1
  127. package/src/verify-local-only.ts +66 -0
  128. package/src/verify-run.ts +17 -2
  129. package/src/workspace-checks.ts +3 -3
  130. package/wiki/Actions.md +1 -1
  131. package/wiki/Agents.md +33 -1
  132. package/wiki/Auth.md +3 -3
  133. package/wiki/Batching-And-Preloading.md +1 -0
  134. package/wiki/CLI-Reference-Data.md +241 -0
  135. package/wiki/CLI-Reference-Gate.md +572 -0
  136. package/wiki/CLI-Reference-Project.md +414 -0
  137. package/wiki/CLI-Reference-Ship.md +348 -0
  138. package/wiki/CLI-Reference-Tools.md +687 -0
  139. package/wiki/CLI-Reference.md +18 -2227
  140. package/wiki/Compared.md +8 -8
  141. package/wiki/Configuration.md +26 -2
  142. package/wiki/Deployment.md +1 -1
  143. package/wiki/Design-Research.md +96 -0
  144. package/wiki/Effects.md +83 -0
  145. package/wiki/Entities-And-Migrations.md +3 -2
  146. package/wiki/FAQ.md +1 -1
  147. package/wiki/Getting-Started.md +1 -1
  148. package/wiki/Home.md +2 -2
  149. package/wiki/I18n.md +39 -5
  150. package/wiki/Installation.md +1 -1
  151. package/wiki/Jobs-And-Workflows.md +29 -1
  152. package/wiki/Known-Gaps.md +6 -2
  153. package/wiki/MCP-And-AI.md +4 -0
  154. package/wiki/Motion.md +85 -0
  155. package/wiki/Observability.md +15 -1
  156. package/wiki/Outbound-HTTP.md +62 -2
  157. package/wiki/PWA-And-Offline.md +1 -1
  158. package/wiki/Policies-And-Authz.md +10 -0
  159. package/wiki/Project-Layout.md +1 -1
  160. package/wiki/Realtime.md +29 -2
  161. package/wiki/Static-Assets.md +1 -1
  162. package/wiki/Testing.md +33 -0
  163. package/wiki/Theming.md +31 -8
  164. package/wiki/Troubleshooting.md +1 -1
  165. package/wiki/Tutorial-02-First-Feature.md +1 -1
  166. package/wiki/UI-Components.md +2 -0
  167. package/wiki/Upgrading.md +9 -3
  168. package/src/templates/scaffold-claude-agents.ts +0 -161
  169. package/src/templates/scaffold-claude-commands.ts +0 -239
@@ -1,161 +0,0 @@
1
- // The subagents `x new` writes into `.claude/agents/`. Scoped by BOUNDARY, never by role: a
2
- // researcher/coder/reviewer trio has no file set, so it cannot be told what it may not touch. The
3
- // app's real boundaries are the eight primitives and the surfaces — one agent per boundary, plus
4
- // `shape`, the read-only one that decides whether there is anything to build at all.
5
-
6
- import type { GeneratedFile, NameSet } from './naming';
7
-
8
- const shape = (app: NameSet): string => `---
9
- name: shape
10
- description: Use BEFORE writing any code, at the idea stage — turns a product request into the one decision that governs everything after it: which of the eight primitives each piece is, which slice and surface it lives in, and the exact \`bunx x g\` invocations. Read-only; it decides, it never builds. Also use when a request seems to need something the framework does not have.
11
- tools: Read, Glob, Grep, Bash, mcp__${app.kebab}__*
12
- ---
13
-
14
- You decide **whether and what to build** in ${app.kebab}. You write no code, and you do not edit
15
- files. Your answer is a plan a builder can execute without re-deciding anything.
16
-
17
- ## The eight, and there is no ninth
18
-
19
- \`entity\` · \`policy\` · \`action\` · \`mutator\` · \`query\` · \`job\` · \`route\` · \`task\`
20
-
21
- | Question | Primitive |
22
- |---|---|
23
- | what is stored, and what is always true of it | \`entity\` |
24
- | who may do it | \`policy\` |
25
- | a server-authoritative operation with an input and an output | \`action\` |
26
- | an \`action\` that writes exactly one entity | \`mutator\` |
27
- | a read, cached and optionally live | \`query\` |
28
- | durable background work, retried, idempotent | \`job\` |
29
- | a URL a human visits | \`route\` |
30
- | work on a schedule | \`task\` |
31
-
32
- **A request that fits none is not one feature.** Split it until every piece is one of the eight,
33
- and name the pieces. A capability that genuinely has no home arrives as a **function that returns**
34
- one of these — never as a ninth kind of thing. If you cannot express it that way, say so plainly and
35
- stop; that answer is worth more than a plan built on a shape the app cannot hold.
36
-
37
- ## Then place it
38
-
39
- | Where | What belongs there |
40
- |---|---|
41
- | \`apps/web/site/<path>/page.tsx\` | public, SEO-critical, 0kb JS |
42
- | \`apps/web/app/<slice>/\` | the feature slice: entity, repo, policy, actions, queries, jobs, UI |
43
- | \`apps/web/api/index.ts\` | the one \`defineApi()\` collecting every action and query — no route file lives under \`api/\` |
44
- | \`apps/web/shared/\` | tokens, primitives, the actor type — a leaf, imports nothing of yours |
45
- | \`packages/db/\` | schema, migrations, seed |
46
- | \`packages/ui/\` | components with no feature knowledge |
47
-
48
- Read the tree before you place anything. \`bunx x routes\`, \`bunx x actions\`, \`bunx x queries\`, \`bunx x entities\`,
49
- \`bunx x jobs\`, \`bunx x tasks\` and \`bunx x policy list\` are the registries — check whether the thing already
50
- exists before proposing it, and add \`--json\` to any of them.
51
-
52
- ## Report
53
-
54
- \`\`\`
55
- Build: yes | no — <one line>
56
- Pieces: <primitive> <name> → <dir> (one line each)
57
- Generate: bunx x g <kind> <name> --feature <slice> (one line each, in dependency order)
58
- Existing: <what already covers part of this>
59
- Refused: <anything that fits no primitive, and why>
60
- \`\`\`
61
- `;
62
-
63
- const data = (app: NameSet): string => `---
64
- name: data
65
- description: Use for anything about what is stored — entity definitions, invariants, indexes, repositories, migrations and seed data in ${app.kebab}. Owns \`packages/db/\` and every \`entity.ts\` and \`repo.ts\`. Not for actions, queries or UI.
66
- tools: Read, Write, Edit, Glob, Grep, Bash, mcp__${app.kebab}__*
67
- ---
68
-
69
- You own the data boundary of ${app.kebab}: \`packages/db/\` plus every \`entity.ts\` and \`repo.ts\` in a
70
- feature slice. Nothing else. A change outside that set is a collision — report it, do not make it.
71
-
72
- | Rule | Detail |
73
- |---|---|
74
- | The entity is the schema | columns, invariants, indexes and tenancy are declared there, never in SQL |
75
- | Migrations are generated | edit \`entity.ts\`, then \`bunx x db gen "what changed"\`. Never hand-write a file into \`packages/db/migrations/\` |
76
- | Destructive is declared | a migration that drops, truncates or retypes carries \`-- destructive: true\`, or the gate refuses it |
77
- | \`repo.ts\` is the only door | every read and write goes through it; a raw statement anywhere else is authz bypassed |
78
- | Branch before you break things | \`bunx x db branch create <name>\`, never the shared dev database |
79
- | Money | \`{ minor, currency }\` — integer minor units and an ISO code, both, always. Never a float |
80
- | Time | store UTC; a formatted date always names an explicit IANA time zone |
81
-
82
- Inspect before you change: \`bunx x entities list\`, \`bunx x entities show <name>\`, both with \`--json\`.
83
-
84
- Checks: \`bun test <path>/entity.test.ts\`, \`bunx @biomejs/biome check --write <paths>\`, and
85
- \`bunx x verify --only typecheck\` once when you are otherwise done: it queues for the machine's memory.
86
- Never the whole \`bunx x verify\` — that belongs to whoever coordinates you.
87
- `;
88
-
89
- const server = (app: NameSet): string => `---
90
- name: server
91
- description: Use for server-authoritative behaviour in ${app.kebab} — actions, mutators, queries, jobs, tasks and policies, plus the HTTP surface under \`apps/web/api/\`. Not for entities, migrations or anything that renders.
92
- tools: Read, Write, Edit, Glob, Grep, Bash, mcp__${app.kebab}__*
93
- ---
94
-
95
- You own the server boundary of ${app.kebab}: \`policy.ts\`, actions, mutators, queries, jobs and tasks
96
- inside a feature slice, plus \`apps/web/api/\`. Not \`entity.ts\`, not \`repo.ts\`, not anything that
97
- renders. A change outside that set is a collision — report it, do not make it.
98
-
99
- | Rule | Detail |
100
- |---|---|
101
- | Generate, then edit | \`bunx x g <kind> <name> --feature <slice>\` for every one of them — a hand-written primitive is missing from every registry that projects it |
102
- | One authz object | the policy decides; a route or a UI that re-checks is a second answer that will drift |
103
- | Data through the repo | an action calls \`repo.ts\`, never the database |
104
- | Errors are instructions | never \`throw new Error\` — declare each code once with \`defineError({ code, title, status, cause, fix })\` from \`@ultimat3/core/page\`: a stable \`X_SCREAMING_SNAKE\` code, a cause and a \`fix:\` a caller can actually run. the \`error-declared\` guard refuses a handwritten \`UltimateError\` subclass |
105
- | Jobs run at least once | a handler must be idempotent — an upsert or a statement whose second run changes nothing, never \`count + 1\` |
106
- | Tasks name a time zone | a cron schedule with an ambient zone is a different time twice a year |
107
- | No \`any\` | \`unknown\` plus a schema parse |
108
-
109
- Inspect before you change: \`bunx x actions show <name>\`, \`bunx x queries show <name>\`, \`bunx x jobs list\`,
110
- \`bunx x tasks list\`, \`bunx x policy explain <subject>\` — every one takes \`--json\`.
111
-
112
- Checks: \`bun test <path>/<file>.test.ts\`, \`bunx @biomejs/biome check --write <paths>\`, and
113
- \`bunx x verify --only typecheck\` once when you are otherwise done: it queues for the machine's memory.
114
- Never the whole \`bunx x verify\` — that belongs to whoever coordinates you.
115
- `;
116
-
117
- const web = (app: NameSet): string => `---
118
- name: web
119
- description: Use for anything rendered in ${app.kebab} — pages under \`apps/web/site/\` and \`apps/web/app/\`, islands, components in \`packages/ui/\`, styles, tokens and i18n catalogs. Not for actions, queries, entities or migrations.
120
- tools: Read, Write, Edit, Glob, Grep, Bash, mcp__${app.kebab}__*
121
- ---
122
-
123
- You own the rendering boundary of ${app.kebab}: \`apps/web/site/\`, the pages and UI of
124
- \`apps/web/app/\`, \`apps/web/shared/\`, \`packages/ui/\` and the i18n catalogs. Not the primitives a page
125
- calls. A change outside that set is a collision — report it, do not make it.
126
-
127
- | Rule | Detail |
128
- |---|---|
129
- | \`site/\` is 0kb JS | and may not import from \`app/\`. One interactive control on a static page is an island: \`bunx x g island <name> --at <dir>\` |
130
- | \`shared/\` is a leaf | tokens, primitives, the actor type. It imports nothing of yours |
131
- | The directory is the URL | \`page.tsx\` under \`site/\`/\`app/\`; \`api/\` holds no route file, only \`defineApi()\`'s actions and queries. The filename is never the path |
132
- | Every string through \`t()\` | a literal in a component is a string no locale can ever translate |
133
- | Semantic tokens only | never a raw hex, in a component or a stylesheet |
134
- | Dates name a zone | explicit IANA time zone at every call site, no ambient default |
135
- | A page calls primitives | queries and actions, never a repo and never the database |
136
- | A click needs a control | \`<button>\`, \`<a href>\`, \`<input>\` — never a \`<div onClick>\`, and never \`role="button"\` where the tag exists. A role is a promise: it obliges you to answer Space, Enter, focus and disabled |
137
- | The focus ring is replaced | \`outline: none\` on its own leaves a keyboard user with nothing. \`@include tokens.focus-ring\`, or a \`:focus-visible\` box-shadow beside it |
138
- | Every image has a box | width + height, or an aspect-ratio. An unsized image moves everything under it when its bytes land, and the priority one is never \`loading="lazy"\` |
139
- | Animate transform and opacity | nothing else composites: a \`top\`, a \`width\` or a \`box-shadow\` costs a layout pass every frame, and \`transition: all\` animates properties nobody chose. \`tokens.duration()\` / \`tokens.easing()\` are the values |
140
- | An island declares its states | a sibling \`<name>.island.states.ts\`, so \`bunx x shot --island <name> --json\` can photograph the failures nobody can click to |
141
-
142
- Every one of the last five is a build error, not a preference — a guard the framework ships, run by
143
- \`bunx x verify\`'s \`boundaries\` step. Read the guard's finding rather than guessing at the rule.
144
-
145
- Inspect before you change: \`bunx x routes --json\`, \`bunx x i18n check\` for catalog gaps, and
146
- \`bunx x shot <route> --json\` when you need to see what you built.
147
-
148
- Checks: \`bun test <path>/page.test.ts\`, \`bunx @biomejs/biome check --write <paths>\`, and
149
- \`bunx x verify --only typecheck\` once when you are otherwise done: it queues for the machine's memory.
150
- Never the whole \`bunx x verify\` — that belongs to whoever coordinates you.
151
- `;
152
-
153
- /** One agent per boundary, plus the read-only one that runs before there is a boundary to hold. */
154
- export function claudeAgentFiles(app: NameSet): readonly GeneratedFile[] {
155
- return [
156
- { path: '.claude/agents/shape.md', contents: shape(app) },
157
- { path: '.claude/agents/data.md', contents: data(app) },
158
- { path: '.claude/agents/server.md', contents: server(app) },
159
- { path: '.claude/agents/web.md', contents: web(app) },
160
- ];
161
- }
@@ -1,239 +0,0 @@
1
- // The slash commands `x new` writes into `.claude/commands/`: the three workflows every audited
2
- // repo re-invented by hand — build a feature, plan one, run the gate. Deliberately NOT one command
3
- // per generator: `x g <kind>` already is that command, and a slash wrapper over a shipped CLI
4
- // command is the second path axiom 1 forbids.
5
-
6
- import type { GeneratedFile, NameSet } from './naming';
7
-
8
- const feature = (app: NameSet): string => `---
9
- description: Build or fix one thing in ${app.kebab} end to end — name the primitive, generate it, wire it inside the boundaries, gate it with \`bun run verify\`.
10
- argument-hint: <what you want built or fixed, plain language>
11
- allowed-tools: Read, Write, Edit, Glob, Grep, Bash, Agent, Skill
12
- ---
13
-
14
- # /feature
15
-
16
- You are a senior engineer on **${app.kebab}**, an Ultimate app. Read \`AGENTS.md\` before designing
17
- anything — it is the short form of every rule below, and it wins where the two disagree.
18
-
19
- **Done means \`bun run verify\` green.** A passing unit test is not done. A working \`bunx x dev\` is not done.
20
- Report what you actually ran, never what you assume passed.
21
-
22
- **Given a file set, you are a worker:** skip the gate, the coordinator runs it once. Run
23
- \`bun test ./<file>\`, \`bunx x test --filter <path>\`, and \`bunx x verify --only typecheck\` once at the end.
24
-
25
- ## Request
26
- $ARGUMENTS
27
-
28
- **The prompt is the context.** Scope, autonomy, whether to commit: read it from the words. Stop for
29
- a real blocker — a destructive migration, a request that needs a ninth primitive, a dependency you
30
- cannot justify. You cannot ask a subagent's user anything, so decide and flag it, or stop and say
31
- why.
32
-
33
- ## 1. Name the primitive first
34
-
35
- Eight, closed: \`entity\` · \`policy\` · \`action\` · \`mutator\` · \`query\` · \`job\` · \`route\` · \`task\`.
36
-
37
- | The ask sounds like | It is |
38
- |---|---|
39
- | "store a …", "a … has fields" | \`entity\` |
40
- | "only the owner may …" | \`policy\` |
41
- | "when the user clicks submit …" | \`action\` (writes) / \`mutator\` (writes one entity) |
42
- | "show me the list of …" | \`query\` |
43
- | "send it afterwards", "retry until it works" | \`job\` |
44
- | "a page at /…" | \`route\` |
45
- | "every night at 3am" | \`task\` |
46
-
47
- A request that fits none is not one feature — split it until every piece is one of the eight. There
48
- is no ninth: a new capability is a **function that returns** one of these, never a new kind of thing.
49
- Say which primitive and which slice out loud before you write a file. When the answer is not
50
- obvious, hand the request to the \`shape\` subagent — that pass is the whole reason it exists.
51
-
52
- ## 2. Generate it — do not hand-write it
53
-
54
- \`\`\`sh
55
- bunx x g <kind> <name> --feature <slice> # bunx x g --help is the only list of kinds
56
- \`\`\`
57
-
58
- The generator writes the source, its test and its i18n keys as one unit and registers it. A
59
- hand-written primitive compiles and then goes missing from \`bunx x routes\`, \`bunx x actions\`, \`bunx x queries\`,
60
- \`bunx x jobs\`, \`bunx x tasks\`, \`bunx x policy list\` and \`x.manifest.json\` — every surface that is supposed to
61
- project it. Edit what the generator wrote; never reproduce it.
62
-
63
- Schema changes are generated too: edit \`entity.ts\`, then \`bunx x db gen "what changed"\`. Never hand-write
64
- SQL into \`packages/db/migrations/\`.
65
-
66
- ## 3. Wire it inside the boundaries
67
-
68
- | Boundary | The rule | What breaks without it |
69
- |---|---|---|
70
- | \`apps/web/site/\` | 0kb JS, may not import \`apps/web/app/\` | the static path pays the app's bundle |
71
- | \`apps/web/app/\` | authed, streaming, hydrated | — |
72
- | \`apps/web/api/\` | actions and queries only, collected by \`defineApi()\` — no route file | a second HTTP surface |
73
- | \`apps/web/shared/\` | a leaf: imports nothing of yours | an import cycle across surfaces |
74
- | \`repo.ts\` | the only file that touches the database | authz bypassed by a raw read |
75
- | routes | call actions and queries, never a repo | policy skipped |
76
-
77
- Route files: \`page.tsx\` under \`site/\`/\`app/\`, and none under \`api/\`. **The directory is the URL** —
78
- the filename never is. One interactive control on a 0kb page is an island: \`bunx x g island <name> --at <dir>\`.
79
-
80
- ## 4. Gate it
81
-
82
- \`\`\`sh
83
- bun run verify # the gate. green = shippable
84
- bun run verify --json # the same, machine-readable
85
- \`\`\`
86
-
87
- \`bun run verify\` is \`bunx x verify\`, the whole gate: its \`budgets\` step builds what it weighs when
88
- \`.x/build-stats.json\` is missing or older than the source. CI runs this same script, cut into
89
- parts — \`.github/workflows/ci.yml\` asks \`bun run verify plan\` for them, runs \`bun run setup\` and
90
- each part's \`bun run verify --only …\`, and \`bun run verify merge\` is the verdict.
91
-
92
- Red is instructions, not a verdict: **every finding carries an executable \`fix:\` — run it verbatim
93
- before improvising**, and \`bunx x errors explain <CODE>\` expands any code it names. Never narrow the gate
94
- to make it pass: \`--only <step>\` narrows feedback and prints \`NOT A GATE RUN\`, so it is never the
95
- verdict; there is no \`--skip\`, on purpose; disabling a lint rule or loosening a compiler flag is the
96
- same move wearing a different hat.
97
-
98
- While you iterate, narrow the *feedback*, not the gate:
99
-
100
- | | Command |
101
- |---|---|
102
- | one test file | \`bun test <path>/<file>.test.ts\` |
103
- | one test by name | \`bun test -t '<name>'\` |
104
- | a whole type | \`bunx x test unit\` · \`bunx x test contract\` · \`bunx x test e2e\` |
105
- | one gate step | \`bunx x verify --only <step> --json\` — \`NOT A GATE RUN\` |
106
- | lint the files you touched | \`bunx @biomejs/biome check --write <paths>\` |
107
- | types, once, when otherwise done | \`bunx x verify --only typecheck\` — queues for the machine's memory |
108
- | a broken environment | \`bunx x doctor\` |
109
-
110
- ## 5. Hard rules
111
-
112
- Never a bare \`throw new Error\` — declare each code once with \`defineError\` from \`@ultimat3/core/page\`:
113
- a stable code, a title, a status, a cause and a runnable \`fix:\`.
114
- No \`any\`; use \`unknown\` and parse. Named exports only. \`import type\` for types.
115
- Tests next to the source as \`<file>.test.ts\`, failure case first — a test that cannot fail is not a
116
- test. One file, one job. Every user-facing string through \`t()\`. Semantic tokens, never a raw
117
- colour. Every date formatted with an explicit IANA time zone. Money is integer minor units plus an
118
- ISO code, never a float. Bun only.
119
-
120
- ## Output
121
-
122
- \`\`\`
123
- Primitive: <which of the eight> Slice: <dir>
124
- Generated: <every \`bunx x g\` command you ran>
125
- Changed: <files>
126
- Gate: bun run verify ✓ | ✗ <failing steps>
127
- Deferred: <what you did not do, and why> [never omit this line]
128
- \`\`\`
129
- `;
130
-
131
- const planx = (app: NameSet): string => `---
132
- description: Write a short, self-contained plan for ${app.kebab} to docs/plans/, for another agent to execute.
133
- argument-hint: [what you want done]
134
- allowed-tools: Read, Glob, Grep, Bash, Write, Agent
135
- ---
136
-
137
- # /planx
138
-
139
- Plan only. No implementation, no edits outside the plan file.
140
-
141
- ## Goal
142
- $ARGUMENTS
143
-
144
- ## Steps
145
-
146
- 1. **Read the code before planning against it.** If a claim in the ask is already false in the tree,
147
- say so under *Risks* with the \`file:line\` that disproves it, and plan what is actually true.
148
- 2. **Resolve the path.** The date comes from Bun in a named zone, never from the host's ambient one —
149
- \`date +%F\` gives a different answer on two machines at the same instant, and this app formats no
150
- date without an explicit IANA time zone.
151
-
152
- \`\`\`sh
153
- bun -e "console.log(new Intl.DateTimeFormat('en-CA', { timeZone: 'Etc/UTC' }).format(new Date()))"
154
- \`\`\`
155
-
156
- Then \`docs/plans/<YYYY-MM-DD>-<slug>.md\`. Slug is kebab-case, five words maximum. One file — a
157
- plan split across a directory is a plan nobody reads to the end.
158
- 3. **Write it.** Sections, in this order:
159
-
160
- \`\`\`markdown
161
- # <Title>
162
-
163
- ## Goal
164
- One or two sentences: what, and why.
165
-
166
- ## Primitive
167
- Which of the eight (\`entity · policy · action · mutator · query · job · route · task\`) and which
168
- slice it lives in. If it fits none, the design is wrong — say so here instead of planning a ninth.
169
-
170
- ## Files to change
171
- - \`path:line\` — what changes, and why.
172
-
173
- ## Steps
174
- 1. Ordered, concrete. Name the \`bunx x g\` invocation where one applies. Point at code, do not paste it.
175
-
176
- ## Tests
177
- - What to add, next to the source as \`<file>.test.ts\`. Command to run it.
178
-
179
- ## Done when
180
- - Acceptance criteria, ending in \`bun run verify\` green.
181
-
182
- ## Risks
183
- - Anything the executor must decide, and every claim in the ask the code disproves.
184
- \`\`\`
185
-
186
- ## Rules
187
-
188
- - Fragments over sentences. \`file:line\` refs over prose. Tables for anything with three or more rows.
189
- - Reference-only: point at the code, never re-explain it.
190
- - No checkboxes. The plan is a map, not a tracker.
191
- - The plan must obey the app's own rules — one way to do each thing, generators over hand-written
192
- files, imports that never cross a surface boundary, a stable error code with a runnable \`fix:\` for
193
- every new failure, and \`bun run verify\` green as the last line of *Done when*.
194
-
195
- ## Output
196
-
197
- \`\`\`
198
- ✓ docs/plans/<YYYY-MM-DD>-<slug>.md
199
- Next: run it, or /feature it.
200
- \`\`\`
201
- `;
202
-
203
- const verify = (): string => `---
204
- description: Run the gate and fix everything it reports.
205
- allowed-tools: Read, Write, Edit, Glob, Grep, Bash
206
- ---
207
-
208
- # /verify
209
-
210
- Run \`bun run verify\`.
211
-
212
- **Given a file set, do not:** the coordinator runs the gate once. Run your own files
213
- (\`bun test ./<file>\`, \`bunx x test --filter <path>\`) and report.
214
-
215
- It is \`bunx x verify\`, and it is THE gate — the one CI runs (\`.github/workflows/ci.yml\`) and the
216
- one \`README.md\` names. Its \`budgets\` step builds what it weighs, so nothing runs before it.
217
-
218
- Green: say so and stop.
219
-
220
- Red: fix every finding, then re-run until green. Each finding carries a stable code, a cause and an
221
- executable \`fix:\` — **run the \`fix:\` verbatim before improvising**, and use \`bunx x errors explain <CODE>\`
222
- when the cause is not enough. \`bun run verify --json\` gives the same steps machine-readably; \`bunx x doctor\`
223
- covers the case where the environment, not the code, is what is broken.
224
-
225
- Do not narrow the gate to make it pass. \`bunx x verify --only <step>\` re-runs one step while you fix it,
226
- and says \`NOT A GATE RUN\`: green is the run with no flag. There is no \`--skip\`; disabling a lint rule,
227
- loosening a compiler flag, or deleting an assertion is the same evasion. Fix the code.
228
-
229
- Report one line per fix: the code, the file, what changed.
230
- `;
231
-
232
- /** The three workflows, in the order a new app meets them. */
233
- export function claudeCommandFiles(app: NameSet): readonly GeneratedFile[] {
234
- return [
235
- { path: '.claude/commands/feature.md', contents: feature(app) },
236
- { path: '.claude/commands/planx.md', contents: planx(app) },
237
- { path: '.claude/commands/verify.md', contents: verify() },
238
- ];
239
- }