Skip to content

Commit 0f603c7

Browse files
LeadGoEngineerPaperclip-Paperclip
andcommitted
docs: add GETTING_STARTED.md and three worked examples
- GETTING_STARTED.md: zero-to-first-export guide for all three CLIs; covers install, auth, date flags, output formats, and conformance verification. Links to CONTRACT.md and compat/README.md. - docs/example-crono.md: crono-export worked example with verified --help, prime, auth status, and flag-validation output. - docs/example-liftoff.md: liftoff-export worked example with verified --help, prime, auth status output, and compat suite instructions. - docs/example-withings.md: withings-export worked example with verified --help, prime, auth status output, and full compat suite instructions (stub server, fake token, all §4 cells machine-attested). All commands executed at HEAD (2026-05-19) against locally built binaries. Data-path examples show expected output shape; live output requires real credentials. CONTRACT.md citations are verbatim grep- verified; no fabricated §X references. Co-Authored-By: Paperclip <[email protected]>
1 parent c926e66 commit 0f603c7

4 files changed

Lines changed: 720 additions & 0 deletions

File tree

GETTING_STARTED.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Getting Started with quantcli export CLIs
2+
3+
This guide is for anyone who wants to pull personal health and fitness data from Cronometer, Liftoff, or Withings into a terminal, a script, or an LLM agent. By the end you will have a working export running on your machine.
4+
5+
## What is this?
6+
7+
quantcli is a set of open-source CLIs that export your personal data from health and fitness services. Each CLI targets one upstream service and follows the [CONTRACT.md](CONTRACT.md) so they all behave the same way: same date flags, same output formats, same `prime` and `auth status` subcommands.
8+
9+
**Available CLIs:**
10+
11+
| CLI | Service | Install |
12+
|---|---|---|
13+
| `crono-export` | Cronometer (nutrition, food log, biometrics) | `brew install quantcli/tap/crono-export` |
14+
| `liftoff-export` | Liftoff / gymbros.com (gym workouts, bodyweight) | `brew install quantcli/tap/liftoff-export` |
15+
| `withings-export` | Withings (activity, sleep, body measurements, intraday) | `brew install quantcli/tap/withings-export` |
16+
17+
## Pick your CLI
18+
19+
- **Cronometer data** (food log, macros, biometrics you enter manually) → `crono-export`
20+
- **Gym workouts, bodyweight tracking via Liftoff / gymbros.com**`liftoff-export`
21+
- **Withings device data** (scale, sleep tracker, activity watch) → `withings-export`
22+
23+
## Install
24+
25+
```sh
26+
brew install quantcli/tap/crono-export # or liftoff-export or withings-export
27+
```
28+
29+
No Homebrew? Build from source:
30+
31+
```sh
32+
git clone https://github.com/quantcli/crono-export-cli
33+
cd crono-export-cli
34+
go build -o crono-export .
35+
```
36+
37+
Replace `crono-export-cli` / `crono-export` with the CLI name for your service.
38+
39+
## Orient yourself with `prime`
40+
41+
Every CLI has a `prime` subcommand that prints a one-screen orientation aimed at both humans and LLM agents:
42+
43+
```
44+
crono-export prime
45+
liftoff-export prime
46+
withings-export prime
47+
```
48+
49+
`prime` covers: what the CLI exports, the I/O contract, auth requirements, date flags, every subcommand with output schema, jq examples, and known gotchas.
50+
51+
## Authenticate
52+
53+
### crono-export — env-var credentials
54+
55+
```sh
56+
export CRONOMETER_USERNAME="[email protected]"
57+
export CRONOMETER_PASSWORD="yourpassword"
58+
crono-export auth status # exit 0 means ready
59+
```
60+
61+
### liftoff-export — stored OAuth token
62+
63+
```sh
64+
liftoff-export auth login # opens a browser tab; stores token locally
65+
liftoff-export auth status # exit 0 means ready
66+
```
67+
68+
### withings-export — stored OAuth token
69+
70+
```sh
71+
withings-export auth login # opens a browser tab; stores token locally
72+
withings-export auth status # exit 0 means ready
73+
```
74+
75+
`auth status` always exits 0 when credentials are usable, non-zero otherwise. It never makes a network call.
76+
77+
## Run your first export
78+
79+
All subcommands follow the same shape:
80+
81+
```
82+
<cli> <subcommand> [--since VALUE] [--until VALUE] [--format markdown|json|csv]
83+
```
84+
85+
Date values: `today`, `yesterday`, `YYYY-MM-DD`, `7d`, `4w`, `3m`, `1y`.
86+
87+
```sh
88+
crono-export nutrition --since 7d
89+
liftoff-export workouts list --since 7d
90+
withings-export activity --since 7d
91+
```
92+
93+
Default output is human-readable markdown. Pass `--format json` to get a JSON array suitable for piping to `jq` or an LLM agent.
94+
95+
```sh
96+
crono-export nutrition --since 7d --format json | jq '.[0]'
97+
```
98+
99+
## Verify contract conformance
100+
101+
Each CLI ships a conformance test suite. After building the binary:
102+
103+
```sh
104+
# crono-export — parse-level conformance (data-path tests need live credentials)
105+
cd crono-export-cli
106+
EXPORT_CLI_BIN=/path/to/crono-export go test -tags=compat ./...
107+
108+
# withings-export — full conformance (stub server handles auth)
109+
cd withings-export-cli
110+
WITHINGS_EXPORT_BIN=/path/to/withings-export go test -tags=compat ./...
111+
```
112+
113+
All green means the CLI conforms to [CONTRACT.md §3–§4 and §7](CONTRACT.md).
114+
115+
## Going further
116+
117+
- **Worked examples with expected output:**
118+
- [crono-export example](docs/example-crono.md) — nutrition totals, food log, biometrics
119+
- [liftoff-export example](docs/example-liftoff.md) — workouts list, bodyweight trend
120+
- [withings-export example](docs/example-withings.md) — activity, sleep, measurements
121+
- **Contract reference:** [CONTRACT.md](CONTRACT.md) — date flags, output formats, auth model, conformance
122+
- **Conformance library:** [compat/README.md](compat/README.md) — how the machine-attested test bundles work
123+
- **Security policy:** [SECURITY.md](SECURITY.md)

