Skip to main content
These are the steps for a coding agent to set up Hatchmark for a user: install the CLI, create or reuse a project, connect one data source and build a first checked page. This page is published at https://hatchmark.dev/docs/get-started/agent-setup.md for the latest release. Inside a project, hatchmark docs agent-setup prints the copy that matches the installed version; when the two differ, follow the installed copy. Run every command yourself. Ask the user only which data source to use and, for a database, to set the variable that holds its connection string. Never invent data, file paths, table names or credentials, and never write a password or connection string into a file.

1. Check the environment

Hatchmark needs Node.js 22.18 or later (on Node.js 23, 23.6 or later). If Node.js is missing or older, tell the user which version is installed and stop.

2. Install the CLI

Hatchmark is the hatchmark package on npm. When the user’s directory has a package.json, add it there, so the project and its MCP server run one pinned version:
Then confirm it runs:
It must report "ok": true (a warn for the project is fine). From here on, wherever a command on this page or in the skill says hatchmark, run npx -y hatchmark.

3. Ask for the data source

Ask the user which data to use, and wait for the answer before creating anything. Ask in the same question what the project is called, unless their request already says. If their directory already holds a data file, name it in the question:
  • A CSV, Parquet or JSON file: get its path.
  • A DuckDB or SQLite file: get its path and the table or view to read.
  • PostgreSQL, MySQL or SQL Server: get which one and the table or query. Ask the user to set an environment variable, such as SHOP_DATABASE_URL, to the connection string in the environment that runs your commands, and to tell you its name.
  • BigQuery: get the Google Cloud project that runs the queries, the dataset.table or query, and the location when it is not US. Ask the user to set an environment variable to a credential (the absolute path of a service account key or similar credential file, its JSON, or an access token) and to tell you its name.
  • No data yet: offer the sample data, US orders that the sample project ships with.
Never ask the user to paste a connection string or credential to you.

4. Create or reuse the project

If the user’s directory already has a hatchmark.yaml, it is a project: skip init and go to step 5. Otherwise create one. For the user’s own data, start empty:
--name is what the user calls the project, such as Acme sales; pages show it above each title. Take it from the user’s request, or ask with the data question in step 3. Never pass the directory name. Without --name the project has no name and pages lead with their own title. For the sample data, drop --template minimal: the sample project has US orders in data/orders.csv, four metrics and a sales dashboard with a weekly revenue chart, and its source orders is already connected. init never prompts and never runs git. Its JSON result lists what it wrote: hatchmark.yaml, a Hatchmark block in AGENTS.md (and a CLAUDE.md that includes it), entries in .gitignore, the agent skill under .claude/skills/ and .agents/skills/, and the hatchmark MCP server in .mcp.json and .codex/config.toml, set to run npx -y hatchmark mcp, which uses the project’s installed hatchmark when there is one. Tell the user what it wrote. Your agent loads the skill and the MCP server only after a restart, so keep using the CLI until then. Run every later command from the project directory, or add --cwd <dir>.

5. Connect the data source

List the source under sources in hatchmark.yaml, replacing the empty sources: {} that init --template minimal writes. The section of hatchmark docs named for each type has every option:
  • A CSV, Parquet or JSON file: move or copy it under data/, also when it already sits in the project directory, then orders: { type: csv, path: data/orders.csv } (type: parquet or json). path is relative to hatchmark.yaml. See hatchmark docs sources.
  • A DuckDB or SQLite file: under data/ too, with the table: orders: { type: duckdb, path: data/shop.duckdb, table: orders }. See hatchmark docs sources#duckdb-files and hatchmark docs sources#sqlite-files.
  • PostgreSQL, MySQL or SQL Server: orders: { type: postgres, env: SHOP_DATABASE_URL, table: public.orders } (type: mysql or sqlserver; query instead of table for a SELECT). env is the variable’s name, never its value. See hatchmark docs sources#database-sources.
  • BigQuery: orders: { type: bigquery, env: BIGQUERY_CREDENTIALS, project: acme-analytics, table: sales.orders }. See hatchmark docs sources#bigquery.
  • The sample data: nothing to do.
Then look at the data. The source must be in hatchmark.yaml first:
It lists the columns, their types, null and distinct counts and time ranges. Its success is what “connected” means below. If it fails, fix the source before writing anything else (see Troubleshooting).

6. Build the first page

Follow the installed skill (.claude/skills/hatchmark/SKILL.md or .agents/skills/hatchmark/SKILL.md) to write the metrics and a dashboard for what the user asked; its references/metrics.md and references/dashboards.md have short examples. A chart over time is a line block with a grain such as week (hatchmark docs line). A KPI computes its metric over the page’s whole range (a sum under last_12_months is a 12-month total), so match the range to the question: for “how did last week go”, give the page range: { last_complete: week } and keep the long trend on another page; when a page keeps last_12_months, name that window in the KPI title (hatchmark docs kpi#match-the-question). Trust hatchmark docs over memory: hatchmark docs --search "<words>" finds a section. With the sample data, the sales dashboard already exists.

7. Check that it worked

Setup is done only when both of these succeed:
check must exit 0 with "error_count": 0; warnings and notes are fine and need no change. build must exit 0 and lists the pages it wrote in pages. A database source needs its variable set for build: check alone passes without it. Then get the version from hatchmark doctor --json (its version field) and tell the user, filling in the values from the JSON results, with one Built line per page and (sample data) after the source when you used it:
In the preview line, write the command you actually ran, such as npx hatchmark dev --open. init points the MCP server at the same package. After the block, say in a sentence or two what you added: the metrics and dashboards you wrote. If a step fails, show the lines that passed, then the failing step with the diagnostic’s code, message and help line, such as ✗ hatchmark check: HM2010 data file not found followed by its help. hatchmark explain <code> explains any code. Fixing the cause and running the step again is fine.

Troubleshooting

The diagnostics setup runs into most often (hatchmark docs diagnostics has the format):
  • HM0004 from init: the directory already has files init would write. Use another directory, or reuse the project if it has a hatchmark.yaml.
  • HM2010: a source’s path points at no file. Paths are relative to hatchmark.yaml.
  • HM2018 or HM2015: a metric names a column the data does not have, or the data cannot be read. Compare with hatchmark data describe <source> --json.
  • HM2040: the variable a database source names in env is not set. Ask the user to set it.
  • HM0002 from data describe: the source is not in hatchmark.yaml yet, or its name differs.
  • HM2041: the database cannot be reached with that connection string. Its message gives the driver’s reason; ask the user to check the string and network access.