Skip to main content
hatchmark <command> [options]. Every command runs without prompts, so scripts and AI agents can run it the same way a person does. hatchmark <command> --help shows a command’s options and one example. hatchmark docs lists every docs page; the files a project holds are described in Project file, Metrics and Dashboards.

Output

A command prints human text when stdout is a terminal. It prints one line of JSON on stdout when stdout is not a terminal, when an AI coding agent runs it (detected with @vercel/detect-agent), or when you pass --json. --format human|json picks the format explicitly and wins over both. Any other --format value is a usage error (exit 2), even with --json. Logs go to stderr, so stdout always holds exactly one result. The mode applies to every result, help and command-line errors included: --help in JSON mode prints the command’s usage, options and example as JSON. Every JSON result has format_version: "1". Check results and every error, usage errors included, use the diagnostic report described in Diagnostics. Colour is on in a terminal unless you pass --no-color or set NO_COLOR.

Printing the SQL

hatchmark explain <metric> prints the SQL that build runs for one metric. It reads the metric by month over last_12_months as of latest_data. The metric’s own filters and segments apply, and no dashboard filters do. A metric without a time column is read once over all rows. hatchmark explain --dashboard <name> --block <id> prints the queries of one block instead. hatchmark check --sql prints the queries of every block. In both cases each filter is at its default. A grain switch prints one query per grain. A comparison window that doesn’t exist, such as all_time, is left out, the same way build skips it. explain also says whether the next build would reuse each query’s result from the build cache: human output ends with one -- build cache line per query (hit, stale and what changed, miss, or off for raw SQL metrics), and JSON gives each query a cache object with status, stored_at, changed, changed_files and the data files with their SHA-256. Explain only reads the cache, never writes it. The printed SQL is the text the DuckDB executor runs. The same core function builds it with the same values. Human output inlines each value as a SQL literal of the type it is bound as. Strings are VARCHAR and booleans are BOOLEAN. Whole numbers are INTEGER or BIGINT. Other numbers are DOUBLE, such as CAST(0.1 AS DOUBLE), so a comparison with a FLOAT column gives the same rows. Quoted identifiers, string literals and comments are left as they are. JSON output keeps the $hm_pN parameters and gives their values:
--dashboard and --block output has dashboard and block in place of metric. check --json --sql adds sql: [{ dashboard, block, queries }] to the diagnostic report. Nothing runs when check finds an error. With paths, an error in a file outside them that keeps a dashboard from building is one HM2015 error on that dashboard. A block the planner leaves out, such as a metric with segments (HM4023), has no queries, and its warning is in diagnostics. "__hm_source_<name>" is a temporary table that holds the source’s rows, in file order. "__hm_ord" numbers those rows, so floating-point sums always add the values in the same order.

Global options

Exit codes

Usage diagnostics

data

hatchmark data lets you (or an agent) look at the data before writing metrics and dashboards. Both subcommands read each source with the same reader options build uses, so the types they print are the types metrics see. The session time zone is UTC: timestamps with an offset print in UTC. hatchmark data describe <source> prints, for each column, its DuckDB type, a kind (time, number, boolean, text or other), the number of nulls and of distinct non-null values, and the min and max of time and number columns. It also prints the row count and the first rows in file order (--limit <n>, default 5, 0 for none). A lookup source is not a file; describe the sources it joins. A postgres or mysql source is read from its copy, as build reads it: a copy younger than max_age is reused, otherwise the rows are fetched into .hatchmark/tmp and removed afterwards, and a missing or unreachable database gives HM2040 or HM2041. hatchmark data query "<sql>" runs one SELECT statement. Each file or database source is a table named after the source, and sources lists them; a CTE of the same name hides the source. A missing or unreadable source gives HM2010 or HM2015 only when the query reads it. The query cannot read files other than the sources or write anything: any other statement, more than one statement, or a file access gives HM0008, and nothing runs. A DuckDB error gives HM0009 with DuckDB’s message. At most --limit rows print (default 100, at most 10000), and truncated says whether the query had more. Values are DuckDB’s, before the rounding build applies to displayed numbers.
Rows are arrays in column order. Integers beyond ±2^53, and DECIMAL values a JSON number cannot hold exactly, are strings, so no digit is lost; dates are YYYY-MM-DD text and timestamps are DuckDB’s text.

init

