Backfill journal body context

From mycelium-hq/ai-brain-starter · View interactive version

Backfill journal body context is an AI agent skill from the GitHub repository mycelium-hq/ai-brain-starter. Use when the user says /backfill-journal-body-context, wants existing daily journal entries enriched with body data retroactively (HRV, sleep, recovery, cycle phase, labs), says 'backfill my journals with health', wants Apple Health / Oura / Fitbit / Whoop history paired with past journals, or just

How to use this skill

Skill file

backfill-journal-body-context

Reads existing daily journals, pulls health-mcp data for each entry's date, and appends a "Body track" section BELOW the original verbatim content. The original entry text is NEVER modified — the rule from feedback_journal_verbatim_words.md is non-negotiable.

When to use

Do NOT use for:

How it works

  1. Determine the date range. Default: --year <current-year> (Jan 1 to today).
  2. Find journal entries in that range using [VAULT_PATH]/⚙️ Meta/journal-index.json (or Meta/journal-index.json on non-emoji vaults; rebuild if stale).
  3. For each entry:
  1. Print summary: N entries processed, M backfilled, K skipped.

Body track template

Append below the original journal content, after a blank line + horizontal rule:


---

## Body track (health-mcp, backfilled {{today_iso}})

*Auto-generated context. Original journal entry above is preserved verbatim.*

**Floor that day:** {{floor_name}} ({{floor_level}})

**Cycle phase** (if cycle data exists): {{phase}}, cycle day {{cycle_day}}{{ — irregularity flag if any}}

**The body that day:**
- HRV: {{hrv_ms}} ms ({{hrv_delta_pct}}% vs 30-day baseline)
- RHR: {{rhr_bpm}} bpm
- Sleep: {{sleep_asleep_min}} min ({{sleep_efficiency}}% efficiency, REM {{rem_min}}min, deep {{deep_min}}min)
- Steps: {{steps_total}}
- Workouts: {{workout_count}} ({{workout_min}}min)
- Mindful: {{mindful_min}}min

**Scores:**
- Recovery: {{recovery_score}}/100 ({{confidence}} confidence)
- Sleep: {{sleep_score}}/100

**Floor-paired interpretation** (1-3 sentences, see synthesis rule below): {{interpretation}}

**Lab markers** (if any out-of-range result from the prior 180 days, paired with today): {{lab_flags}}

Synthesis rule (the helpful-not-just-cool part)

The interpretation line must follow the same shape as the /weekly section 0d synthesis. Each line:

Examples (template SHAPES, not for verbatim use):

Floor was Fear and HRV ran 22% below baseline on a luteal day. The body and the mind both registered the threat. Without the journal entry the recovery score would have called this "rest more"; pairing with Fear shows the actual signal was "the worry is doing work the rest can't fix."

Floor was Joy after a strong gym week. HRV at baseline, sleep efficiency 94%. This is the high-water mark — note what conditions produced it.

Floor was Apathy and Vitamin D 25-OH came back at 26 ng/mL (below range) the month before. The mood floor may have had a metabolic floor under it. Worth a re-test after 3 months of supplementation.

Banned shapes (from /weekly section 0d, same rules apply):

Model routing

The interpretation line is grunt-work prose. Use the cheapest model that produces a helpful sentence. Order of preference:

  1. Python template (zero cost) — for high-confidence cases (HRV in normal range during follicular, no out-of-range labs, no anniversary signal). The script scripts/backfill-journal-body-context.py covers this.
  2. MiniMax (~$0.06/M tokens, very cheap) — for cases where the data shows a real pattern that deserves a synthesized sentence. Invoke via "⚙️ Meta/scripts/minimax.sh" if the vault has it, otherwise skip the LLM step and use a fallback template.
  3. Haiku (cheap, fast, reliable) — for cases where MiniMax is unavailable.
  4. Sonnet — only if explicit --high-quality flag passed and the user accepts the cost.

The default is Python template + MiniMax fallback. Do NOT default to Sonnet for hundreds of journal entries.

Invocation

The actual work runs in scripts/backfill-journal-body-context.py. The skill assembles arguments and hands off to the script.

When invoked:

  1. Parse arguments:
  1. Sanity checks:
  1. Run the script:

```

/usr/bin/python3 "[REPO_ROOT]/scripts/backfill-journal-body-context.py" --year 2026 --vault-root "$VAULT_ROOT"

```

  1. Surface the summary: N entries processed, M backfilled, K skipped, plus the date range covered.

Output

The skill does NOT write to the vault itself — the Python script does the file mutations. The skill only:

Idempotency

The Python script checks each journal file for an existing ## Body track (health-mcp, backfilled line. If present, skip unless --force. Re-running the skill on the same range is safe.

Ongoing daily run

After the initial backfill, the same script runs daily for yesterday's entry via a scheduled task (use the /schedule skill). Suggested cadence: 7am local, after Apple Watch has uploaded the previous night's sleep data.

Scheduled-task body:

/usr/bin/python3 "[REPO_ROOT]/scripts/backfill-journal-body-context.py" --start "$(date -v-1d +%F)" --end "$(date -v-1d +%F)" --vault-root "$VAULT_ROOT"

That's "backfill yesterday, every morning, forever." Set it up after the initial backfill completes successfully.

Voice rules

Privacy

The script reads journal files + the local DuckDB. It writes only to journal files (appending body-track sections). No data leaves the machine. The interpretation step (if LLM-backed) sends ONLY the structured body data + floor tag to the chosen model — never the journal body content.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.