Agent authoring playbook
This page renders src/ai/playbook.md, the file the repository’s
Claude Code skill
reads. It is written for an agent and pairs with the generated
knowledge pack: the pack
lists what a document may contain, the playbook says how to use it. Mica’s
tests import each complete document below with no issues and no
hints, find each labeled part in the
document it names, check that import refuses what the “cannot do” table says
it refuses, and run the host record and collection, the wizard pages, the
two-list move and the mastery quiz; the rest is prose.
For an agent writing Mica documents: how to translate a
request, where the host’s job starts, patterns and style. The pack (npm run mica:pack -- <pack id>) is
the vocabulary — every component, prop value, expression, action, object
grammar, projected path and limit. Read it first. npm run mica:check -- --json <file> lists every
reason import refuses a document.
The designer’s selected element is “this” (the turn names its key, type, JSON and references); a CLI agent has the whole file and no selection.
Links such as lists are Mica docs pages, here
site/src/content/docs/guides/lists.mdx (or .md). An example page such as order history
renders examples/documents/order-history.json.
Work in five steps
- Understand. Who uses the app, what they need to get done, and what they see at each step. Note which data exists before the app opens (a person, a list of orders), which data the app produces (a ticket, an answer), and which decisions follow from it (approve, pass, price).
- Translate into how Mica would do it. Map each want onto Mica’s pieces:
pages in the root PageStack moved between with
goToPage; document state inui.state, which form controls bind with$bindState;visibleconditions for anything that appears or disappears; a repeated Stack or Grid for a list; declared host objects for data the host owns. When a want has no direct form, use what Mica cannot do and tell the person how you translated it. - Decide the host contract. For each piece of data, ask whether local
state is enough or the host must know or decide. Whatever the host owns
becomes an
objectsdeclaration: a host type key, cardinality, identity, only the fields the document reads, capabilities with typed inputs and their constraints, and a design sample. Prefer those object verbs when the thing is a record. When the host owns a named verb that is not fetch, create, update or delete of a declared type, declare it underhostActions(a catalogue of names the host lists — never a script) and bind that name. Addlifecycle.startupfetches for data the first page shows (see host record and collection). Host actions cannot run at startup. The declarations are the contract: state them to the person as assumptions a host developer must confirm. - Build. Choose the pack first: a document cannot change pack
later. Signal (
mica.core) has the form controls and suits forms, data and operational tools; Nocturne (mica.nocturne) is for editorial, read-mostly pages and has no form controls or Section. Write the whole document in the exported form —envelopeVersion,uiwithroot,elementsandstate, thenmeta.pack, andobjects/hostActions/lifecyclewhen there are any. Seedui.statewith the paths the document reads or binds (not a declared object’s/objectsor/meta/objectspaths, which the runtime projects), and give every object a sample, so the preview’s mock host auto-plays them; scripted error/delay/not-found outcomes go in the{stem}.mica-design.jsonsidecar, never the document. - Check. Run
npm run mica:check -- --json <file>, fix every issue, and rerun until it is clean. A clean check means import accepts it, not that it does what was asked: walk it once more — every page reachable, every button leading somewhere, every loading and error state visible, every hidden element shown by something.
The host boundary
A Mica document declares, projects, validates structurally and renders. The host that embeds it owns everything that must stay true when someone bypasses the screen.
| The host owns | The document does |
|---|---|
| Business rules: grading, pricing, eligibility, approval | Collects inputs and sends them with create or update |
| Computed values: scores, totals, anything that decides or counts | Shows the raw values the host returns, formatted with $format; a live total with $calc or a number $expr, never sent to the host, which recomputes anything that counts |
| Authorization and roles: who may see, edit or approve | Reads /meta/objects/{alias}/capabilities/{op}/allowed and /fields/{field}/writable to hide or lock controls |
| Hierarchy and assignment: managers, teams, who acts next | Shows what the host returns, such as the approver’s name |
| Search, sort, filter and paging of collections | Passes the person’s choices as fetch inputs |
| Persistence, notifications, routing and sign-in | Moves between its own pages with goToPage |
| A named verb that is not fetch/create/update/delete of a declared type | Declares it in hostActions and binds the name; the host implements the handler |
| Final validation | Declares input constraints as a first check and shows the host’s fieldErrors |
Two consequences:
- Hiding a control is presentation, not permission. A document may hide
Delete when
allowedis false; the host must still refuse that delete. See the host contract. - A rule that decides an outcome belongs in the host even when the document
could approximate it. A quiz whose result counts is graded by the host’s
createreturning a field such aspassed; a practice quiz may stay local (see the mastery quiz).
When the request is vague about the host (“a quiz about the gym”), propose the smallest contract that works, with realistic samples, and offer the local-only alternative when there is one.
What Mica cannot do, and what to do instead
| The request | What Mica lacks | Do this instead |
|---|---|---|
| A live total: price × quantity, a basket’s sum, nights between dates | — | $calc or a number $expr where $format goes, or as its value: {"$calc": "product", "args": [{"$state": "/order/price"}, {"$state": "/order/quantity"}]}; a sum over a list’s rows takes list and field. Display only |
| Next enabled only when two fields are set | — | Button disabled { "$cond": <boolean $expr of isEmpty/and/or/not>, "$then": true, "$else": false }. Never send $expr in setState, object inputs or host-action params |
| A score, a pass mark, eligibility, “3 of 4”, a full name | Decisions that count, and templates: boolean $expr may hide or disable; never $expr in create/setState; $calc stays display-only; $template and $computed are refused |
The host computes it, returning numbers and dates raw (shown with $format), a decision as a field (passed), joined text whole (fullName). To show a value under its label, use a Value. A wizard’s “Step 2 of 3” is Steps, never a typed Text (see wizard pages) |
| Money, a date, a percent, “3 claims” | — | {"$format": "currency", "value": {"$state": "/objects/claim/data/amount"}, "currency": "EUR"} in a Text or Heading’s content or a Value’s value; also number, percent (a fraction), date (YYYY-MM-DD) and count (one at exactly 1, other otherwise, in every locale). value is a $state or $item read, a $calc or a number $expr, never a literal. Never a host amountLabel |
| A Button that looks selected | A Button’s variant takes a literal value only |
One of a few options shown as buttons: one Choice with display: "segmented". On and off (“Follow” / “Following”): one Toggle with display: "button" and onLabel / offLabel. A Button that runs actions: two Buttons with complementary visible conditions, solid and outline |
| Feedback or an explanation once an option is chosen | — | The option’s note, shown under the Choice while that option is chosen; see the mastery quiz |
| Radio buttons, a select, checkboxes, a switch, a number, a note, dates | — | Choice (display radio, select, checkboxes, segmented, or combobox to search a long list), Toggle (display switch, checkbox or button), NumberField (min/max mark an outside number invalid, never change it; step moves the stepper; format currency with currency, percent of a fraction, unit with unit; stores the number), an Input with lines 2–8, DateField (YYYY-MM-DD; display field or picker), DateRange (start/end) or Slider, bound with $bindState. See the forms guide |
| Tick off a row of a list | A Button cannot write a field of its own row | A Toggle bound to the row’s field with $bindItem, or move the row between two local lists (see the two-list move). A host row is changed through the host with update |
| Search, sort, filter, pages of results | No sorting, text search or paging inside the document | Host query: declare fetch inputs and refetch from a control’s commit or a Button’s press; see filter and sort |
| “Only managers can approve”, approval chains | Roles and rules are not the document’s job | The host’s availability, writability and rejections; the document reads the projected allowed, writable and reason |
| Auto-advance, timers, react on every keystroke | No timers or watchers (watch is refused); commit fires when a person finishes an edit |
Explicit Buttons, or a control’s commit |
| A list inside each row of a list | A repeat inside another repeat’s template is refused | Show the inner list for one selected row, fetched by the row’s identity, or flatten it on the host |
| A field that is a list | Declared fields are never arrays | A cardinality: "many" collection |
| A drop-down of actions that do something | DropdownMenu declares no events | Buttons with variant outline or ghost |
| Brand colours, dark mode, fonts | Documents carry no styling | Pick the pack; the host applies a theme |
| Check a form that writes nothing to the host | — | Form control rules (required, enum, pattern, minLength, maxLength, minimum, maximum) plus a validate action. Bind the value with $bindState and the message with error {"$state": "/path"}. requiredWhen stays on business-object inputs |
The limits page lists all else import refuses or Mica does not do yet.
Recipes
Local form check
Bind each control with $bindState and error {"$state": "/errors/{key}"} (seed ""). Put checks on rules (required, enum, pattern, minLength, maxLength, minimum, maximum; Toggle has none). A Button press or the control’s commit runs { "action": "validate", "params": {} }, checking only ruled controls visible on the active page; others keep their error slots; none visible succeeds. Import refuses an error path that setState could not write, or that equals, contains or sits inside a $bindState path or a list a repeat or $bindItem uses, and refuses validate when no control carries valid rules. The designer’s Inspector can copy a declared enum onto a Choice’s options; when writing JSON, list the enum values as options yourself.
Draft and edit
Import refuses a form control bound to a declared object’s /objects/...
path. Copy the record into a draft, edit the draft, save it:
- An Edit Button runs
setStateof the draft path with a copy of the record,{ "$state": "/objects/{alias}/data" }, or, in a row, asetStaterecord of the row’s fields read with$item, identity included. - Inputs bind to the draft with
$bindState; for a single record each can takewritablefrom/meta/objects/{alias}/fields/{field}/writable. - Save runs
updatewith inputs read from the draft (and, for a collection,rowfrom the draft’s identity), then clears the draft. A rejected update stops the event, so the draft survives for another try. A collection’s update merges the returned row into the list; do not refetch it. - Each Input shows its input’s field error with
error:{ "$state": "/meta/objects/{alias}/operations/update/error/fieldErrors/{input}" }.
A single record: customer profile. A row of a collection: order history’s delivery note.
{ "note-save": { "on": { "press": [ { "action": "update", "params": { "object": "orders", "inputs": { "note": { "$state": "/noteDraft/note" } }, "row": { "id": { "$state": "/noteDraft/id" } } } }, { "action": "setState", "params": { "statePath": "/noteDraft", "value": {} } } ] } }}Create, then go to a page
Put create and goToPage in one event. When the host or the input check
rejects the create, the rest of the event is skipped, so the person stays on
the form and sees the errors: each control whose value the create sends
takes error, { "$state": "/meta/objects/{alias}/operations/create/error/fieldErrors/{input}" },
which shows the message under the control and marks it invalid, and near the
submit a Text shows the error’s message. On success the next page
reads the host’s answer from /objects/{alias}/data/.... Make the submit
Button busy while the create’s phase is loading, with a busyLabel such as
“Sending…”: one Button, which ignores presses while busy, rather than a
hidden Button and a “Sending…” Text. When the form spans pages, see
wizard pages. See support ticket,
including a conditionally required input (requiredWhen on the input, a
$cond on the Input’s required marker).
Loading, error and empty states
Give every fetched object three states, each a Text or Section shown by the fetch’s phase; the empty one also reads the count. The error state can carry a Retry Button that runs the same fetch.
{ "loading": { "visible": { "$state": "/meta/objects/orders/operations/fetch/phase", "eq": "loading" } }, "load-error": { "visible": { "$state": "/meta/objects/orders/operations/fetch/phase", "eq": "error" } }, "empty": { "visible": [ { "$state": "/meta/objects/orders/operations/fetch/phase", "eq": "success" }, { "$state": "/meta/objects/orders/count", "eq": 0 } ] }}A local list is empty when its first row is missing:
{ "$state": "/toPack/0", "not": true } (in the two-list move below). Show a
write’s own phase and error next to the Button that runs it — see
customer profile.
Host record and collection
The host’s data and a form that adds to it, in one page. Both objects are
fetched at startup. A fetch that takes no inputs is "fetch": {}, never
"inputs": {}. The identity is declared
"required": true, "nullable": false. The list has its loading, error and
empty states; each Input’s error reads the host’s fieldErrors for its
input. A rejected create stops the event, so the draft survives for another
try; a created row joins the list by itself, because the fetch takes no
inputs.
{ "envelopeVersion": 1, "ui": { "root": "app", "elements": { "app": { "type": "PageStack", "props": { "name": "Team ideas" }, "children": ["page-ideas"] }, "page-ideas": { "type": "Page", "props": { "title": "Ideas", "background": "mist" }, "children": ["title", "me-name", "loading", "load-error", "empty", "idea-list", "new-idea"] }, "title": { "type": "Heading", "props": { "content": "Team ideas", "level": "1", "align": "left", "accent": false }, "children": [] }, "me-name": { "type": "Text", "props": { "content": { "$state": "/objects/me/data/name" }, "size": "sm", "tone": "muted", "align": "left", "italic": false }, "children": [] }, "loading": { "type": "Text", "props": { "content": "Loading ideas…", "size": "md", "tone": "muted", "align": "left", "italic": false }, "children": [], "visible": { "$state": "/meta/objects/ideas/operations/fetch/phase", "eq": "loading" } }, "load-error": { "type": "Stack", "props": { "direction": "horizontal", "gap": "sm", "align": "center", "justify": "between", "wrap": true, "padding": "none", "surface": null }, "children": ["load-error-text", "retry"], "visible": { "$state": "/meta/objects/ideas/operations/fetch/phase", "eq": "error" } }, "load-error-text": { "type": "Text", "props": { "content": { "$state": "/meta/objects/ideas/operations/fetch/error/message" }, "size": "md", "tone": "accent", "align": "left", "italic": false }, "children": [] }, "retry": { "type": "Button", "props": { "label": "Try again", "variant": "outline", "size": "sm", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": { "action": "fetch", "params": { "object": "ideas" } } } }, "empty": { "type": "Text", "props": { "content": "No ideas yet. Share the first one.", "size": "md", "tone": "muted", "align": "left", "italic": false }, "children": [], "visible": [{ "$state": "/meta/objects/ideas/operations/fetch/phase", "eq": "success" }, { "$state": "/meta/objects/ideas/count", "eq": 0 }] }, "idea-list": { "type": "Stack", "props": { "direction": "vertical", "gap": "sm", "align": "stretch", "justify": "start", "wrap": false, "padding": "none", "surface": null }, "children": ["idea-row"], "repeat": { "statePath": "/objects/ideas/data", "key": "id" } }, "idea-row": { "type": "Stack", "props": { "direction": "horizontal", "gap": "sm", "align": "center", "justify": "between", "wrap": true, "padding": "sm", "surface": "paper" }, "children": ["idea-title", "idea-status"] }, "idea-title": { "type": "Text", "props": { "content": { "$item": "title" }, "size": "md", "tone": "default", "align": "left", "italic": false }, "children": [] }, "idea-status": { "type": "Text", "props": { "content": { "$item": "statusLabel" }, "size": "sm", "tone": "muted", "align": "right", "italic": false }, "children": [] }, "new-idea": { "type": "Section", "props": { "eyebrow": "NEW IDEA", "title": "Share an idea", "tone": "outlined", "padding": "lg" }, "children": ["idea-input", "why-input", "share", "share-error"] }, "idea-input": { "type": "Input", "children": [], "props": { "label": "Idea", "placeholder": "A quiet room on floor 3", "inputType": "text", "required": true, "helpText": null, "value": { "$bindState": "/draft/title" }, "error": { "$state": "/meta/objects/ideas/operations/create/error/fieldErrors/title" } } }, "why-input": { "type": "Input", "children": [], "props": { "label": "Why it helps", "placeholder": "", "inputType": "text", "required": false, "helpText": null, "value": { "$bindState": "/draft/why" }, "error": { "$state": "/meta/objects/ideas/operations/create/error/fieldErrors/why" } } }, "share": { "type": "Button", "children": [], "props": { "label": "Share idea", "variant": "solid", "size": "md", "disabled": false, "fullWidth": false, "busy": { "$cond": { "$state": "/meta/objects/ideas/operations/create/phase", "eq": "loading" }, "$then": true, "$else": false }, "busyLabel": "Sending…" }, "on": { "press": [ { "action": "create", "params": { "object": "ideas", "inputs": { "title": { "$state": "/draft/title" }, "why": { "$state": "/draft/why" } } } }, { "action": "setState", "params": { "statePath": "/draft", "value": { "title": "", "why": "" } } } ] } }, "share-error": { "type": "Text", "props": { "content": { "$state": "/meta/objects/ideas/operations/create/error/message" }, "size": "sm", "tone": "accent", "align": "left", "italic": false }, "children": [], "visible": { "$state": "/meta/objects/ideas/operations/create/phase", "eq": "error" } } }, "state": { "draft": { "title": "", "why": "" } } }, "meta": { "pack": { "id": "mica.core", "version": "1.0.0" } }, "objects": { "me": { "type": "team.member", "cardinality": "one", "identity": "id", "fields": { "id": { "kind": "string", "required": true, "nullable": false }, "name": { "kind": "string", "required": true } }, "capabilities": { "fetch": {} }, "sample": { "id": "u_12", "name": "Sam Ortiz" } }, "ideas": { "type": "team.idea", "cardinality": "many", "identity": "id", "fields": { "id": { "kind": "string", "required": true, "nullable": false }, "title": { "kind": "string", "required": true }, "statusLabel": { "kind": "string", "required": true } }, "capabilities": { "fetch": {}, "create": { "inputs": { "title": { "kind": "string", "required": true, "minLength": 3, "maxLength": 80 }, "why": { "kind": "string", "maxLength": 500 } } } }, "sample": [{ "id": "idea_1", "title": "A quiet room on floor 3", "statusLabel": "Under review" }] } }, "lifecycle": { "startup": [{ "action": "fetch", "params": { "object": "me" } }, { "action": "fetch", "params": { "object": "ideas" } }] }}Wizard pages
One Page per step in the root PageStack, in the order a person meets them.
Each step page shows its position with a Steps element: format takes {n} (the page’s position) and {total}
(the number of counted pages), and the count follows the pages, so removing
or reordering a step edits no Steps. It counts every page; when the flow has
pages that are not steps (a done page), list the step pages in pages
(counted in page order; add each new step page to them); elsewhere it shows
nothing.
Each step’s Next runs goToPage. A Next waiting on one value is disabled
until it is set (a $cond with "not": true); one waiting on several is shown
only once all are set (a list of conditions, or a boolean $expr). When a step can be finished
more than one way, keep one Next and give it an any-of condition: $or lists
groups, each one condition or a list that must all hold, one level deep. Talks, or the workshop
with dietary needs filled:
{ "track-next": { "visible": { "$or": [ { "$state": "/form/track", "eq": "talks" }, [{ "$state": "/form/track", "eq": "workshop" }, { "$state": "/form/dietary" }]] } } }Back is a ghost Button. State persists across
pages, so a review page shows each earlier answer as one Value: its
label, its value read with $state, and empty for an answer left
blank. For a Choice, read { "$label": "<the Choice's key>" } instead, so the
person sees the option they picked (“Morning, 9:00–12:00”), not its stored
value (“morning”); for checkboxes it lists the chosen labels. The review’s
submit runs create then goToPage. A done page offers a restart that
resets state with setState; first micro-app
builds a two-page flow.
A refused create leaves the person on the review page, so show the host’s
field errors twice, from the single-page form’s paths: each control’s error
on its own step, for Back to fix, and the error of the answer’s Value on
the review page. Every input the create sends from a control gets both; the
error’s message sits by the submit.
{ "envelopeVersion": 1, "ui": { "root": "app", "elements": { "app": { "type": "PageStack", "props": { "name": "Volunteer sign-up" }, "children": ["page-you", "page-shift", "page-review", "page-done"] }, "page-you": { "type": "Page", "props": { "title": "You", "background": "mist" }, "children": ["you-steps", "you-title", "name", "email", "you-next"] }, "you-steps": { "type": "Steps", "props": { "format": "Step {n} of {total}", "pages": ["page-you", "page-shift", "page-review"] }, "children": [] }, "you-title": { "type": "Heading", "props": { "content": "About you", "level": "1", "align": "left", "accent": false }, "children": [] }, "name": { "type": "Input", "children": [], "props": { "label": "Name", "placeholder": "", "inputType": "text", "required": true, "helpText": null, "value": { "$bindState": "/form/name" }, "error": { "$state": "/meta/objects/signup/operations/create/error/fieldErrors/name" } } }, "email": { "type": "Input", "children": [], "props": { "label": "Email", "placeholder": "", "inputType": "email", "required": true, "helpText": null, "value": { "$bindState": "/form/email" }, "error": { "$state": "/meta/objects/signup/operations/create/error/fieldErrors/email" } } }, "you-next": { "type": "Button", "props": { "label": "Choose a shift", "variant": "solid", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "visible": [{ "$state": "/form/name" }, { "$state": "/form/email" }], "on": { "press": { "action": "goToPage", "params": { "page": "page-shift" } } } }, "page-shift": { "type": "Page", "props": { "title": "Shift", "background": "mist" }, "children": ["shift-steps", "shift-title", "shift", "shift-back", "shift-next"] }, "shift-steps": { "type": "Steps", "props": { "format": "Step {n} of {total}", "pages": ["page-you", "page-shift", "page-review"] }, "children": [] }, "shift-title": { "type": "Heading", "props": { "content": "Pick a shift", "level": "1", "align": "left", "accent": false }, "children": [] }, "shift": { "type": "Choice", "children": [], "props": { "label": "Shift", "display": "radio", "required": true, "helpText": null, "value": { "$bindState": "/form/shift" }, "options": [{ "value": "morning", "label": "Morning, 9:00–12:00" }, { "value": "afternoon", "label": "Afternoon, 13:00–17:00" }], "error": { "$state": "/meta/objects/signup/operations/create/error/fieldErrors/shift" } } }, "shift-back": { "type": "Button", "props": { "label": "Back", "variant": "ghost", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": { "action": "goToPage", "params": { "page": "page-you" } } } }, "shift-next": { "type": "Button", "children": [], "props": { "label": "Review", "variant": "solid", "size": "md", "fullWidth": false, "disabled": { "$cond": { "$state": "/form/shift", "not": true }, "$then": true, "$else": false } }, "on": { "press": { "action": "goToPage", "params": { "page": "page-review" } } } }, "page-review": { "type": "Page", "props": { "title": "Review", "background": "mist" }, "children": ["review-steps", "review-title", "review-name", "review-email", "review-shift", "submit", "submit-error", "review-back"] }, "review-steps": { "type": "Steps", "props": { "format": "Step {n} of {total}", "pages": ["page-you", "page-shift", "page-review"] }, "children": [] }, "review-title": { "type": "Heading", "props": { "content": "Check and send", "level": "1", "align": "left", "accent": false }, "children": [] }, "review-name": { "type": "Value", "children": [], "props": { "label": "Name", "value": { "$state": "/form/name" }, "empty": "Not given", "error": { "$state": "/meta/objects/signup/operations/create/error/fieldErrors/name" } } }, "review-email": { "type": "Value", "children": [], "props": { "label": "Email", "value": { "$state": "/form/email" }, "empty": "Not given", "error": { "$state": "/meta/objects/signup/operations/create/error/fieldErrors/email" } } }, "review-shift": { "type": "Value", "children": [], "props": { "label": "Shift", "value": { "$label": "shift" }, "empty": "Not chosen", "error": { "$state": "/meta/objects/signup/operations/create/error/fieldErrors/shift" } } }, "submit": { "type": "Button", "children": [], "props": { "label": "Sign up", "variant": "solid", "size": "md", "disabled": false, "fullWidth": false, "busy": { "$cond": { "$state": "/meta/objects/signup/operations/create/phase", "eq": "loading" }, "$then": true, "$else": false }, "busyLabel": "Sending…" }, "on": { "press": [ { "action": "create", "params": { "object": "signup", "inputs": { "name": { "$state": "/form/name" }, "email": { "$state": "/form/email" }, "shift": { "$state": "/form/shift" } } } }, { "action": "goToPage", "params": { "page": "page-done" } } ] } }, "submit-error": { "type": "Text", "props": { "content": { "$state": "/meta/objects/signup/operations/create/error/message" }, "size": "sm", "tone": "accent", "align": "left", "italic": false }, "children": [], "visible": { "$state": "/meta/objects/signup/operations/create/phase", "eq": "error" } }, "review-back": { "type": "Button", "props": { "label": "Back", "variant": "ghost", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": { "action": "goToPage", "params": { "page": "page-shift" } } } }, "page-done": { "type": "Page", "props": { "title": "Done", "background": "paper" }, "children": ["done-title", "done-shift", "done-again"] }, "done-title": { "type": "Heading", "props": { "content": "You're signed up", "level": "1", "align": "left", "accent": true }, "children": [] }, "done-shift": { "type": "Text", "props": { "content": { "$state": "/objects/signup/data/shiftLabel" }, "size": "md", "tone": "default", "align": "left", "italic": false }, "children": [] }, "done-again": { "type": "Button", "props": { "label": "Sign up someone else", "variant": "outline", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "setState", "params": { "statePath": "/form", "value": { "name": "", "email": "", "shift": "" } } }, { "action": "goToPage", "params": { "page": "page-you" } } ] } } }, "state": { "form": { "name": "", "email": "", "shift": "" } } }, "meta": { "pack": { "id": "mica.core", "version": "1.0.0" } }, "objects": { "signup": { "type": "volunteers.signup", "cardinality": "one", "identity": "id", "fields": { "id": { "kind": "string", "required": true, "nullable": false }, "shiftLabel": { "kind": "string", "required": true } }, "capabilities": { "create": { "inputs": { "name": { "kind": "string", "required": true, "minLength": 2 }, "email": { "kind": "string", "required": true, "format": "email" }, "shift": { "kind": "string", "required": true, "enum": ["morning", "afternoon"] } } } }, "sample": { "id": "vol_7", "shiftLabel": "Saturday morning, 9:00–12:00" } } }}Two-list move
To tick items off, move each row between two local lists: addRow to the
other list with the row’s fields read with $item, then removeRow from its
own list by key. Add before you remove: a refused add stops the event, so the
row stays where it was. The moved row gets a new key (row-1, …), so a local
list’s key should not carry meaning. Repeat a plain vertical Stack around
one row Stack, or the rows run together in one box.
{ "envelopeVersion": 1, "ui": { "root": "app", "elements": { "app": { "type": "PageStack", "props": { "name": "Packing list" }, "children": ["page-pack"] }, "page-pack": { "type": "Page", "props": { "title": "Pack", "background": "mist" }, "children": ["title", "to-pack", "all-packed", "packed-title", "packed"] }, "title": { "type": "Heading", "props": { "content": "Packing list", "level": "1", "align": "left", "accent": false }, "children": [] }, "to-pack": { "type": "Stack", "props": { "direction": "vertical", "gap": "sm", "align": "stretch", "justify": "start", "wrap": false, "padding": "none", "surface": null }, "children": ["to-pack-row"], "repeat": { "statePath": "/toPack", "key": "id" } }, "to-pack-row": { "type": "Stack", "props": { "direction": "horizontal", "gap": "sm", "align": "center", "justify": "between", "wrap": true, "padding": "sm", "surface": "paper" }, "children": ["to-pack-name", "pack-it"] }, "to-pack-name": { "type": "Text", "props": { "content": { "$item": "name" }, "size": "md", "tone": "default", "align": "left", "italic": false }, "children": [] }, "pack-it": { "type": "Button", "props": { "label": "Packed", "variant": "outline", "size": "sm", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "addRow", "params": { "statePath": "/packed", "value": { "name": { "$item": "name" } } } }, { "action": "removeRow", "params": { "statePath": "/toPack", "row": { "id": { "$item": "id" } } } } ] } }, "all-packed": { "type": "Text", "props": { "content": "Everything is packed.", "size": "md", "tone": "muted", "align": "left", "italic": false }, "children": [], "visible": { "$state": "/toPack/0", "not": true } }, "packed-title": { "type": "Heading", "props": { "content": "Packed", "level": "2", "align": "left", "accent": false }, "children": [] }, "packed": { "type": "Stack", "props": { "direction": "vertical", "gap": "xs", "align": "stretch", "justify": "start", "wrap": false, "padding": "sm", "surface": null }, "children": ["packed-name"], "repeat": { "statePath": "/packed", "key": "id" } }, "packed-name": { "type": "Text", "props": { "content": { "$item": "name" }, "size": "md", "tone": "muted", "align": "left", "italic": true }, "children": [] } }, "state": { "toPack": [{ "id": "passport", "name": "Passport" }, { "id": "charger", "name": "Phone charger" }], "packed": [] } }, "meta": { "pack": { "id": "mica.core", "version": "1.0.0" } }}When rows only need a done flag, a Toggle in the row bound with
{ "$bindItem": "done" } is simpler; the workshop sign-up
does this for its talks.
Mastery quiz
With no host, a quiz can still teach: each question’s Next appears only once
the answer is right, and every option’s note says why once it is chosen.
The answers are in the
document, so this suits practice; a result that counts needs the host to
grade a create.
{ "envelopeVersion": 1, "ui": { "root": "app", "elements": { "app": { "type": "PageStack", "props": { "name": "Gym basics" }, "children": ["page-q1", "page-done"] }, "page-q1": { "type": "Page", "props": { "title": "Question 1", "background": "mist" }, "children": ["q1-card"] }, "q1-card": { "type": "Section", "props": { "eyebrow": "QUICK CHECK", "title": "After your set", "tone": "outlined", "padding": "lg" }, "children": ["q1", "q1-next"] }, "q1": { "type": "Choice", "children": [], "props": { "label": "Where do the weights go?", "display": "radio", "required": false, "helpText": null, "value": { "$bindState": "/quiz/q1" }, "options": [ { "value": "floor", "label": "Leave them on the floor", "note": "Not quite: the next person needs a clear floor." }, { "value": "rack", "label": "Back on the rack", "note": "Right: racked plates are safe and easy to find." } ] } }, "q1-next": { "type": "Button", "props": { "label": "Finish", "variant": "solid", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "visible": { "$state": "/quiz/q1", "eq": "rack" }, "on": { "press": { "action": "goToPage", "params": { "page": "page-done" } } } }, "page-done": { "type": "Page", "props": { "title": "Done", "background": "paper" }, "children": ["done-title", "done-again"] }, "done-title": { "type": "Heading", "props": { "content": "You know the basics", "level": "1", "align": "left", "accent": true }, "children": [] }, "done-again": { "type": "Button", "props": { "label": "Start again", "variant": "outline", "size": "md", "disabled": false, "fullWidth": false }, "children": [], "on": { "press": [ { "action": "setState", "params": { "statePath": "/quiz", "value": { "q1": "" } } }, { "action": "goToPage", "params": { "page": "page-q1" } } ] } } }, "state": { "quiz": { "q1": "" } } }, "meta": { "pack": { "id": "mica.core", "version": "1.0.0" } }}The same note explains any option once chosen — what a shipping speed
costs, what a plan includes. It is shown, never judged: the document cannot
score answers.
For a graded quiz, declare an object with a create whose inputs are the
answers (each an enum of the option values) and whose record carries
passed and a score the result shows with $format; the submit runs
create then goToPage to a result page that shows a pass or a fail Section by
/objects/{alias}/data/passed. Show the host’s field errors as
wizard pages do: in each answer’s control error, and by
the submit.
Style
For both packs:
- A Page’s
titlenames the page in the designer and to hosts but is not shown. Give each page one level 1 Heading for its title, and use levels 2 and 3 below it. - Element keys are readable and stable:
page-review,email,submit,submit-error. Pages start withpage-. - Labels say what happens: “Save note”, “Send request”, not “Submit” or
“OK”. A delete’s
confirmationnames the consequence. To ask before a create or update — “Submit for review? You cannot edit it afterwards.” — give that binding the sameconfirmation; never build a confirm step out of Buttons andsetState. - One solid Button per step for the main action; outline for secondary actions, the quietest variant (ghost in Signal, text in Nocturne) for Back and small row actions.
- Show a labelled fact or answer (a review row, a record’s field) as one
Value, not a label Text and a value Text. - Put a field’s guidance in its
helpText, not a separate Text. Use muted Text for secondary information, and accent sparingly for what needs attention (a retry hint, a field error). - Keep copy short and concrete, in the person’s words; do not explain Mica.
Signal (mica.core), operational:
- Page
background:mistbehind forms and tools,paperfor reading and results,inkfor a hero, with Texttone: "inverse"on it. - Group a form’s fields in an outlined Section with an
eyebrowfor context and atitle; useraisedfor the one thing that matters most,inkrarely. - Grid for cards and metrics (two or three columns); a horizontal Stack with
justify: "between"for a row of label and action. Stacksurface: "citrus"highlights one block per page at most. dangeris for destructive actions only. Avatar stands for a person, not decoration.
Nocturne (mica.nocturne), editorial:
- Pages read like an edition: a large Heading with
accentunderlineorlast, italic Text for standfirsts and captions, a labeled Divider between ideas, one Quote per page for a voice set apart. - Few actions: one solid Button as the call to action,
textvariant for quiet links such as page navigation. inkbackgrounds suit covers and closing invitations; keep body pages onpaperormistfor long reading.- Nocturne has no form controls. If the request needs input, use Signal. See town hall for the Nocturne vocabulary in use.