/boxel-skills:boxel-workspace-cardinal-rulesfrom boxel-skills
Silent-failure traps in Boxel card authoring — rules that pass lint and often indexing, then corrupt the realm index, crash at render, or drop data with no error (DateField vs DateTimeField formats, external URLs in relationship links, and more). Check every card and field against this list before finishing.
Ships in boxel-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Rules discovered the hard way in a downstream Boxel workspace: each one passes lint and often passes indexing too, then breaks silently — corrupting the realm's index, crashing at render, or dropping data with no error. Check every card/field you write against this list before finishing an issue.
The numbers below are local to this file. The boxel skill carries a separate Cardinal
Rules table with its own numbering, and that is the one a bare "Cardinal Rule N"
citation in index.md, CLAUDE.md, or AGENTS.md refers to — several of those numbers
are past the end of this list and do not name a rule here.
DateField values are YYYY-MM-DD (no T). DateTimeField values are full ISO
datetimes (2026-07-16T14:30:00.000Z, with T). Putting a datetime string in a
DateField (or vice versa) passes lint and indexes fine, then crashes at render
with RangeError: Invalid time value when a user actually opens the card. Naming
convention to follow when picking the field type: a *At suffix (createdAt,
publishedAt) means DateTimeField; a *Date/*On suffix or bare dob means
DateField.
relationships.<field>.links.self — and never a realm URL in a string fieldIf a linksTo/linksToMany field's JSON links.self points at a URL the indexer
can't parse as a card (an external website, an image CDN URL, anything not a card
resource), the failed parse poisons the JSONB write and rolls back the WHOLE
REALM's indexing transaction — every other file in the same push silently fails to
index too, with no error pointing at the actual bad file. For an external image/URL,
use the pair pattern instead: linksTo(ImageDef) (or a similar file/media field) +
contains(UrlField) as two separate fields, never one relationship pointing straight
at an external URL.
The rule cuts both ways. If a field's value is the URL of a card instance or a
realm file — an absolute realm URL, a relative path like ../Theme/foo, or any URL
a realm serves — model it as linksTo / linksToMany (a FileDef subtype for
files), never as a StringField or UrlField attribute. The string version writes
fine, indexes fine, and even renders as a clickable link — then rots silently: the
index never invalidates the referrer when the target changes, broken-link
diagnostics can't see it, <@fields.X /> can't render the target, and queries can't
traverse it. When the target moves or is deleted, nothing reports the dangling
reference. Two carve-outs where a string is correct: a FileDef subtype's own
id/url/sourceUrl descriptor fields hold the realm file URL as strings by
design, and a curated public path routed via hostRoutingRules (a nav target like
/about) is a routed path, not a resource identifier. Everything else UrlField
holds should be an external (non-realm) URL. Details:
boxel/references/base-field-catalog.md "Realm-resource URLs — always a
relationship, never a string".
linksToMany JSON uses indexed top-level keys, never an arrayCorrect:
"relationships": {
"items.0": { "links": { "self": "../foo" } },
"items.1": { "links": { "self": "../bar" } }
}
Wrong (rejected outright — "instance ... is not a card resource document"):
"relationships": {
"items": { "links": { "self": ["../foo", "../bar"] } }
}
No data: URIs, blob: URIs, base64, or raw media bytes in any JSON string field or
attribute. Store media as a realm file linked via linksTo(FileDef) (or a FileDef
subtype: ImageDef, CsvFileDef, etc.) instead — never embed the bytes directly in
the instance JSON.
A card search with no realms targets the card's own realm; before that realm is
known it searches nothing, so don't treat the empty first result as an answer. A card
search is capped at 100 rows and 2 realms, and asking for more returns nothing, not
a trimmed page — boxel/references/query-systems.md "Limits and ceilings".
type selects instances, on only scopes predicatesTo select every instance of a type, filter on { type: <ref> } directly — never wrap
it in { on: <ref> } alone (on only scopes other predicates like eq/contains;
a bare { on: ref } with nothing else matches nothing). Build refs with a codeRef()
helper, not a manually-constructed object.
Large atomic pushes (30+ files via a single bulk-write endpoint) can report success while silently dropping some files' indexing jobs. For bulk kit/asset installs, push in smaller batches and verify each batch's expected file count actually shows up in a realm search before pushing the next batch.
Base card modules are addressed by the canonical @cardstack/base/ prefix
(@cardstack/base/theme, @cardstack/base/card-api,
@cardstack/base/cards/structured-theme, etc.). Those are loader-resolved module
references, not fetchable HTTP resources — there is no URL to GET. The older URL
spelling https://cardstack.com/base/... still resolves at runtime, but do not write it
and never fetch it: cardstack.com is a marketing site, so a direct GET or a realm op
(_mtimes, boxel file read) against cardstack.com/base/... returns a generic
Webflow 404 HTML page (data-wf-domain=... %%PUBLISH_URL_REPLACEMENT%%), NOT the
card. Do not keep retrying it — that page will never become the schema. To learn a base
card's fields/shape, use the get_card_schema tool (it resolves through the realm
server), or read an existing instance of that card already in the target realm. Same
rule for any published *.boxel.site / *.boxel.build URL: those are Webflow-published
sites, not realms — never point realm operations at them.
Also: many base cards are default exports, so the schema ref is name: "default",
NOT the class name. The base Theme card is the default export of
@cardstack/base/theme (the module is export default Theme) — query it as
module @cardstack/base/theme, name default (querying #Theme fails).
StructuredTheme is likewise the default export of base/structured-theme. When a
get_card_schema call fails with "named export is a CardDef", retry with name: "default" before assuming the card is unreachable — do NOT fall back to curling a URL.
serializeCard(model) from a render getterSerializing the card's own model inside a template-facing getter (isolated/embedded
component code) can appear to work, then fails in two environment-dependent ways:
in prerender it throws during render (instance-error 500, the card drops out of
prerendered listings), and in interactive sessions it raises the deterministic
IDResolver error conflicting instance id in store — the serialize path re-registers
the instance under a conflicting local id. When a template needs a JSON:API-shaped
view of the card, reconstruct the shape from @model fields instead of calling
serializeCard.
linksTo fields never appear in attributes — not even as nullA linksTo field is serialized under relationships, keyed by its field path — for a
linksTo nested inside a contained field, a dotted key: "cardInfo.theme": { "links": { "self": "../Theme/foo" } }. An empty link is { "links": { "self": null } }, or
omit the key entirely. Writing "cardInfo": { "theme": null } (or any value for the
link) into attributes passes lint and writes successfully — then every read of the
instance throws linkTo field 'theme' cannot deserialize non-relationship value null
until the raw JSON is repaired by hand.
When a template calls a component function — as a helper ({{if (this.isActive note) ...}}) or via {{fn}} — Glimmer invokes the plain function without
binding this. A class body is always strict mode, so inside a class method
this is undefined and the first property access throws — during render,
which poisons Ember's renderer beyond recovery: the whole application freezes
and only a page reload brings it back. The code passes lint, often passes
prerender (the crash can hide behind interaction-dependent branches), and event
handlers wired with {{on}} mask the pattern because the same mistake there
merely breaks one handler instead of the app. Write every template-invoked
function as an arrow property:
// wrong — crashes the app at render
isActive(note: string) { return this.activeNotes.has(note); }
// right
isActive = (note: string) => this.activeNotes.has(note);
Getters are safe: the template reads them off this ({{this.safeTitle}},
{{#if this.showComments}}), so they never lose their receiver — the trap is
only functions the template detaches and calls. @action methods also bind
correctly and are safe in call position; arrow properties are the convention
in this repo.
:global() in a card's CSSCard code is compiled with :global turned off (to stop a card's styles from
escaping its scope). The compiler only warns, on the server, and leaves
:global(...) in the output; the browser rejects the selector as invalid, and
an invalid selector drops the whole rule, so every other selector in the same
comma-separated list goes with it:
/* both selectors are dropped; .plain loses its style too */
.wrap td :global(button.x), .plain { color: var(--primary); }
The card compiles, lint passes, the correctness check passes, and the styles
never apply. The host's and the component libraries' own CSS uses :global;
card code cannot copy it. Use instead:
...attributes through (Pret UI and boxel-ui controls, and a linked or
compound field invocation such as <@fields.link class='…' />) lands on its
root and is reachable with a plain scoped selector. Pret UI's own styles are
in cascade layers, so that rule wins without extra specificity. A class on
Select lands on its wrapper, so reach its trigger with
:deep(.pretui-selecttrigger). A boxel-ui component is restyled through
its knobs, not a rule on its classes. A primitive leaf field
(<@fields.title class='…' /> on a StringField) renders bare text, so the
class lands nowhere; wrap it in an element of your own.:deep() for DOM you neither render nor can put a class on (the
internals of a component or a host shell). It compiles to a scoped ancestor
and an unscoped descendant, which the browser accepts.Grep for :global( before finishing any card.
Intl formatter once, at module scope — never per callEach new Intl.DateTimeFormat(…) holds roughly 15–30 KB of ICU memory outside
the JavaScript heap. The garbage collector does not count that memory, so it
feels no pressure to free it. A date formatter built inside a function that
runs per row, per render, grows the browser tab by hundreds of MB per second
while the JS heap stays small: the render times out, the tab is killed, and a
prerender of the card can take down every other card rendering beside it. In
Chrome, 200,000 constructions grew a tab from 34 MB to 5.8 GB; one shared
formatter doing the same 200,000 calls grew it by nothing. The other
formatters (Intl.NumberFormat, RelativeTimeFormat, Collator,
PluralRules, ListFormat) hold less memory, but each construction still
costs about 40 format calls. Lint passes, sample data renders fine, and the
card fails only once real data piles up.
Inside a getter, computeVia, helper, loop, map / filter / sort /
reduce callback, or any function a template calls (or one called from it),
never:
Intl formatter (new Intl.DateTimeFormat(…), or the same
call without new);toLocaleString / toLocaleDateString / toLocaleTimeString with
options, or localeCompare with options. Each such call builds a formatter
or collator internally and throws it away. That costs CPU on every call
(about 30 times a shared formatter's format) rather than memory, but
per row and per render it adds up the same way.Build each formatter once at module scope. When the locale, time zone or
currency comes from the data, cache formatters in a module-level Map keyed by
the options:
// wrong — a new formatter for every row, on every render
const dayKey = (d: Date, timeZone: string) =>
new Intl.DateTimeFormat('en-CA', { timeZone, year: 'numeric', month: '2-digit', day: '2-digit' }).format(d);
// wrong — rebuilds a formatter internally on every call
const dayLabel = (d: Date) => d.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric' });
// right — module scope: one formatter for the whole module
const dayLabelFormat = new Intl.DateTimeFormat('en-US', { weekday: 'short', month: 'short', day: 'numeric' });
const dayLabel = (d: Date) => dayLabelFormat.format(d);
// right — options vary with the data: one formatter per time zone, ever
const dayKeyFormats = new Map<string, Intl.DateTimeFormat>();
function dayKey(d: Date, timeZone: string) {
let format = dayKeyFormats.get(timeZone);
if (!format) {
format = new Intl.DateTimeFormat('en-CA', { timeZone, year: 'numeric', month: '2-digit', day: '2-digit' });
dayKeyFormats.set(timeZone, format);
}
return format.format(d); // YYYY-MM-DD in that time zone
}
// right — sorting by a locale-aware compare: one collator, not one per comparison
const byName = new Intl.Collator('en', { sensitivity: 'base' });
people.sort((a, b) => byName.compare(a.name, b.name));
Safe on any path:
toLocaleString(), toLocaleDateString(), toLocaleTimeString() and
localeCompare(other) with no options and at most one fixed locale
(n.toLocaleString(), d.toLocaleDateString('en-US'),
a.localeCompare(b)), which reuse a cached formatter or collator. A locale
that changes from row to row defeats that cache, so build those formatters in
a module-level Map as above.formatDateTime, formatCurrency, formatNumber and
formatRelativeTime helpers, which cache their formatters.For a card that formats dates, numbers or currency, grep for Intl.,
toLocale and localeCompare before finishing. Every hit is at module scope,
inside a module-level cache, or a safe call from the list above.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
boxel-skills@cardstack-boxel is listed by cardstack/boxel — review the source before installing
npx claudepluginhub cardstack/boxel --plugin boxel-skills27 skills in this plugin
/api-integrationsUse when a card needs data from, or sends data to, a third-party API — "show my GitHub pull requests in a card", "pull my open issues", "a card that calls the weather API with my key", "integrate with Stripe/Twilio/OpenAI", "how often can this card poll", "build a PR inbox". Takes a card author from "I want data from this vendor" to a working card: classifying the integration (no key, a key the workspace shares, the user's own key, a key that can write), choosing a live card or a scheduled pipeline (and why private data takes the pipeline), declaring the `callApi` operations with labels and credential slots, estimating polling cost, and recipes for GitHub (GraphQL, a GitHub App or a read-only fine-grained token, the PR inbox as a pipeline and as a live card), for a plain API key sent in a header, and for images from an AI vendor called with the user's own key (an automation run's own AI requests carry text only). Activates on "third-party API", "vendor API", "integration", "pipeline", "live card", "On a schedule and when the card is opened", "poll", "GitHub API", "GraphQL", `callApi`, `{{userKey}}`, `{{apiKey}}`, "image generation", "AI vendor key", "automation image"./api-keysUse when a card or the AI assistant needs a user's API key, or a key shared into a workspace — "this card needs my GitHub token", "the forecast operation was refused binding-not-approved", "let the user add their key", "share my key with this workspace", "add a key button". Also "sign in to GitHub from this card", "connect my account", "the operation was refused credential-rejected", "the service rejected my key", "should I register a GitHub App or an OAuth App". Covers getting a key from the user only through Boxel's secure window, with the open-secure-window tool: opening it from a card through `@context.toolContext` or from the assistant, its modes (enter a key, replace the key an operation sends, share a key, connect an account through OAuth, approve a card's requests for scheduled pipelines or also for when the card is opened, review what changed in them), passing only the operation the card is blocked on and letting the window gather the card's other operations into one approval, what the tool answers, the blocked-popup fallback, telling the user to check the address bar, what to do when the service rejects a key (stop polling, offer Try again, and Reconnect, which opens the window to replace the key), OAuth clients and connections (when to use a connection rather than a static key, what the card declares, opening connect mode, `credential-rejected` and its reasons, sharing a client into a workspace, and why GitHub takes a GitHub App), and never asking for a credential in the chat or building a form for one. Also covers asking first with `@context.keyReadiness` — the answers (`ready`, `needs-connect`, `needs-approval`, `needs-reapproval`, `needs-admin`, `needs-sign-in`, `rate-limited`, `over-budget`), what a card shows for each and what the secure window can fix, and treating `undefined` as "not known yet" so prerendered HTML never shows Connect. Also covers a call refused for the key owner's limits (`rate-limited`, `over-budget`, `rate-limit-unavailable`): backing off by `retryAfterSeconds` and saying the limit is reached without naming a budget. Activates on "approve", "Allow", "review changes", `needs-approval`, `needs-reapproval`, `open-secure-window`, `OpenSecureWindowTool`, `keyReadiness`, "secure window", "API key", "enter a key", "replace a key", "share a key", "OAuth", "connect", "Reconnect", "GitHub App", `{{userKey}}`, `{{apiKey}}`, `binding-not-approved`, `interactive-use-not-approved`, `anonymous-use-not-approved`, "On a schedule and when the card is opened", "people who aren't signed in", "anonymous cap", `credential-rejected`, `rate-limited`, `over-budget`.