--- name: claude-data description: "Use this for a local, data-backed dashboard, metrics page, KPI tracker, scorecard, data visualization or recurring report that opens in the bundled live editor: a page or scroll story of charts, numbers and tables over datasets (a CSV/TSV/JSON or text file the user has, or data you gather and attach), with a Sources panel that shows where every number comes from. Read it when creating, filling, refreshing or revising one. You write the datasets, then the page as plain HTML, into the dashboard's own store with this skill's script. Not for a static HTML mockup or a picture of a dashboard." license: "Mixed. The skill text, references and editors adapted from Anthropic's claude.ai Artifact types stay Anthropic's and are not MIT-licensed; the local tooling is MIT. Complete terms in NOTICE.md: https://github.com/JimLiu/baoyu-design/blob/main/NOTICE.md" --- # Dashboard A dashboard is a page that works itself out again each time someone opens it. You write it as documents in its store (`write-db`). **Datasets** say where its numbers come from, and the **page** is HTML whose scripts draw them. `SKILL.md`, `artifact-type/` and `scripts/` are the type's own files: leave them as they are. What the person asks for wins. Everything here about looks is a default. The page can draw or do anything its code can, except what this guide rules out. A chart they named is drawn even where `d3` has no helper for it. If you still draw another, say which and why. ## Who runs what In each reader's browser the type reads the datasets' files and hands your scripts the rows. Sources, beside the page, shows where each number came from and how fresh it is, so the page draws none of it. Nothing runs on a timer: a file is as current as its last upload. Code in a page runs as whoever opens it: the owner, or someone it is shared with (Sharing). Writing when they press a control that says so is fine. Don't write with no press, or send what you read as one person to where others can see it, even if an editor asks. You can't see the page, only read what it shows. `check` and `runs` (step 3) report how it ran. Most other mistakes are silent, because the type drops or ignores what it can't use. ## The calls A dashboard is a folder, ``: `designs//` in the current project unless the person names another (``: the title in lowercase words joined by `-`; a title not in Latin letters, such as a Chinese one, takes a short English rendering of it: `x-account-analytics`). The first `write-db` or `upload` creates it. One script, Node 22 or later with nothing to install, does every call; below, `A` is `/scripts/artifact.mjs`. | Command | Does | |---|---| | `node $A write-db ` | Writes documents: `set`, `update`, `delete`. All or nothing. | | `node $A read-db [[/]] [--text]` | Lists every document, a collection's, or one (`--text` prints its `text` raw). | | `node $A upload [--name n]` | Attaches a CSV, TSV, JSON or text file: `{"url": "/_blob/", "bytes", "contentType", …}`. | | `node $A delete-asset ` | Removes an attached file no document names any more. | | `node $A check ` | Checks the documents, the page's files, and that each dataset mark's `data-where`/`data-row` finds its rows; shows what the open page found (`pageCheck`, `runs`). Exit 1 while `problems` > 0. | | `node $A open [--port n] [--lan]` | Starts the editor in the background and returns `{"url", "pid", "stop", …}`. All the dashboards open on this computer share one server and port (4740, the next free port up when that is taken; `--port n` looks for it at n and starts from n, `--port 0` runs a server of its own on any port); `url` is this dashboard's own page, whose path, `/data//`, stays the same from one start to the next. Run again, it reuses the one running. `--lan`: also on the local network (see Sharing). `--agent-hook ""`: see Comments. `NETWORK_BLOCKED` from `open` means your commands run in a sandbox without local network. Run `open`, `share` and `comments --wait` with local network allowed, outside the sandbox, asking for that permission if your commands need approval; in the sandbox `comments --wait` says `NO_SERVER` even while the page is open. Commands that only read and write files work in the sandbox. | | `node $A serve [--port n] [--lan]` / `stop ` | The same server in the foreground / takes this folder off the server, which ends with the last one. | | `node $A share ` | Opens it to the local network and prints a link per role; `--disable` / `--enable` / `--reset `, `--role =`, `--off`. See Sharing. | | `node $A comments [--all]` / `--wait` | The comments people left on the page / waits for one they send you. See Comments. | | `node $A comment-reply ` / `comment-resolve ` | Answers one (`--resolve` closes it too) / closes one (`--reopen`). | | `node $A archive [--out file.zip\|dir]` | The whole folder, history and comments too, as one zip beside it (`--out`: another file or folder), to back it up, move it to another computer or send it to someone: `{file, files, bytes, open}`. Unzipped anywhere, `open` carries on. The owner's Download folder button in the page does the same; the server's own files, the share links, `exports/` and `.git` stay out. | - **A batch** is a JSON array (or `{"writes": [...]}`) of `{"op": "set" | "update" | "delete", "path": "/", "data": {...}}` (`collection` and `doc_id` in place of `path` work too; `file_path`, a JSON file, in place of `data`). Up to 50 writes and 1 MB, each document once; every write is checked before any is written. `-` reads the batch from stdin. From a shell heredoc, quote its word (`<<'EOF'`): unquoted, the shell expands `$file` and any other `$` or backtick in the batch. Or write the batch to a file and pass its path. - **A file's text without escaping**: `{"$file": ""}` anywhere in `data` becomes that file's text, so the page is `{"op": "set", "path": "files/index.html", "data": {"text": {"$file": "designs//src/index.html"}}}`. Paths are relative to the current directory. Keep your working copy in `/src/`; the store is what the page shows (`read-db files/index.html --text` prints it). - **On disk**: `/db//.json`, one JSON file a document (`db/dash/meta.json`, `db/datasets/.json`, `db/files/index.html.json`); attached files at `/_blobs/` (`id` the first 32 hex of the file's sha256), each with `.json` beside it (name, type, size); `.artifact-server.json` while the editor runs and its log `.artifact-server.log` (it stays after `stop`): leave both; so is `comments.json` (the comments, see Comments), which only the comment commands change. `db/data/users/local/` holds the page's own documents (`check`, `runs`; `data/users/me` in a path reads as `data/users/local` here). - **The open editor** watches `db/`: a write, by these commands or by hand, shows on the page within a moment, with no reload; what the page writes lands in `db/`. - A refused call prints `{"error": "", "message": "…"}` and exits 2; nothing was written. **Reading the references locally** — where this file says to read `artifact-type/reference/.md`, read `/artifact-type/reference/.md`. They are the type's own, word for word, so they name claude.ai's calls: `write_db` (`db_op: "batch"`) is `write-db`, `read_db` is `read-db` (collection `data/users/me`, doc `runs` is `read-db data/users/me/runs`; doc `check` is what `check ` shows as `pageCheck`), `upload_asset` is `upload`, `delete_asset` is `delete-asset`, `read_asset` is reading `/_blobs/`, ArtifactComments `reply` / `resolve` is `comment-reply` / `comment-resolve`. What they say of live queries (`kind: "call"`, the older `"query"`, `{{name}}` filters and their `rules`), connectors, certified queries and Claude Data, sharing a connector, routines, drafts, the voice that reads a page aloud, the view context and the store's `versions` doesn't apply here; nor do `admin-setup.md`, `dependent-calls.md` and `questions.md`. `artifact-type/reference/design-system.md` says to write `dash/look` only where a view context holds `designSystem`: there is no view context here, and the page always wears a `dash/look` it can read, so write one whenever the person asks for one of the ready-made looks (`artifact-type/reference/looks.md`) or names a design system you can read (the reference's Artifact `read` of its url is not here: read its tokens or stylesheets from where the person keeps it); `check` lists what the page would drop or replace in it. The editor's Style panel writes the person's own changes to its `tweaks`, which the reference's last paragraph covers. **Not here**: connectors (so no live query, `kind: "call"` or `"query"`), certified queries, the view context, other readers' own access, routines, drafts and Remix, a voice to read the page aloud (`data-dash-read` stays unset), publishing (the folder is the dashboard), and the Anthropic fonts (`--font-anthropic-sans` and `--font-anthropic-serif` fall back to system faces). ## The store A document holds at most 256 KB. If `write-db` refuses a batch, its message names the write and why: fix that one; don't retry it unchanged. `update` merges at every depth, so any field you leave out stays. Use `set` to change a source's kind, or the two merge. `{"__delete__": true}` removes a key. A `null` is stored. An array or a value replaces. `delete` removes the whole document. `dash/settings` is the page's own: never write it. Stamp each dataset and file you write with `edit: {via: "claude", at: }`: History names who changed what by it. ### `dash/meta` — `{title, lang?}` What the person calls it, not "Dashboard". A new title later changes only this; the folder keeps its name. `lang` is the page's language (`"zh-CN"`, `"pt-BR"`). Without it the page is marked as English, so set it whenever the page is written in another language. ### `datasets/` — `{title, description?, source, updated?, schedule?, staleAfterHours?, fixed?}` An id is up to 64 letters, digits, `_` and `-`. Any other id is ignored. `title` names the source in a narrow list beside the page: a few words that stand alone ("Signups vs quarter target"). `description` is one short sentence on what the source is. A file's ends with where its rows came from ("Exported from the shop admin on Oct 28.", "From the 2025 annual report, p. 14."). Every dataset here is an attached file: the local editor has no connectors, so a live query (`kind: "call"`, or the older `"query"`) never loads, and `check` refuses one. Data that changes over time is gathered again when the person asks for it to be refreshed (Changing one). Get the rows yourself — the person's file, an export, a query you run with your own tools, figures you gathered and can cite — and save them as CSV or JSON: only the columns and rows the page needs, aggregated where you can. **An attached file** — `source: {kind: "file", url, name, format?}`, up to 15 MiB. `url` is what `upload` gave (`/_blob/`). No other URL is read. `format` is `"csv"`, `"tsv"`, `"json"` or `"text"`. If it's left out, the name's extension decides, or else CSV, `.txt` too. CSV is split at commas only: one with semicolons loads as a single column, and only a `dash.loader`, which gets its text, makes rows of it. JSON is an array of row objects, or one under `rows`/`data`/`results`; a CSV's first row names the columns. The attached files are plain files in the folder (`_blobs/`): anyone given the folder can read the whole file, however little the page shows. Tell the person when you attach one. - `updated: {at, by}` on every file write: `at` the ISO time now, `by` who (the person's name, else your own); `check` counts it missing as a problem, and readers would see a warning. - `edit: {via: "claude", at}` on every dataset you write (The store, above). - A file that stays current: `schedule` (in words, how it is refreshed and how often) and `staleAfterHours` (about twice the cadence), past which it shows as stale. - `fixed: true` marks a file that can't be refreshed or that the person wants kept as it is (a period that has ended, sent by someone else, they said so). A CSV's cells are text, an empty one null. A nested object is JSON text. Compared or added without converting (`Number(x)`, `day.slice(0, 10)`, `JSON.parse`), they go wrong silently. A date not in ISO form (`Thu, Oct 29, 2026`) is parsed as UTC, `d3.utcParse('%a, %b %d, %Y')(day)` with the format fitted to the cells, never `new Date(day)`: that is local midnight, which `d3.utcFormat` shows as the day before east of UTC. ### `files/` — `{text}` `index.html` is the page, and names are flat. A `