# Build an app with harbr

Documentation index: https://app.harbr.cloud/llms.txt
Human-readable guide: https://app.harbr.cloud/start

For agents in a T3 Code thread. The user says “make me an app that tracks X”; a few minutes later they have a live page at https://app.harbr.cloud/r/ID whose rows arrive from a script with an app key. Follow the steps in order. Replace ID with the copy’s 8-character ID.

## 1. Set up

Run harbr from a T3 Code thread. With this computer’s runner running (`harbr runner status` shows it), there is nothing else to set up: every command below goes through the runner as the thread’s own agent, with no `--profile`, `--context` or `-i`. Not set up yet, or the runner is not running: https://app.harbr.cloud/install.md.

```sh
harbr runner status
```

On a Mac the runner cannot yet tell which thread is calling, so harbr runs with the person’s sign-in that setup made: add `-i` to a command that writes (copy, publish, deploy, app-keys, share).

## 2. Pick a starter, or start blank

A starter is a working app: a page, a backend and skills. Pick the one that fits what the user wants to track:

**Tracker** `ka5pzejy`: numbers over time, each with a label and an optional note (water, runs, spending, sales, hours). Today’s total, a 7-day chart, recent entries. Scripts send with `add`.

**CRM** `5svsev33`: people or deals moving through stages (leads, clients, candidates). A pipeline by stage and a contact list. Scripts send with `save`.

**Dashboard** `zk3cf339`: several named numbers, the latest value and change of each (signups, revenue, uptime). Scripts send with `add`.

A starter close to the thing but missing a field (a mood on each entry) is still the right pick: step 3 adds the field to the copy. Start blank only when the thing is a different shape altogether (a booking with dates, stock levels per item): follow `harbr help backends`, one complete example.

```sh
harbr search --templates
```

## 3. Copy it and make it theirs

Copy makes a new, empty app in the user’s library with the starter’s page, backend and skills, never its data or keys. It prints the copy’s 8-character ID (`copy.shortId`); use it as ID below. It can take up to a minute and names each step on stderr as it goes. A new copy needs a place in the sidebar: `--no-project` (as below) leaves it outside every project; to put it in one of the user’s projects, pass `--project PROJECT` instead (`harbr nav list` lists them). With neither, a copy run outside a project’s git repo is refused (PROJECT_REQUIRED).

Then rename the page for the user’s thing: in `site/index.html` change the `<title>`, the `<h1>` and the field labels (for water: Value → Millilitres). Keep the element ids and the script, and map the user’s thing onto the starter’s fields where they fit. Publish the folder: its `artifact.json` makes it update the same page, and the page stays connected to the app.

The fields each starter stores (times are epoch milliseconds and default to now; `ref` is your own id, and sending the same `ref` again updates that row instead of adding one):

**Tracker** `add`: `value` (a number, required), `label` (what it counts, 1–40 characters, required), `note` (up to 280), `at` (when it happened), `ref`.

**CRM** `save`: `name` (up to 120, required when adding), `company`, `email`, `stage` (lead, qualified, proposal, won or lost; default lead), `value` (the deal’s value, 0 or more), `nextStep` (up to 200), `touchedAt` (last contact), `ref`; or `id` (from `board`) to update only the fields sent.

**Dashboard** `add`: `name` (the metric, 1–60 characters, required), `value` (a number, required), `at` (when it was measured), `note` (up to 200), `ref`.

What the reads return (step 5 runs them; `harbr actions ID NAME` shows each one’s inputs and result shape):

**Tracker** `recent` `{limit?}`: `[{id, at, value, label, note?, ref?}]`, newest first. `summary` `{from, to}` (at most 4 days apart): `[{slot, total, count}]`, one per 30 minutes.

**CRM** `board` `{stage?, limit?}`: `{stages: [{stage, count, value}], contacts: [{id, name, company?, email?, stage, value, nextStep?, touchedAt, createdAt, ref?}]}`, contacts most recently touched first (limit up to 200); `createdAt` is when the contact was added. Added today: run `board` with `{"limit":200}`, keep the contacts whose `createdAt` is at or after local midnight, then count them and sum their `value`.

