@jskit-ai/agent-docs 0.1.328 → 0.1.329

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 (30) hide show
  1. package/guide/agent/app-extras/assistant.md +115 -2
  2. package/guide/agent/app-setup/authentication.md +16 -0
  3. package/guide/agent/app-setup/package-with-nix.md +118 -0
  4. package/guide/agent/app-setup/upgrading-jskit.md +21 -2
  5. package/guide/agent/framework/security-pass.md +136 -0
  6. package/guide/agent/framework/speed-pass.md +194 -0
  7. package/guide/agent/framework/ux-pass.md +116 -0
  8. package/guide/agent/index.md +11 -0
  9. package/package.json +1 -1
  10. package/patterns/minimal-foundation/example/package.json +2 -2
  11. package/patterns/shell-foundation/example/package.json +3 -3
  12. package/reference/autogen/PATTERN_INDEX.md +31 -31
  13. package/reference/autogen/packages/assistant-core.md +3 -3
  14. package/reference/autogen/packages/assistant-runtime.md +18 -3
  15. package/reference/autogen/packages/auth-provider-local-core.md +11 -4
  16. package/reference/autogen/packages/workspaces-core.md +7 -0
  17. package/reference/autogen/tooling/jskit-catalog.md +33 -0
  18. package/skills/jskit/SKILL.md +9 -4
  19. package/skills/jskit/references/package-with-nix.md +113 -0
  20. package/skills/jskit/references/pattern-index.md +31 -31
  21. package/skills/jskit/references/patterns/app/minimal-foundation/example/package.json +2 -2
  22. package/skills/jskit/references/patterns/app/shell-foundation/example/package.json +3 -3
  23. package/skills/jskit/references/patterns/auth/accounts-hub/example/package.json +1 -1
  24. package/skills/jskit/references/patterns/auth/oidc-sign-in/example/package.json +2 -2
  25. package/skills/jskit/references/patterns/realtime/realtime-application/example/package.json +2 -2
  26. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users/package.json +1 -1
  27. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/package.json +2 -2
  28. package/skills/jskit/references/security-pass.md +131 -0
  29. package/skills/jskit/references/speed-pass.md +189 -0
  30. package/skills/jskit/references/ux-pass.md +111 -0