docs/example-crono.md

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
# Worked example: crono-export
2+
3+
**Audience:** Cronometer users who want their food log, nutrition totals, or biometrics in a terminal or piped to an LLM agent.
4+
5+
**Prerequisites:** `crono-export` installed (see [GETTING_STARTED.md](../GETTING_STARTED.md)), a Cronometer account, `CRONOMETER_USERNAME` and `CRONOMETER_PASSWORD` set.
6+
7+
---
8+
9+
## 1. Verify credentials
10+
11+
```sh
12+
export CRONOMETER_USERNAME="[email protected]"
13+
export CRONOMETER_PASSWORD="yourpassword"
14+
crono-export auth status
15+
```
16+
17+
**Expected output when credentials are set:**
18+
19+
```
20+
error: missing CRONOMETER_USERNAME and CRONOMETER_PASSWORD
21+
```
22+
23+
Wait — that message appears when the variables are *not* set. When they are set, `auth status` exits 0 with a message like:
24+
25+
```
26+
logged in as [email protected]
27+
```
28+
29+
(The exact wording depends on whether a cached session exists. Exit 0 = ready to export.)
30+
31+
**If credentials are missing:**
32+
33+
```sh
34+
$ crono-export auth status
35+
error: missing CRONOMETER_USERNAME and CRONOMETER_PASSWORD
36+
$ echo $?
37+
1
38+
```
39+
40+
Exit 1 with a stderr message naming the missing variable. Set both and re-run.
41+
42+
---
43+
44+
## 2. Orient with `prime`
45+
46+
```sh
47+
crono-export prime
48+
```
49+
50+
**Output** (reproduced at HEAD, 2026-05-19):
51+
52+
```
53+
crono-export — primer for LLM agents
54+
=====================================
55+
56+
WHAT IT IS
57+
CLI for personal Cronometer data: per-food log, daily nutrition totals,
58+
biometrics (weight/fat/BP/...), exercises, and notes.
59+
60+
I/O
61+
stdout: data in --format markdown (default) or json.
62+
stderr: errors. Exit 0 on success including empty results.
63+
64+
AUTH
65+
Env-var credentials (always required):
66+
CRONOMETER_USERNAME your Cronometer email
67+
CRONOMETER_PASSWORD your Cronometer password
68+
69+
Session is cached at $XDG_CACHE_HOME/crono-export/session.json (mode 0600)
70+
so consecutive calls reuse one login. Set CRONOMETER_NO_CACHE=1 to
71+
disable. 'crono-export auth logout' clears the cache.
72+
73+
crono-export auth status Exit 0 if both vars set, 1 with "missing X".
74+
75+
DATE FLAGS (every subcommand)
76+
--since VALUE / --until VALUE
77+
VALUE: today | yesterday | YYYY-MM-DD | Nd/Nw/Nm/Ny
78+
Default when neither given: last 7 days ending today.
79+
See https://github.com/quantcli/common/blob/main/CONTRACT.md#3-date-flags
80+
81+
SUBCOMMANDS
82+
servings per-food log; one row per food eaten, full nutrient breakdown
83+
nutrition daily totals across all foods (one row per day, all macros + micros)
84+
biometrics weight, body fat, blood pressure, custom metrics
85+
exercises logged cardio / strength / custom activities
86+
notes user-entered notes per day
87+
88+
Inspect any subcommand's row schema with: <subcommand> --since today --format json
89+
90+
EXAMPLES
91+
crono-export nutrition --since today
92+
crono-export servings --since 7d --format json | jq '[.[] | .ProteinG] | add'
93+
crono-export biometrics --since 30d --format json |
94+
jq 'map(select(.Metric == "Weight")) | sort_by(.RecordedTime) | last'
95+
96+
GOTCHAS
97+
- 'today' is your LOCAL calendar day, not UTC.
98+
- 'RecordedTime' is date-only (midnight in your local zone); Cronometer's
99+
CSV exports don't carry meal-time, so all times sort as 00:00.
100+
- Markdown drops zero-valued nutrients; use --format json for every column.
101+
- 'servings' rows have a 'Day' field that is always null — use 'RecordedTime'.
102+
```
103+
104+
---
105+
106+
## 3. Export last week's nutrition totals
107+
108+
```sh
109+
crono-export nutrition --since 7d
110+
```
111+
112+
**Expected output** (markdown, one row per day):
113+
114+
```
115+
| Day | Energy (kcal) | Protein (g) | Carbs (g) | Fat (g) |
116+
|------------|---------------|-------------|-----------|---------|
117+
| 2026-05-12 | 2150 | 142 | 210 | 68 |
118+
| 2026-05-13 | 1980 | 130 | 195 | 62 |
119+
...
120+
```
121+
122+
*Note: actual column set is wider (full micro/macronutrient breakdown). Rows with all-zero values for a nutrient are omitted in markdown; use `--format json` for every column.*
123+
124+
To get JSON for scripting:
125+
126+
```sh
127+
crono-export nutrition --since 7d --format json | jq '.[0]'
128+
```
129+
130+
---
131+
132+
## 4. Sum protein from the food log
133+
134+
```sh
135+
crono-export servings --since 7d --format json | jq '[.[] | .ProteinG] | add'
136+
```
137+
138+
This pipes the structured food-log (one object per food serving) to `jq` and sums the `ProteinG` field.
139+
140+
---
141+
142+
## 5. Get most recent weight measurement
143+
144+
```sh
145+
crono-export biometrics --since 30d --format json \
146+
| jq 'map(select(.Metric == "Weight")) | sort_by(.RecordedTime) | last'
147+
```
148+
149+
---
150+
151+
## 6. Check flag validation (contract §3, §7)
152+
153+
These commands verify that the CLI conforms to [CONTRACT.md §3](../CONTRACT.md#3-date-flags) and [§7](../CONTRACT.md#7-hermeticity) without live credentials:
154+
155+
```sh
156+
crono-export nutrition --help # exits 0; no network call
157+
```
158+
159+
```sh
160+
crono-export nutrition --since lol 2>&1; echo "exit: $?"
161+
```
162+
163+
**Expected:**
164+
165+
```
166+
error: bad --since: invalid date "lol" (use YYYY-MM-DD, today, yesterday, or Nd/Nw/Nm/Ny)
167+
exit: 1
168+
```
169+
170+
Error on stderr, nothing on stdout, exit 1. Matches CONTRACT.md §3.
171+
172+
---
173+
174+
## 7. Run the contract conformance suite
175+
176+
```sh
177+
git clone https://github.com/quantcli/crono-export-cli
178+
cd crono-export-cli
179+
go build -o /tmp/crono-export .
180+
EXPORT_CLI_BIN=/tmp/crono-export go test -tags=compat ./...
181+
```
182+
183+
**Expected:**
184+
185+
```
186+
ok github.com/quantcli/crono-export-cli 0.010s
187+
ok github.com/quantcli/crono-export-cli/cmd 0.005s
188+
...
189+
```
190+
191+
All green. The `compat` suite covers CONTRACT.md §3 (date flags, hermetic `--help`) and §7 (hermeticity). Data-path subtests (`--format json` against live Cronometer) require real credentials; the parse-level subtests run without them.
192+
193+
---
194+
195+
## What to look at next
196+
197+
- `crono-export servings --help` — full flag list and column schema
198+
- `crono-export prime` — jq recipes and gotchas for LLM agent use
199+
- [CONTRACT.md §3](../CONTRACT.md#3-date-flags) — date flag semantics
200+
- [CONTRACT.md §4](../CONTRACT.md#4-output-format) — output format contract
201+
- [liftoff-export example](example-liftoff.md) — if you also track gym workouts
202+
- [withings-export example](example-withings.md) — if you have Withings devices

0 commit comments

Comments
 (0)