/boxel-skills:boxel-file-deffrom boxel-skills
Use when adding or working with file-typed fields (FileDef, ImageDef, MarkdownDef, PngDef, CsvFileDef). Activates when a card needs to reference an image, document, or other file asset.
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.
Read when SKILL.md points to them.
How to use FileDef, ImageDef, MarkdownDef, and related types for file fields in Boxel cards
Need to reference an image / document / file asset?
│
├── External URL only (a photo URL, a cover from Open Library, an avatar from gravatar)?
│ └── → the catalog `ImageSourceField` (or the URL/ImageDef pair): the URL goes
│ in its `url` half, and the slot can switch to a realm file later with no
│ schema change (references/sample-images.md). A link to a non-image file
│ elsewhere is `contains(UrlField)`. Never store `data:`, `blob:`, or
│ base64 in either.
│
├── File lives inside this realm and you want to display it?
│ └── → `linksTo(ImageDef)` for images, `linksTo(MarkdownDef)` for markdown,
│ `linksTo(PngDef)` for explicit PNG, `linksTo(CsvFileDef)` for CSV,
│ `linksTo(FileDef)` for generic.
│
├── File is uploaded by the user via the card editor?
│ └── → `linksTo(ImageDef)` (or correct subtype). The host's edit-mode picker
│ handles upload; the field stores the resulting realm file URL.
│
├── File is generated by AI/API and arrives as a `data:` URI / blob / bytes?
│ └── → Write the bytes to a realm file, then store only
│ `linksTo(PngDef/ImageDef/FileDef)`. You write them with
│ `await realm.fs.writeBytes(path, base64)` in a `run-realm-code`
│ script (see `source-code-editing`). Card code that makes the bytes
│ at runtime writes them with `WriteBinaryFileCommand`
│ (references/using-filedef-in-cards.md). The data URI can be a
│ transient command input or `@tracked` preview only; never a saved
│ card field.
│
└── Embed the raw bytes in the card JSON (legacy)?
└── → Forbidden for new work. `Base64ImageField` exists but is deprecated.
`contains(StringField)` with a base64 data URI is just as bad.
File explosion + huge JSON. Use `linksTo(ImageDef)` instead.
Never use contains(ImageDef). ImageDef extends FileDef and like CardDef, it has its own identity — it needs linksTo, not contains. This is the same rule as contains(CardDef): forbidden.
Never inline binary. The host rejects large card JSON around 512KB (Card size ... exceeds maximum allowed size (524288 bytes)), and even smaller inline media clogs the indexer and AI context. Store media bytes as files and link them.
The FileDef a file resolves to is also its policy type. A realm policy grants reads of a file's bytes by the FileDef subclass its extension names — .png is a PngDef, which a rule on ImageDef also matches — and an extension no def covers resolves to FileDef itself. So renaming a file changes which grant reaches it. Module source (.ts, .gts, .js, .gjs) is a TsFileDef or GtsFileDef, which only a rule naming one of those reaches: a rule on FileDef never serves code. See realm-policy-authoring §5.
boxel — for the surrounding CardDef/FieldDef and linksTo/contains rules.source-code-editing — for the actual file edits adding file fields.boxel-ui-guidelines — if you also render the file (image preview, document viewer) in a template.linksTo to a CardDef. FileDef is specifically for file-backed assets.references/filedef-first-class-file-support.md — FileDef — First-Class File Supportreferences/type-hierarchy.md — Type Hierarchyreferences/import-paths.md — Import Pathsreferences/available-fields.md — Available Fieldsreferences/using-filedef-in-cards.md — Using FileDef in Cardsreferences/rendering-file-fields-in-templates.md — Rendering File Fields in Templatesreferences/markdowndef-vs-markdownfield.md — MarkdownDef vs MarkdownFieldreferences/filedef-vs-base64imagefield.md — FileDef vs Base64ImageFieldreferences/no-inline-binary.md — Mandatory no-inline-media rule, generated image workflow, and A Million Dreams MP3 FileDef examplereferences/sample-images.md — Build-time sample images: pick a source by scenario (the user's own, AI-generated with realm.images.generate, a real photo from the Openverse API from a terminal, or a labelled placeholder), then link it without breaking the realmreferences/available-fields.md (opens in a new tab)references/filedef-first-class-file-support.md (opens in a new tab)references/filedef-vs-base64imagefield.md (opens in a new tab)references/import-paths.md (opens in a new tab)references/markdowndef-vs-markdownfield.md (opens in a new tab)references/no-inline-binary.md (opens in a new tab)references/rendering-file-fields-in-templates.md (opens in a new tab)references/sample-images.md (opens in a new tab)references/type-hierarchy.md (opens in a new tab)references/using-filedef-in-cards.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
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`.Other plugins' skills for the same job