/boxel-cli:dev-file-deffrom boxel-cli
How to use FileDef, ImageDef, MarkdownDef, and related types for file fields in Boxel cards
Ships in boxel-cli. 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.
FileDef is a third kind of "def" in Boxel, alongside CardDef and FieldDef. A FileDef instance represents a file that lives in the realm — an image, document, or other asset — with metadata automatically extracted during indexing.
linksTo, never containsisolated, embedded, fitted, and atom templatesFileDef → any file
├── ImageDef → any image (adds width, height)
│ ├── PngDef → .png files
│ ├── JpgDef → .jpg / .jpeg files
│ ├── SvgDef → .svg files
│ ├── GifDef → .gif files
│ ├── WebpDef → .webp files
│ └── AvifDef → .avif files
├── MarkdownDef → .md / .markdown (adds title, excerpt, content)
├── TextFileDef → .txt (adds title, excerpt, content)
├── TsFileDef → .ts (adds title, excerpt, content)
├── GtsFileDef → .gts (extends TsFileDef)
├── JsonFileDef → .json (adds title, excerpt, content)
└── CsvFileDef → .csv (adds title, excerpt, content, columns, columnCount, rowCount)
Use the most specific type that fits. Prefer PngDef over ImageDef when you specifically need PNG; prefer ImageDef over FileDef when any image format is acceptable.
This set is not extensible by Boxel users (currently). The Boxel project provides these types and only new releases of boxel can add new ones. This may change in the future.
import FileDef from 'https://cardstack.com/base/file-api';
// Image types
import ImageDef from 'https://cardstack.com/base/image-file-def';
import PngDef from 'https://cardstack.com/base/png-image-def';
import JpgDef from 'https://cardstack.com/base/jpg-image-def';
import SvgDef from 'https://cardstack.com/base/svg-image-def';
import GifDef from 'https://cardstack.com/base/gif-image-def';
import WebpDef from 'https://cardstack.com/base/webp-image-def';
import AvifDef from 'https://cardstack.com/base/avif-image-def';
// Document / text types
import MarkdownDef from 'https://cardstack.com/base/markdown-file-def';
import TextFileDef from 'https://cardstack.com/base/text-file-def';
import TsFileDef from 'https://cardstack.com/base/ts-file-def';
import GtsFileDef from 'https://cardstack.com/base/gts-file-def';
import JsonFileDef from 'https://cardstack.com/base/json-file-def';
import CsvFileDef from 'https://cardstack.com/base/csv-file-def';
Every FileDef instance exposes these base fields:
| Field | Type | Description |
|---|---|---|
id | string | URL identifier of the file |
url | string | Current URL of the file |
sourceUrl | string | Original source URL |
name | string | Filename (e.g. photo.png) |
contentType | string | MIME type (e.g. image/png) |
contentHash | string | MD5 hash of file content |
contentSize | number | File size in bytes |
Additional fields added by subtype:
| Type | Extra Fields |
|---|---|
ImageDef + all image subtypes | width (px), height (px) |
MarkdownDef, TextFileDef, TsFileDef, GtsFileDef, JsonFileDef | title, excerpt, content (full text) |
CsvFileDef | title, excerpt, content, columns (array), columnCount, rowCount |
import { CardDef, field, linksTo } from 'https://cardstack.com/base/card-api';
import ImageDef from 'https://cardstack.com/base/image-file-def';
import PngDef from 'https://cardstack.com/base/png-image-def';
import FileDef from 'https://cardstack.com/base/file-api';
import MarkdownDef from 'https://cardstack.com/base/markdown-file-def';
export class ProductListing extends CardDef {
@field photo = linksTo(PngDef); // Specifically PNG
@field banner = linksTo(ImageDef); // Any image format
@field attachment = linksTo(FileDef); // Any file type
@field readme = linksTo(MarkdownDef); // Markdown document
}
Use <@fields.fieldName /> exactly as with any other field. The built-in display components handle rendering automatically.
static isolated = class Isolated extends Component<typeof ProductListing> {
<template>
<div class='product'>
{{! Full image with filename and dimensions shown }}
<@fields.photo @format="isolated" />
{{! Responsive inline image filling its container }}
<@fields.banner @format="embedded" />
{{! Thumbnail + filename (good for lists/atom use) }}
<@fields.photo @format="atom" />
{{! Access raw metadata directly when needed }}
<p>{{@model.photo.name}} ({{@model.photo.width}}×{{@model.photo.height}}px)</p>
<p>Size: {{@model.attachment.contentSize}} bytes</p>
</div>
</template>
};
Image built-in formats:
isolated → full-size image + filename + dimensions footerembedded → responsive <img> that fills its container widthfitted → background-image: cover for fixed-size grid cellsatom → 20 px thumbnail + filename inlineThese are completely different and are not interchangeable:
MarkdownDef | MarkdownField | |
|---|---|---|
| Kind | FileDef — a .md file in the realm | FieldDef — inline text stored in the card's JSON |
| Import | https://cardstack.com/base/markdown-file-def | https://cardstack.com/base/markdown |
| Declaration | @field notes = linksTo(MarkdownDef) | @field notes = contains(MarkdownField) |
| Stored as | Separate .md file referenced by URL | String embedded in the card's .json |
| Has own URL? | ✅ Yes — shareable and reusable | ❌ No — owned by the containing card |
| Editable in card UI? | ❌ No — replaced by uploading a new file | ✅ Yes — inline markdown editor |
| Extra fields | title, excerpt, content auto-extracted | Raw markdown string only |
| Use when | Stand-alone documents, content shared across cards, files managed outside Boxel | Inline rich text that belongs to the card, like a description or body field |
🚨 Do NOT use Base64ImageField for images. Use an image FileDef type instead.
FileDef (ImageDef, PngDef, etc.) | Base64ImageField | |
|---|---|---|
| Storage | Separate file in the realm | Base64 data embedded in the card's JSON |
| AI context cost | ✅ Minimal — just a URL reference | ❌ Extremely large — can exhaust context |
| Shareable | ✅ Yes — has its own URL | ❌ No — embedded in one card |
| Performance | ✅ Standard HTTP caching | ❌ Bloated JSON payloads |
| Use | ✅ Always prefer this | ⚠️ Avoid |
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub review-bench/cardstack_boxel --plugin boxel-cli15 skills in this plugin
/boxel-apiUse when calling Boxel realm-server APIs from code — primarily federated search across realms. Documents the boxel-cli programmatic surface (`BoxelCLIClient`) and the matching CLI commands. Read this whenever you need to query a realm's index./boxel-commandUse when running a Boxel host command via the realm server's prerenderer — invoking commands like `get-card-type-schema`, `evaluate-module`, `instantiate-card`, or any other module exposed at `@cardstack/boxel-host/commands/.../default`. Documents `boxel run-command` and the matching `client.runCommand()` method./boxel-designBoxel UI design discovery. Use when designing or redesigning a Boxel app, choosing a visual direction, or pushing past default look-and-feel before generating code.Other plugins' skills for the same job