**Dashboard** `metrics` `{}`: `[{name, latest, latestAt, previous?, previousAt?, count}]`, one per metric. `series` `{name, from?, limit?}`: `[{id, value, at, note?, ref?}]`, newest first.

Need a field the starter lacks (a mood on each Tracker entry)? The copy carries its app’s source: `harbr source checkout ID backend --kind backend` writes it to the folder `backend`. Add the field where rows are defined and checked, as an optional field so the copy’s rows stay valid (Tracker: the `entries` table in `convex/schema.ts`; the `add` args, the `entry` shape and what `recent` returns in `convex/entries.ts`; the `add` input in `backend.json`). Deploy it into the copy with `--bind site`, which points the page at the new version, then publish the page (show the field in `site/index.html` too if the user wants to see it). The copy keeps its rows. Send a row with the new field (step 4) and check it with `recent` (step 5).

A longer field (book titles over Tracker’s 40-character `label`): a field’s limit is only your code’s check when a row is written (Tracker: `.slice(0, 40)` in `convex/entries.ts` and `maxLength` in `backend.json`; change both), never a check on rows already stored. Raising it is safe; lowering it leaves longer stored rows as they are, still readable.

Add an operation to a copied starter (a read it lacks, such as this month’s total per label): check out the source as above, write the query next to the others (Tracker: `convex/entries.ts`, with the same `args: {input: v.object({…}), viewer}` as `recent`), and list it in `backend.json`’s `operations`: `{"name":"monthTotals","function":"entries:monthTotals","type":"query","access":"viewer","effects":"read"}`. Run `harbr backend validate backend`, deploy with `--bind site` (a page may call only the operations its `artifact.json` names; `--bind` adds the new one), and publish `site`. In a fresh copy, `site/artifact.json` from `harbr checkout` may list no operations: the published page keeps its binding anyway, and `deploy --bind site` writes the full list into the file. Try it with `harbr run ID monthTotals --args '{"from":…,"to":…}'`, then call it from the page: `Reports.backend.subscribe("monthTotals", {from, to}, render)`.

Totals for the user’s day or month: the backend runs in UTC and does not know where the user’s month starts, so the page passes the period’s start and end (epoch ms from its own clock: `new Date(y, m, 1).getTime()` and `new Date(y, m + 1, 1).getTime()`), and the query reads only that range of the `by_at` index and sums it: `ctx.db.query("entries").withIndex("by_at", q => q.gte("at", input.from).lt("at", input.to)).take(2000)`. A bounded range of one person’s month is cheap: this is the exception that `harbr help backends`’ rule “Counters, not scans” names. `validate` notes `take-too-large` for it; that note is advisory and fine here.

A deploy that warns `indexes N string field(s) (table.field, …)` and 512 bytes means a row whose indexed text is over 512 bytes (UTF-8, up to 4 bytes per character) cannot be written. It is harmless when the code caps those fields shorter, as every starter does (Tracker slices `ref` to 80 characters, at most 320 bytes). A field of your own that you index: cap it the same way before writing.

```sh
harbr copy ka5pzejy --title "Water intake" --no-project
harbr checkout ID site
harbr publish site

# only to add a field or an operation:
harbr source checkout ID backend --kind backend
harbr backend validate backend
harbr backend deploy backend --id ID --request-key $(uuidgen | tr A-Z a-z) --bind site
harbr publish site
harbr source save backend
```

Change the page again any time: edit `site/index.html`, publish. Change the app again the same way: edit `backend`, deploy with a new request key and `--bind site`, publish `site`, then `harbr source save backend` keeps the source for next time. A deploy that fails changes nothing; read its message, fix, deploy again.

## 4. Send rows from a script

Make a key that may only add rows. Its secret goes straight into a private file and is never printed. Then send a JSON Lines file with it: no profile or session needed, and the key works only for this app.

A once-a-day number (Tracker, Dashboard): set `at` to noon of that date in the user’s time zone (Python: `int(datetime(2026, 10, 31, 12).timestamp() * 1000)`) and `ref` to the name and date (`signups-2026-10-31`), so sending a day again updates it. The pages count days in the viewer’s time zone; noon keeps the value on its date.

