文件内容
SKILL.md
---
name: baby-tracker
description: Log, query, import, and chart baby care events as a private CSV-based replacement for baby tracking apps such as Huckleberry. Use when recording or analyzing diaper changes, feeds, sleep, growth/weight/height, temperature, medication, illness notes, or extensible baby measurements; also use when asked for baby charts, weight graphs, percentile lines, summaries, trends, imports, or CSV exports.
---
# Baby Tracker
Use this skill to maintain a private append-only baby log in CSV form and answer natural-language tracking/query/chart requests.
## Storage
Default data directory:
```bash
~/.openclaw/workspace/data/baby-tracker
```
Override it for any command with either:
```bash
export BABY_TRACKER_DIR=/path/to/baby-tracker-data
python3 scripts/baby_tracker.py --data-dir /path/to/baby-tracker-data ...
```
Files:
- `events.csv` — append-only flexible event log.
- `metadata.json` — baby metadata (`name`, `date_of_birth`, `sex`, timezone, extra fields).
- `weight_percentiles_approx.csv` — approximate visual guide percentile data generated by the script.
- `who/who_weight_lms.csv` — optional official WHO LMS/z-score data for precise weight-for-age charts.
- `charts/*.html` and `charts/*.png` — generated chart outputs.
Never delete or rewrite `events.csv` unless explicitly asked. Append corrections as a new `correction` event or ask before destructive cleanup.
## Script
Run commands from this skill directory, or use the absolute path to the installed skill:
```bash
python3 scripts/baby_tracker.py ...
```
The scripts use only Python stdlib.
### Initialize or update metadata
Set these before age-aware charts or percentiles:
```bash
python3 scripts/baby_tracker.py meta --name "Baby" --date-of-birth YYYY-MM-DD --sex female --timezone Europe/London
```
`--field key=value` can store arbitrary metadata such as `birth_weight_kg=3.4`, `height_cm=52`, `notes=...`.
### Log an event
General pattern:
```bash
python3 scripts/baby_tracker.py log \
--type diaper \
--subtype both \
--field pee=large \
--field poo=small \
--notes "optional note" \
--source-text "original message" \
--at "2026-05-03 10:14"
```
Omit `--at` to use current time in the baby's configured timezone. Preserve the original user message in `--source-text` when helpful.
Preferred event shapes:
- Diaper: `--type diaper --subtype wet|dirty|both|dry --field pee=small|medium|large --field poo=small|medium|large|...`
- Weight: `--type growth --subtype weight --metric weight --value 4.53 --unit kg`
- Height/length: `--type growth --subtype height --metric height --value 55 --unit cm`
- Temperature: `--type temperature --metric temperature --value 38.2 --unit C --field method=ear`
- Feed bottle: `--type feed --subtype bottle --metric volume --value 50 --unit ml --field milk=breast|formula`
- Feed breast: `--type feed --subtype breast --field side=left|right|both --field duration_min=20`
- Sleep: `--type sleep --metric duration --value 90 --unit min` plus optional start/end in fields.
- Medication: `--type medication --subtype calpol --metric dose --value 2.5 --unit ml`.
- Anything new: choose a clear `--type`, optional `--subtype`, and structured `--field key=value` details. The schema is intentionally extensible.
If a message is ambiguous but low risk, log the raw information with `notes`/`source_text` rather than blocking. Ask only when the missing detail changes the meaning materially, such as unknown units or ambiguous baby identity in a multi-baby setup.
### Query
Examples:
```bash
python3 scripts/baby_tracker.py query --type diaper --since today
python3 scripts/baby_tracker.py query --metric weight --format json
python3 scripts/baby_tracker.py query --since 7d --format summary
```
Use summaries for chat replies. Use JSON/CSV when doing analysis.
### Chart
For quick generic charts, generate a self-contained HTML/SVG chart:
```bash
python3 scripts/baby_tracker.py chart --metric weight
```
For WHO weight-for-age percentile claims, prefer the official WHO LMS PNG renderer:
```bash
python3 scripts/render_weight_png.py
```
It expects official WHO weight-for-age LMS/z-score data at:
```bash
$BABY_TRACKER_DIR/who/who_weight_lms.csv
# or, by default:
~/.openclaw/workspace/data/baby-tracker/who/who_weight_lms.csv
```
If the WHO LMS CSV needs rebuilding from downloaded WHO Excel files, place those files in the `who/` data directory and run:
```bash
python3 scripts/build_who_weight_lms.py
```
To send a chart image in chat, run the PNG renderer and attach the generated `charts/weight-latest.png` or the path printed by the script.
## Natural-language handling
When a terse baby log message arrives:
1. Interpret the event type and details.
2. Append it immediately with the script.
3. Reply briefly with what was logged and the timestamp.
Examples:
- “nappy both pee large poo small” → log diaper/both with fields.
- “weight 4.53kg” → log growth/weight.
- “temp 38.2 ear” → log temperature with method.
- “50ml bottle breast milk at 10:20” → log feed/bottle volume.
For queries, run `query`, inspect the result, and answer naturally. For chart requests, run the appropriate chart command and return the output file when requested.
## Huckleberry CSV imports
When given a Huckleberry CSV, import it conservatively with the idempotent importer:
```bash
python3 scripts/import_huckleberry.py /path/to/Huckleberry.csv
```
Use `--dry-run` first for unusual files. The importer:
- Maps `Type=Growth` with `Start Condition` like `4.53kg` to `growth/weight`.
- Maps `Type=Diaper` and notes like `Both, pee:large poo:small` to diaper events.
- Maps `Type=Feed` rows to breast/bottle feed events, preserving duration, side, location, milk, and volume fields where possible.
- Maps `Sleep`, `Pump`, and custom activity rows to extensible event types.
- Keeps original row text in `source_text` and structured Huckleberry columns in `details_json` for auditability.
- Uses deterministic import event IDs, so rerunning the same CSV skips already-imported rows.
- Does not overwrite existing manually logged events unless asked for deduplication.