hatchmark init writes the same bytes every time for the same name and template. It never runs git or installs packages. With --force, it overwrites only the files it writes and reports them as created, updated or unchanged. It resolves the directory it initialises once with realpath, so symlinks above it (such as macOS /tmp and /var) are fine. Inside that directory it never writes through a symlink: a symlinked file or subdirectory where it writes gives HM0004. It never writes to an existing CLAUDE.md. When that file does not include @AGENTS.md, it adds a note to the result. In AGENTS.md it replaces the block between exactly one <!-- hatchmark:start --> line and one later <!-- hatchmark:end --> line, each alone on its line (surrounding spaces are fine), or appends a block when there are no marker lines. With any other combination, including marker text that shares a line with anything else, it changes nothing and reports HM0005 with the marker lines. --skills also installs the agent skill into .claude/skills/hatchmark/ and .agents/skills/hatchmark/, as hatchmark skills install does (see skills); --force then also replaces a skill directory Hatchmark did not write. The result gains a skills list only with that flag.

docs

hatchmark docs reads the docs that ship inside the installed package (node_modules/hatchmark/docs/), so what it prints always matches the version that runs your project, offline.
  • hatchmark docs lists the topics: each page’s path without .md (index for the README), such as metrics or components/table. A component page also answers to its short name, table.
  • hatchmark docs <topic> prints a page as it is.
  • hatchmark docs <topic>#<section> prints one section, from its heading to the next heading of the same or a higher level. The section is the heading’s anchor as GitHub writes it: lower case, punctuation dropped, spaces as -, and -1, -2 for repeated headings.
  • hatchmark docs --search "<words>" lists the sections whose own text (without their subsections) holds every word, case-insensitive, best first, at most --limit (default 10). Each result has the section to print it, its title, the line in the page and a snippet.
JSON results carry version. A page or section result has topic, path, title and content.

skills

Hatchmark ships an Agent Skills package in the installed package (node_modules/hatchmark/skills/hatchmark/): a short SKILL.md with the workflow for coding agents (look at the data, write one YAML file per thing, hatchmark check --json after every edit, hatchmark explain, hatchmark docs) and references/ pages that point into these docs. Agents load it when a task is about Hatchmark dashboards, metrics or sources. hatchmark skills install [--agent claude|codex] [--scope project|user] [--force] copies it into the directories each agent reads skills from: Claude Code reads skills from .claude/skills/ and ~/.claude/skills/. OpenAI Codex reads .agents/skills/ from the working directory up to the repository root and ~/.agents/skills/; that directory is the cross-agent convention other Agent Skills tools, such as GitHub Copilot in VS Code, read too. Without --agent, install writes both. The installed SKILL.md is the bundled one with metadata: { hatchmark-version: "<version>" } added to its front matter (with the file’s own line endings), always the version of the CLI that wrote it; every other file is copied byte for byte. Install also writes .hatchmark-skill.json next to them: the version and the SHA-256 of every file it wrote. That manifest marks a directory as Hatchmark’s and tells an untouched copy from an edited one:
  • A directory that does not exist is created.
  • A copy whose files all match the manifest is clean. A clean copy with the bundled files is unchanged; any other clean copy, such as one from another version, is updated without asking. Install replaces the whole directory, so files the bundle no longer has go away.
  • A copy with a changed, added or deleted file is modified, and a hatchmark skill directory without a manifest was not written by Hatchmark. Install refuses both with HM0010 unless you pass --force, which replaces them.
  • A symlink, FIFO or anything else that is not a regular file or directory on the way to the skill directory or inside it (such as .claude/skills linked elsewhere) gives HM0010, even with --force. So does a path that cannot be read or written (EACCES, EPERM, EROFS, ENOSPC), with the path and the error.
Install checks every target first, then writes each new copy into a staging directory next to its target, then swaps the copies in. If anything fails before every copy is in place, it removes what it staged, puts back any copy it had moved aside, and writes nothing. Once the new copies are in place the install has succeeded (exit 0). It then deletes the previous copies; one it cannot delete is named in warnings (human output: a warning: line), so you can remove the leftover .hatchmark-old-* directory yourself.
hatchmark skills status lists each of the four directories (or those --agent and --scope pick) with the version from its manifest and a status: missing, current, stale (a clean copy of another version), modified (changed since it was installed), foreign (not written by Hatchmark), blocked (install would refuse a symlink or special file there) or unreadable; the last two carry a detail with the path. Status reads through the same checks as install, so it never opens a FIFO or follows a symlink. hatchmark init --skills stages the skill before init writes anything and installs it at project scope for both agents. If the skill then cannot be swapped in, init exits 2 with HM0010 saying that it wrote the project, and its JSON and human output still list the project files it created, updated or left unchanged, with an empty skills list. hatchmark doctor warns about every stale copy, project or user, and prints the hatchmark skills install --agent <agent> --scope <scope> command that refreshes it, shell-quoted so it can be pasted as is; for a modified copy it prints the same command with --force. It never suggests an install for a blocked or unreadable path, and no copy is not a warning.