No real numbers yet? Send a few sample rows from `sample.jsonl`, each with a `ref` starting `sample-` (Tracker and Dashboard: also `"note":"sample"`), and tell the user they are made up. Once real rows arrive, clear them as the user (the key may only add): `grep -o '"ref":"sample-[^"]*"' sample.jsonl | sed 's/.*/{&}/' > clear.jsonl`, then `harbr run ID remove --batch clear.jsonl`. Every starter’s `remove` takes `{ref}`.

```sh
harbr app-keys create ID --name tracker-sender --operations add --expires 90d --save-to env:./tracker.env
printf '%s\n' '{"value":250,"label":"glass"}' '{"value":500,"label":"bottle"}' > rows.jsonl
(set -a; . ./tracker.env; set +a; harbr run ID add --batch rows.jsonl)
```

It prints `landed 2 · refused 0`. CRM sends with `save` (`--operations save`). The copy carries a ready sender for the user’s own program: `harbr read ID --skill send-rows` (CRM: `import-contacts`, Dashboard: `send-metrics`) prints a Python script that uses https://app.harbr.cloud/lib/harbr.py. The key file is named as in that skill: `tracker.env` (CRM: `crm.env`, Dashboard: `dashboard.env`); a copy’s skill keeps those names, so keep the skill’s file name, or rename both (the `--save-to env:` file and the one your script reads). A script run on its own reads the key from that file: `App(ID, key_file="tracker.env")` in harbr.py, `new App(ID, {keyFile: 'tracker.env'})` in harbr.mjs, or `HARBR_APP_KEY_FILE=./tracker.env` for either; only its `HARBR_APP_KEY` line is read, and never printed. Never print or commit it. Stop a sender: `harbr app-keys list ID`, then `harbr app-keys revoke ID KEY_ID`.

## 5. Check it works

Check both before you tell the user it works: the rows are stored, and the page shows them.

```sh
# Tracker
harbr run ID recent --args '{"limit":5}'
# CRM
harbr run ID board --args '{}'
# Dashboard
harbr run ID metrics --args '{}'

harbr preview site --check
```

Run the read for your starter: it lists the stored rows (fields in step 3). `preview --check` opens the page in a headless Chrome or Chromium if this machine has one and exits 0 only when the page showed its data; look for your rows in the text it prints. Its “today” is this machine’s time zone (it prints which); prefix `TZ=Area/City` to check the user’s day. Do not install a browser for this: without one (or if it does not start) the check still covers the page’s binding to the app, each operation it subscribes to, the rows they return and that its script parses, ends “page rendering not checked: no browser”, and exit 0 means you are done. It also names any read the app offers that the page never uses (“Not used by the page: …”: if you added that read for the page, your edit to `site/index.html` is not saved or not published), an operation the page names that its binding lacks (FAILED: deploy with `--bind site`), and a call whose operation name the page computes (“operation name not literal; not checked”). Only use a browser that is already there (macOS has Chrome); never try to install one or its system libraries on Linux. Then give the user the link: https://app.harbr.cloud/r/ID (they open it signed in). A copy of one of the three starters shows its rows at once. A copy of any other account's template shows none of them until its owner turns that on: `harbr copy` says so (`pageData: off`), and only a person can do it, in the browser, never the CLI. Then tell the user plainly: open the link and choose Turn on, once; until then the page reads 0 and Reconnecting, even though `harbr run ID recent` lists the rows.

## 6. Share it

View only. `--email`: that person signs in with that email. `--link`: anyone signed in who has the link. `harbr sharing ID` lists who can see it; `harbr unshare` stops it.

A teammate’s page and agent read the app’s data only through the reads its backend.json marks `"shared": "read"` (the starters’ reads are; writes never can be). Only for a read you added: mark it in the app’s backend source (`harbr source checkout ID FOLDER --kind backend`), `harbr backend deploy FOLDER --id ID`, then share. The teammate’s agent runs them with `harbr run ID recent`; `harbr help backends` has the rule.

```sh
harbr share ID --email sam@example.com
harbr share ID --link
```

Next: run the sender from the user’s own program or a daily job so rows keep arriving; `harbr read ID` lists the app’s other skills.