@@ -0,0 +1,131 @@
1
+ <!-- Generated from `packages/agent-docs/site/guide/framework/security-pass.md`. -->
2
+
3
+ # Security pass
4
+
5
+ A security pass makes an app refuse what it should. Genesis's security pass
6
+ skill (`genesis-security-pass`) holds the method: map every way in, work
7
+ through authorization, sign-in, input, secrets, production settings and
8
+ dependencies, prove each finding by sending the input that breaks it, and keep
9
+ a test that fails without each fix. This page says where each of those lives in
10
+ a JSKIT app. The rules it applies are already in [Typed features](typed-features.md),
11
+ [Data access](data-access.md), [Authentication](/guide/app-setup/authentication),
12
+ [Workspace tenancy](multi-homing.md) and the [sanity checks](sanity-checks.md).
13
+
14
+ ## Who may call each route and action
15
+
16
+ - A route's `auth` is `"public"` unless it says otherwise, so a route
17
+ registered without `auth` answers anyone. List every `/api` route with its
18
+ `auth` (`"required"`, or `"own"` with `ownerParam` naming the route parameter
19
+ that must be the signed-in user's id) and its `permission`, and keep each
20
+ public route public on purpose.
21
+ - A workspace route registers under `/api/w/:workspaceSlug/...` with
22
+ `contextPolicy: "required"`: the server resolves the workspace and the
23
+ caller's membership from the slug and the session, and answers 404 or 403
24
+ before the handler runs
25
+ ([Workspace-scoped features and routes](multi-homing.md#workspace-scoped-features-and-routes)).
26
+ - A surface's access policy guards pages in the browser only; the server reads
27
+ just `requireWorkspaceMembership: false` from it. A page hidden by
28
+ `requireAnyPermissions`, or a command whose `useCommand({ runPermissions })`
29
+ is false, still needs the route's own `auth` and `permission`.
30
+ - An action's `permission` is checked by the kernel before its input. A route
31
+ that bypasses actions, reading with `await request.callOptions()`, runs no
32
+ action permission, so its own `auth` and `permission` are its only gate
33
+ ([Layer 1](data-access.md#layer-1-the-table-resource)).
34
+ An action on the `automation` channel is a tool the assistant may call as
35
+ the typing user.
36
+ - A rule that depends on the role reads `hasPermission(context.permissions, …)`,
37
+ never `includes()`, which misses `*` and `bookings.*` grants, and lists the
38
+ permission in `roleCatalog.customPermissions`
39
+ ([Role permissions](multi-homing.md#role-permissions)).
40
+
41
+ ## Rows stay in their workspace
42
+
43
+ - A table resource's `ownership` (`workspace`, `user`, `workspace_user`,
44
+ `workspace_or_shared`, `system` or `public`) and its row policy scope every
45
+ handle call to the call's `options.context`, and only the owner feature
46
+ reaches the table ([The resource is the only door](data-access.md#the-resource-is-the-only-door)).
47
+ Knex past the handle, a repository that drops the call's `options`, or a
48
+ context built by hand skips that scope: search for each. Confirm every
49
+ `public` table is meant to be read by anyone.
50
+ - Who acts is `resolveActor(context)`; the workspace comes from the context
51
+ only, never from the body or another input
52
+ ([Request context](typed-features.md#request-context)). A row
53
+ policy decides from `caller` and the server-resolved `context.workspace`,
54
+ `context.membership` and `context.permissions`, never from request input.
55
+ - Jobs declare `systemScope` and narrow `systemContext(reason)` with
56
+ `forWorkspace`, `forUser` or `forWorkspaceUser`; work done as one member runs
57
+ in `workspaces.memberContext(…)`, which refuses a removed member as their
58
+ request would ([Background work](data-access.md#background-work)).
59
+ - `expectScoped()` from `@jskit-ai/resource-runtime/test` runs a path as owner
60
+ A before and after seeding owner B, and fails when B's rows change A's answer
61
+ or B's rows change ([Tests](data-access.md#tests)). Give each
62
+ workspace path one.
63
+
64
+ ## Sign-in, sessions and limits
65
+
66
+ - Auth's routes are limited per client address, and local auth makes an
67
+ account wait after repeated failures; both are on by default.
68
+ `config.auth.rateLimits` changes a limit and `false` removes one: a removed
69
+ limit is a finding unless the person chose it. Behind a proxy,
70
+ `TRUSTED_PROXIES` names it, or every client shares one count
71
+ ([Sign-in protection](/guide/app-setup/authentication#sign-in-protection)).
72
+ - Any other route that repetition can abuse (sending email or codes,
73
+ invitations, costly reads, calls to a paid service) declares
74
+ `rateLimit: { max, timeWindow }`, refused with 429 `kernel.http.rateLimited`.
75
+ Each limit gets a test expecting the 429.
76
+ - Sign-in cookies are httpOnly, and in production `Secure` with the `__Host-`
77
+ prefix; `AUTH_COOKIE_SAME_SITE` is `lax` or `strict`
78
+ ([Sign-in cookies and SameSite](/guide/app-setup/authentication#sign-in-cookies-and-samesite)).
79
+ Every unsafe `/api` method checks its CSRF token unless the route sets
80
+ `csrfProtection: false`; each route that does must authenticate its request
81
+ another way, as the pass sign-in route does with its signed pass.
82
+ - A dangerous action asks for a recent second factor with `secondFactor`
83
+ where the app uses one, and password-only sign-in sets
84
+ `AUTH_LOCAL_PASSWORD_MIN_LENGTH=15`
85
+ ([Second factor](/guide/app-setup/authentication#second-factor-local-auth)).
86
+ - Password recovery and a new confirmation link answer the same whether or not
87
+ an account exists. Give the app's own invitation, lookup and sign-up routes
88
+ the same answer.
89
+
90
+ ## Production settings and secrets
91
+
92
+ - `NODE_ENV=production`, set by the Deployment's Serve step, is JSKIT's only
93
+ production switch. There local auth requires `AUTH_LOCAL_SESSION_SECRET`,
94
+ refuses `AUTH_DEV_BYPASS_ENABLED` and `AUTH_LOCAL_RECOVERY_DEV_OUTPUT`, and
95
+ refuses to start without a confirmation sender while anyone may register
96
+ ([Production settings](sanity-checks.md#production-settings)).
97
+ - On an empty production database the first account needs the setup code
98
+ (403 `auth.local.setup.codeRequired`), so whoever reaches a new deployment
99
+ first cannot own it. A registration or admin bootstrap of the app's own
100
+ needs the same protection
101
+ ([The first account in production](/guide/app-setup/authentication#the-first-account-in-production-local-auth)).
102
+ - `AUTH_LOCAL_SESSION_SECRET` and every other secret live in private Env, read
103
+ on the server, and the Deployment generates the session secret. Nothing
104
+ secret goes in `config/public.js`, which the browser imports, or in a
105
+ committed `.env` file or example.
106
+ - An internal failure is a plain `Error`, which the caller sees as "Internal
107
+ server error."; an `AppError`'s message is shown at any status, so it never
108
+ carries internals
109
+ ([Internal failures are plain errors](typed-features.md#internal-failures-are-plain-errors)).
110
+ - `config.securityHeaders` sets the security headers. Production adds
111
+ transport security, framing protection and a content security policy that is
112
+ reported, not enforced, by default; enforce it once the pages run without
113
+ violations, and read the headers on a production build
114
+ ([Security headers](/guide/app-setup/initial-scaffolding#security-headers)).
115
+
116
+ ## Try each refusal
117
+
118
+ - Boot the server in a route test and sign each person in over `app.inject`,
119
+ one cookie jar each, sending the session's `csrfToken` as `csrf-token` with
120
+ every write ([Tests](data-access.md#tests)).
121
+ - Send each attack and expect its refusal: no session (401
122
+ `auth.session.required`), a member without the route's permission (403), a
123
+ slug of a workspace the caller is not in (403), another workspace's record id
124
+ and `workspaceId` in the body (refused, or answered in the caller's own
125
+ workspace), a write without `csrf-token`, and one request past each
126
+ `rateLimit` (429). A body that does not validate, sent without a session,
127
+ must get the refusal, not field errors.
128
+ - Production settings: start the server with `NODE_ENV=production` and the
129
+ test database, and check that it stops without `AUTH_LOCAL_SESSION_SECRET`,
130
+ that registering asks for the setup code, and the response headers.
131
+ - Run `npm audit` and `npm run verify`.
@@ -0,0 +1,189 @@
1
+ <!-- Generated from `packages/agent-docs/site/guide/framework/speed-pass.md`. -->
2
+
3
+ # Speed pass
4
+
5
+ A speed pass makes an app and its tests take the time their work needs.
6
+ Genesis's speed pass skill (`genesis-speed-pass`) holds the method: measure
7
+ each wait first on a realistic build at realistic sizes, fix its cause, measure
8
+ again the same way, and never raise a time limit, add retries, or shrink
9
+ realistic data or coverage to get faster. This page says where each wait lives
10
+ in a JSKIT app and which JSKIT tools measure and fix it. The rules it applies
11
+ are already in [Typed features](typed-features.md),
12
+ [Client features](client-features.md),
13
+ [Data access](data-access.md) and the
14
+ [sanity checks](sanity-checks.md). Query counts, narrowing and
15
+ indexes belong to the [data pass](data-pass.md): when a wait is
16
+ database time, apply that page to the path.
17
+
18
+ ## Test speed
19
+
20
+ ### Measure
21
+
22
+ - `jskit test` starts by saying how many test files it runs at a time and
23
+ where that number came from (`V64_TEST_CONCURRENCY`, or half of the
24
+ machine), and ends with its 10 slowest test files and tests; each file's time
25
+ is kept in `node_modules/.cache/jskit-test/file-times.json`. Time the whole
26
+ command too (`time npm test`): a wall time close to the sum of the files'
27
+ times means they ran one after another
28
+ ([Test files run in parallel](typed-features.md#test-files-run-in-parallel)).
29
+ - Test database preparation reports each phase and its duration
30
+ ([Test databases are prepared once](typed-features.md#test-databases-are-prepared-once)).
31
+ Read them: slow preparation otherwise hides inside the first test that waits
32
+ for it.
33
+ - Every Playwright run through `browserTestConfig()` ends with its 10 slowest
34
+ tests. Compare a slow spec's time with the time of the app's requests it
35
+ makes, so you know whether the test or the app is slow.
36
+
37
+ ### Fix
38
+
39
+ - Scripts run `jskit test` (`jskit test --databases` for database tests), and
40
+ Playwright and Vitest take their workers from `testConcurrency()`. `jskit
41
+ check` reports a script that runs `node --test` directly, passes a fixed
42
+ concurrency or pins `V64_TEST_CONCURRENCY`, and a Playwright or Vitest config
43
+ that runs files one at a time ([test-run rules](typed-features.md#test-run-rules)).
44
+ - Files that collide are isolated, never run one at a time: a port from
45
+ `listen(0)`, a directory from `mkdtemp`, the database `jskit test --databases`
46
+ gives each file, and a Vite `cacheDir` of its own. The
47
+ `// jskit-test: alone - <reason>` marker is only for a file that holds a
48
+ resource of the whole machine.
49
+ - `jskit test --databases` restores each file's database from a snapshot
50
+ rebuilt only when the migrations' digest changes. A file that runs
51
+ `knex.migrate.latest()` itself replays the whole history for every file:
52
+ remove it, and let the full history run once in its own check.
53
+ - A fixture every file only reads (a built app, a composed project, a
54
+ generated tree) is made once, before any file starts, by a global setup
55
+ module: `jskit test --test-global-setup=tests/helpers/globalSetup.js`
56
+ (`jskit test` passes its arguments to `node --test`). Its `globalSetup()`
57
+ makes the fixture and puts its location in an environment variable the test
58
+ processes inherit; its `globalTeardown()` removes it. A file run on its own
59
+ makes the fixture itself when the variable is absent, and a test that writes
60
+ into the fixture makes its own copy.
61
+ - `browserTestConfig()` builds the production frontend once and gives each
62
+ worker its own server, port and seeded database; with a `signIn` module
63
+ each worker signs in once. A check of what a component shows belongs in a
64
+ Vitest component test, and a new browser check is an assertion in the spec
65
+ that already reaches that screen.
66
+ - Wait for the condition, never for time: Playwright's web-first assertions
67
+ (`await expect(locator).toBeVisible()`, `await expect(page).toHaveURL(...)`)
68
+ instead of `page.waitForTimeout()`. The app's own delays (retry backoff,
69
+ debounce, polling) run on a fake clock: `mock.timers` in `node:test`,
70
+ `vi.useFakeTimers()` in Vitest and `page.clock` in Playwright.
71
+ - A file imports what it needs at its top level, so loading counts against the
72
+ file, not against a test's time limit. `jskit test` keeps Node's compile
73
+ cache in `node_modules/.cache/jskit-node-compile-cache`, so each file's
74
+ process loads the modules the files before it compiled.
75
+ - The bounds stay: `jskit test`'s 10 minutes a file and 45 a run,
76
+ `browserTestConfig()`'s `actionTimeout` (15 s), `navigationTimeout` (30 s)
77
+ and `globalTimeout`. A bound in `test-time-bounds.json` rises only with a
78
+ measurement of the work's real need; a file that got slow is fixed instead.
79
+
80
+ ### Prove
81
+
82
+ Run the whole suite before and after on the same machine with the same
83
+ `V64_TEST_CONCURRENCY`, and report the wall time, each preparation phase, the
84
+ slowest files and the test counts, which stay the same.
85
+
86
+ ## Client speed
87
+
88
+ ### Measure
89
+
90
+ - Build with `npm run build` and read Vite's report: every chunk with its
91
+ size and its gzip size. `dist/index.html` names the entry script and the
92
+ chunks it preloads (`<link rel="modulepreload">`): together they are the
93
+ JavaScript every page loads before it shows anything. Vite's warning about
94
+ a chunk over 500 kB is a finding to follow to its import, never a limit to
95
+ raise with `build.chunkSizeWarningLimit`.
96
+ - Serve that build and open each main screen with a cold cache. In a
97
+ Playwright spec, `page.on("request", ...)` counts the `/api` requests a
98
+ screen or an action makes; look for the same request twice, one request per
99
+ row, and requests made on a timer.
100
+
101
+ ### Fix
102
+
103
+ - **Screens load with their routes.** A page under `src/pages` loads as its
104
+ own chunk when its route is first visited. A library one page uses is
105
+ imported by that page or a component it shows, never by `src/main.js`, a
106
+ client provider or a layout every page renders. A heavy component that a
107
+ page shows only sometimes loads with
108
+ `defineAsyncComponent(() => import("./HeavyChart.vue"))`.
109
+ - **Packages keep their screens out of every page.** Each client provider is
110
+ exported by a subpath of its own, and its file imports only what every page
111
+ needs ([Provider subpaths](client-features.md#provider-subpaths)).
112
+ A provider without one, or a `./client` that declares `routeComponents` or
113
+ `clientRoutes` or uses `export *`, brings all of `./client` to every page.
114
+ On the accounts starter, loading users-web's provider through its subpath
115
+ instead of all of its `./client` took the JavaScript a page loads before it
116
+ starts from 1,302 KB to 778 KB.
117
+ - **One request for related records.** A list shows its related records with
118
+ `include` and the including contract's `includeFields`, in the same request,
119
+ never with a request per row; `fields[<type>]` narrows what an included
120
+ record carries ([Layer 2: the CRUD surface](data-access.md#layer-2-the-crud-surface)).
121
+ A picker reads its selected values past the loaded page by id, all in one
122
+ request (`filter[id]`, which `useCrudListFilterLookups()` sends for a lookup
123
+ filter), and searches on the server with `q`
124
+ ([Wire list search with the initial resource](crud-operations.md#wire-list-search-with-the-initial-resource),
125
+ [Search on the server](client-features.md#search-on-the-server)).
126
+ - **One read for the same data.** Read through http-web's composables
127
+ (`useList`, `useView` and the CRUD screens), which keep each read under its
128
+ query key, so components showing the same list with the same parameters
129
+ share one request, instead of a `fetch` of their own in each component.
130
+ - **Events, not polling.** A list or record refreshes on the realtime events
131
+ that change it: a read composable's `realtime` option or
132
+ `useRealtimeQueryInvalidation()` marks the matching reads stale and reads
133
+ again only those a mounted screen uses, at most twice a query for a burst of
134
+ events
135
+ ([Realtime](/guide/app-extras/realtime#event-contract)). A `setInterval`
136
+ that refetches is a finding.
137
+ - **Render what is visible.** A long list reads pages and renders with pages
138
+ or `v-virtual-scroll`
139
+ ([Screens](sanity-checks.md#screens)).
140
+
141
+ ### Prove
142
+
143
+ Report the entry chunk and its preloads (gzip) from the build before and
144
+ after, the requests each main screen and action makes, and the main actions'
145
+ time from click to result on the production build, cold and warm. Keep a
146
+ request count in the spec that reaches the screen, as a count, never as a
147
+ time.
148
+
149
+ ## Server speed
150
+
151
+ ### Measure
152
+
153
+ - Boot the server in a test as [Tests](data-access.md#tests)
154
+ shows, seed a realistic size in `TEST_DB_NAME`, and time the main routes
155
+ over `app.inject`, the first request after boot and later ones.
156
+ `countQueries(knex, work)`, or `countRuntimeQueries(work)` for a booted
157
+ server, from `@jskit-ai/database-runtime/server/testDatabases`, gives the
158
+ statements, so you can tell database time from the rest.
159
+ - Start the server with `node --cpu-prof` to see where a slow route or a slow
160
+ start spends its computing time, in the `.cpuprofile` file it writes.
161
+ - After the app has been idle, list the server's child processes, timers and
162
+ connections, and the jobs still running.
163
+
164
+ ### Fix
165
+
166
+ - **Do once what does not change.** A feature builds what does not change
167
+ between requests (a parsed configuration, a compiled schema, a client for an
168
+ outside service) in `setup()` and starts it in `boot()`, never per request
169
+ ([Owned state](typed-features.md#owned-state)).
170
+ - **Nothing runs without real use.** A process, worker or timer a feature
171
+ starts has its owner stop it in `shutdown()`
172
+ ([Shutdown mirrors setup](typed-features.md#shutdown-mirrors-setup)),
173
+ and one that serves only some requests starts on its first real use and
174
+ stops when idle. A periodic job's timer is `unref()`ed.
175
+ - **Work nobody waits for leaves the request.** Work over many rows or every
176
+ workspace runs as a background job with `systemScope`
177
+ ([Background work](data-access.md#background-work)).
178
+ - **Database time is the data pass's.** A count that grows with the rows, a
179
+ read narrowed in code, a write that reads its row back with
180
+ `returning: "record"` when it does not use it, and a missing index are
181
+ fixed as the [data pass](data-pass.md) says.
182
+
183
+ ### Prove
184
+
185
+ Report each main route's time before and after, with its statement count, at
186
+ the realistic size, the first after boot and later ones. Keep an
187
+ `expectFlatQueries()` test for each path whose count you changed.
188
+
189
+ Then run `npx jskit check` and `npm run verify`.
@@ -0,0 +1,111 @@
1
+ <!-- Generated from `packages/agent-docs/site/guide/framework/ux-pass.md`. -->
2
+
3
+ # User experience pass
4
+
5
+ A user experience pass makes the main things people do in an app short and
6
+ clear. Genesis's user experience pass skill (`genesis-ux-pass`) holds the
7
+ method: list the main tasks from the Blueprint, walk each one as a new and a
8
+ returning person, cut steps and decisions, make each task easy to find, word it
9
+ plainly, make mistakes cheap, and walk it again. This page says where each of
10
+ those lives in a JSKIT app. The rules it applies are already in
11
+ [Material 3](material-3.md), [CRUD operations](crud-operations.md),
12
+ [Record form actions](crud-form-actions.md) and
13
+ [Translation](translation.md).
14
+
15
+ ## Where people find each task
16
+
17
+ - **Main tasks are top-level destinations:** a main-navigation placement
18
+ (`kind: "link"`, `target: "shell.primary-nav"`), one literal
19
+ `addPlacement({ ... })` each, whose `label` is the word people use. A task
20
+ people do daily does not belong under Settings or an overflow menu
21
+ ([What an app declares](material-3.md#what-an-app-declares)).
22
+ - **Every inner page opens from its link:** each record, form and sub-page
23
+ declares `jskit.parent` once, so a shared link or a bookmark opens it and Up
24
+ leads somewhere sensible. Up follows the trail, which restores filters, sort,
25
+ page, scroll and focus, so a person never starts a list over; never add a
26
+ Back of your own ([The model](material-3.md#the-model)).
27
+ - **Context lives in the route:** a list's search, filters, tab and page stay
28
+ in the route when they must survive navigation or a shared link
29
+ ([Adaptive layout](material-3.md#adaptive-layout)).
30
+ - **Search finds what people remember:** `resource.searchSchema.q` names the
31
+ fields searched on the server; a Search box without it finds nothing
32
+ ([Wire list search with the initial resource](crud-operations.md#wire-list-search-with-the-initial-resource)).
33
+ Each filter chip opens its own control, and a lookup filter shows names
34
+ through `useCrudListFilterLookups()`, never ids.
35
+ - **A returning person lands in their workspace:** the Your workspaces landing
36
+ (`WorkspacesClientElement`) opens the last-used or the only workspace at
37
+ once, and stays on the list only when there is a choice to make or a pending
38
+ invitation.
39
+
40
+ ## The next action
41
+
42
+ - **A list's New is its primary action:** `ShellPrimaryAction`, an extended
43
+ FAB on compact and medium widths and a filled bar button on expanded, with
44
+ `CrudListScreen`'s `createLabel` naming what it creates ("New invoice"); the
45
+ empty state offers the same action
46
+ ([Lists, records and forms](material-3.md#lists-records-and-forms)).
47
+ - **A record shows its next step:** the record's next workflow step is its one
48
+ filled button, in context; a row of mostly disabled actions makes people
49
+ guess. Edit sits in the bar, other actions in its overflow menu.
50
+ - **One tap opens a record:** a card or table row opens its record; row
51
+ actions are trailing icon buttons, never a "View" text button on every row.
52
+
53
+ ## Forms start filled and finish somewhere useful
54
+
55
+ - **Defaults:** a `formFields` entry's `initialValue` is what a new record
56
+ starts with, and `useCrudAddEditScreen()`'s `createModel(fields)` computes
57
+ the whole starting model when it depends on the moment or the person, such
58
+ as today's date or the last choice made. A required field with one sensible
59
+ value should not start empty.
60
+ - **Save says what it saves:** `saveLabel` ("Save invoice"); an error appears
61
+ beside its field and the person's input stays
62
+ ([Record form actions](crud-form-actions.md)).
63
+ - **Where Save lands:** `useCrudAddEditScreen()`'s `saveSuccess` decides it,
64
+ by default the saved record, else the list; `navigateToView: false` with
65
+ `listUrlTemplate` returns to the list
66
+ ([Save navigation](crud-operations.md#save-navigation)).
67
+ Choose what the person does next, not what was easiest to wire. For entering
68
+ several in a row, offer Save and add another through
69
+ `addEditOptions.onSaveSuccess`.
70
+ - **Leaving a form:** a custom form finishes through `useShellNavigation()`:
71
+ `finish(target)` after Save and `finish()` for Cancel, back to where it was
72
+ opened; the bar's X is its Cancel
73
+ ([What an app declares](material-3.md#what-an-app-declares)).
74
+
75
+ ## Mistakes cost little
76
+
77
+ - **Deletion confirms by name:** `CrudDeleteAction` asks before deleting and
78
+ returns to the list afterwards, without a "Record not found" detour
79
+ ([Record deletion](crud-operations.md#record-deletion)).
80
+ Keep it: a delete cannot be undone.
81
+ - **Undo for what can be undone:** archiving, moving or marking done acts at
82
+ once and offers Undo in the snackbar:
83
+ `useShellWebErrorRuntime().report({ intent: "action-feedback", severity: "success", message, action: { label, handler } })`
84
+ from `@jskit-ai/shell-web/client/error`, whose handler reverses the command.
85
+ A confirmation dialog people see often is one they click through.
86
+
87
+ ## Words people read
88
+
89
+ - **The app's text is the app's:** labels, titles (`jskit.title`, or
90
+ `useShellPageTitle()` for a record's name), button text and messages come
91
+ through `useJskitText()` and the app's own message keys, so a renamed thing
92
+ changes everywhere at once and stays translatable; a placement `label` may
93
+ be a key ([Placement labels](translation.md#placement-labels)).
94
+ - **One name for each thing:** search the app's `locales/en.json` and the
95
+ placements for every name of a thing, and keep one. Copied starter files are
96
+ app code, so their words are the app's to change
97
+ ([What the app translates itself](translation.md#what-the-app-translates-itself)).
98
+ - **Names, not ids:** lists, chips and titles show names and formatted
99
+ figures through `formatDate` and `formatNumber`
100
+ ([Dates and numbers](translation.md#dates-and-numbers)).
101
+
102
+ ## Walk each task
103
+
104
+ - Walk each main task in the host's managed Preview, or with Playwright as
105
+ [UI operations](ui-operations.md#browser-verification) describes,
106
+ as a new person on a fresh `BROWSER_TEST_DB_NAME` fixture and as a returning
107
+ one with hundreds of rows; count the steps and decisions before and after.
108
+ - Lock each changed path into the Playwright spec that already reaches that
109
+ task, with `getByRole(role, { name })` naming what the person reads, and see
110
+ it fail once on the old path. Take screenshots at 390 and 1280 wide as the
111
+ [UI pass](ui-pass.md) shows, then run `npm run verify`.