test

hatchmark test runs every test in the project, or those of the metrics and sources it names, and exits 1 when one fails, so it fits a CI step. Metric tests are described in Metrics and row-count tests in Project file. Each test reads the data through the same queries as build, so a pinned number is the number a dashboard shows. Before a test is read, the project is checked as hatchmark check checks it. Any error stops the run: no test runs, results is empty, and the exit code is the one check gives for that error. The JSON report is the check report (format_version, ok, error_count, warning_count, diagnostics) plus passed, failed, errors (tests that could not run, such as a missing fixture file or a metric the planner can’t evaluate yet) and one entry per test in results:
  • Always: kind (metric or source), target, index, file, pointer and status (pass, fail or error). name when the test has one.
  • When the test was read: expected and actual. actual is null when the metric has no value.
  • difference (actual minus expected) when both are numbers. A test with by gives actual and difference per group, with null for a group without a value.
Diagnostics: HM4030 for each test whose value was compared and differs, HM4031 (a warning) for a test that reads past the data, and the reason for each test that could not run. A failed test without by carries an unsafe fix that pins the actual value; one with by doesn’t. Exit codes: 0 when every test passed. Otherwise: 2 for an error in hatchmark.yaml, a name that is no metric or source, or no project; 3 when the only errors are missing data or fixture files; 1 for anything else, a failed test or an error in a metric file included; 4 for an internal error (HM9001). Every one of these reports has the fields above, with empty results when no test ran.

dev

hatchmark dev serves the project at http://localhost:5173/ (or the next free port) with the same renderer, runtime and fonts as hatchmark build, at the same URLs: /<dashboard>/ for each dashboard, and / as the index when there is more than one (with one dashboard, / redirects to it). It writes nothing into the project. It watches hatchmark.yaml, the metrics, segments and dashboards directories and every data file a source names. On a save it reloads the project and re-runs only the dashboards the change can affect: the edited dashboard, the dashboards that show an edited metric or whose queries change, and the dashboards whose queries read an edited data file. Everything re-runs when hatchmark.yaml or a segment changes. It then compares each card with the page in the browser:
  • Changed cards, or single KPIs in the KPI strip, are pushed over Vite’s HMR connection and swapped in place, and the browser runtime is attached to them again, so tooltips and grain switches work. A swapped card keeps the grain the reader picked on it, or else the header grain filter’s. The rest of the page, scroll position included, is left alone.
  • A structural change reloads the page: a block added, removed or moved, a changed span or block type, or anything outside the grid (title, description, filters, period, footer, theme).
  • An open page of a dashboard that was removed or renamed reloads into a “Dashboard removed” page (status 404), which reloads into the live dashboard when its file comes back. This holds for a page whose dashboard never built, too. The index reloads when a dashboard is added, removed or retitled, or the project name changes.
A data file that several sources read re-runs every dashboard that reads any of them. The file watcher ignores a second change to a file within 50 ms of the first, so dev checks each file again 100 ms after rebuilding it and rebuilds once more if it changed in between. When check or a dashboard’s queries report errors, dev prints them in the terminal and lays them over the page in the same format as hatchmark check, in the Default theme’s colours, light or dark. The page under it shows the last good build. The overlay clears on the next good build. --port <n> fails with HM0006 when the port is taken instead of choosing another one. --host 0.0.0.0 serves the local network; dev serves only the pages and their assets, never the project’s files. --open opens the page in the default browser. Output: in human mode dev prints the URL on stdout, then rebuild notes and diagnostics on stderr. In JSON mode it prints one line on stdout once the server is ready and nothing more there:
Diagnostics go to stderr in both modes. Dev runs until it is stopped with Ctrl-C (SIGINT) or SIGTERM, then exits 0. Without a hatchmark.yaml it exits 2 before starting. Dev never changes what build writes: the build output holds no Vite or HMR code.