agentleFS
somz22somz22/personal-health-fitbit/.agents/skills/health-logging/SKILL.md

health-logging

Skill2 starsChanged 8 months agoMITView on GitHub

Log medications, daily health entries, weight, and lab reports — includes AI-powered lab report parsing where the agent reads a PDF/image and stores all values automatically

  • Reads credentials
  • Sends data out

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. Presidio-Federal/ai-studio-netops★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 8 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Key capability: When a user shares a lab report (image or PDF), you read it directly using your multimodal capabilities, extract all …

    line 10
  2. Distinctive:

    Use consistent symptom names for better analysis:

    line 163
  3. Distinctive:

    When the user says "I have a lab report" or "upload my blood test", ask them to:

    line 233
  4. Very specific:

    If the report already shows H/L/Normal flags, use those

    line 307
  5. Distinctive:

    Before storing, show a table summary:

    line 317
  6. Distinctive:

    Important: When batch inserting, ALL objects must have identical keys (include null for missing fields).

    line 386
  7. Distinctive:

    Use these consistent parameter names for cross-report tracking:

    line 406
  8. Distinctive:

    After inserting a lab report, always offer to analyse it:

    line 508
  9. Very specific:

    Use the /health-analysis skill to run the correlation analysis.

    line 521
  10. Distinctive:

    After inserting data via Supabase, pull it to your local DuckDB for analysis:

    line 525

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Health Logging Skill

This skill handles all manual data input: medication doses, daily health entries (mood, energy, symptoms), lab reports, and weight.

Key capability: When a user shares a lab report (image or PDF), you read it directly using your multimodal capabilities, extract all biomarker values, map them to standard parameter names, and store them in Supabase. No external OCR or parsing tool needed.

Data is stored in Supabase (source of truth) and synced to local DuckDB.

Prerequisites

  • Supabase credentials configured in .env (SUPABASE_URL, SUPABASE_SERVICE_KEY)
  • Patient UUID known (query from patients table or check HEALTH_CONTEXT.md)

Get Patient ID

curl -s "$SUPABASE_URL/rest/v1/patients?select=id,name&limit=1" \
  -H "apikey: $SUPABASE_SERVICE_KEY" -H "Authorization: Bearer $SUPABASE_SERVICE_KEY"

Or from DuckDB:

SELECT id, name FROM patients LIMIT 1

Store this UUID — it is needed for all insert operations below.

Log a Medication Dose

Record That a Medication Was Taken

curl -s -X POST "$SUPABASE_URL/rest/v1/medication_logs" \
  -H "apikey: $SUPABASE_SERVICE_KEY" -H "Authorization: Bearer $SUPABASE_SERVICE_KEY" \
  -H "Content-Type: application/json" -H "Prefer: return=representation" \
  -d '{
    "patient_id": "PATIENT_UUID",
    "medication_id": MEDICATION_ID,
    "date": "2026-03-20",
    "taken": true,
    "taken_at": "2026-03-20T08:30:00+05:30",
    "notes": "Taken with breakfast"
  }'

Record a Missed Dose

curl -s -X POST "$SUPABASE_URL/rest/v1/medication_logs" \
  -H "apikey: $SUPABASE_SERVICE_KEY" -H "Authorization: Bearer $SUPABASE_SERVICE_KEY" \
  -H "Content-Type: application/json" -H "Prefer: return=representation" \
  -d '{
    "patient_id": "PATIENT_UUID",
    "medication_id": MEDICATION_ID,
    "date": "2026-03-20",
    "taken": false,
    "notes": "Forgot — was travelling"
  }'

Fields Reference

FieldTypeRequiredNotes
patient_idUUIDYesFrom patients table
medication_idINTEGERYesFK to medications table
dateDATEYesFormat: YYYY-MM-DD
takenBOOLEANYestrue = taken, false = missed
taken_atTIMESTAMPTZNoExact time taken (include timezone)
notesTEXTNoAny relevant context

Manage Medications

List Active Medications

curl -s "$SUPABASE_URL/rest/v1/medications?patient_id=eq.PATIENT_UUID&active=eq.true&select=id,name,dosage,frequency&order=name" \
  -H "apikey: $SUPABASE_SERVICE_KEY" -H "Authorization: Bearer $SUPABASE_SERVICE_KEY"

Or from DuckDB:

SELECT id, name, dosage, frequency FROM medications WHERE active = true ORDER BY name

Add a New Medication

curl -s -X POST "$SUPABASE_URL/rest/v1/medications" \
  -H "apikey: $SUPABASE_SERVICE_KEY" -H "Authorization: Bearer $SUPABASE_SERVICE_KEY" \
  -H "Content-Type: application/json" -H "Prefer: return=representation" \
  -d '{
    "patient_id": "PATIENT_UUID",
    "name": "Pantoprazole",
    "dosage": "40mg",
    "frequency": "once daily before breakfast",
    "active": true
  }'

Deactivate a Medication (Stopped Taking)

curl -s -X PATCH "$SUPABASE_URL/rest/v1/medications?id=eq.MEDICATION_ID" \
  -H "apikey: $SUPABASE_SERVICE_KEY" -H "Authorization: Bearer $SUPABASE_SERVICE_KEY" \
  -H "Content-Type: application/json" -H "Prefer: return=representation" \
  -d '{"active": false}'

Update Medication Details

curl -s -X PATCH "$SUPABASE_URL/rest/v1/medications?id=eq.MEDICATION_ID" \
  -H "apikey: $SUPABASE_SERVICE_KEY" -H "Authorization: Bearer $SUPABASE_SERVICE_KEY" \
  -H "Content-Type: application/json" -H "Prefer: return=representation" \
  -d '{"dosage": "20mg", "frequency": "twice daily"}'

Log Daily Health Entry

Record Mood, Energy, Stress, Exercise, and Symptoms

curl -s -X POST "$SUPABASE_URL/rest/v1/daily_logs" \
  -H "apikey: $SUPABASE_SERVICE_KEY" -H "Authorization: Bearer $SUPABASE_SERVICE_KEY" \
  -H "Content-Type: application/json" -H "Prefer: return=representation" \
  -d '{
    "patient_id": "PATIENT_UUID",
    "date": "2026-03-20",
    "mood": 7,
    "energy": 6,
    "stress": 4,
    "exercise_done": true,
    "exercise_type": "running",
    "exercise_minutes": 30,
    "symptoms": ["bloating", "mild_headache"],
    "notes": "Felt good after run. Bloating started after lunch."
  }'

Fields Reference

FieldTypeRequiredNotes
patient_idUUIDYesFrom patients table
dateDATEYesFormat: YYYY-MM-DD
moodINTEGERNoScale 1-10 (1=terrible, 10=excellent)
energyINTEGERNoScale 1-10
stressINTEGERNoScale 1-10 (1=none, 10=extreme)
exercise_doneBOOLEANNoDid structured exercise today?
exercise_typeTEXTNoe.g., "running", "weights", "yoga", "walking"
exercise_minutesINTEGERNoDuration of exercise
symptomsJSON (array)NoList of symptoms as strings
notesTEXTNoFree-form notes about the day

Common Symptom Tags

Use consistent symptom names for better analysis:

  • bloating, nausea, acid_reflux, stomach_pain
  • headache, mild_headache, migraine
  • fatigue, brain_fog, poor_focus
  • anxiety, restlessness, insomnia
  • muscle_soreness, joint_pain, back_pain
  • palpitations, chest_tightness

Check Medication Compliance

Compliance for a Specific Date

curl -s "$SUPABASE_URL/rest/v1/medication_logs?patient_id=eq.PATIENT_UUID&date=eq.2026-03-20&select=*,medications(name,dosage)" \
  -H "apikey: $SUPABASE_SERVICE_KEY" -H "Authorization: Bearer $SUPABASE_SERVICE_KEY"

Compliance Over Past 7 Days

SELECT ml.date,
       m.name,
       m.dosage,
       ml.taken,
       ml.taken_at,
       ml.notes
FROM medication_logs ml
JOIN medications m ON ml.medication_id = m.id
WHERE ml.date >= current_date - 7
ORDER BY ml.date DESC, m.name

Find Days With Missing Logs

WITH active_meds AS (
    SELECT id, name FROM medications WHERE active = true
),
date_range AS (
    SELECT generate_series(
        current_date - 7,
        current_date,
        INTERVAL '1 day'
    )::DATE as date
),
expected AS (
    SELECT d.date, m.id as medication_id, m.name
    FROM date_range d CROSS JOIN active_meds m
),
logged AS (
    SELECT date, medication_id FROM medication_logs
)
SELECT e.date, e.name as medication, 'NOT LOGGED' as status
FROM expected e
LEFT JOIN logged l ON e.date = l.date AND e.medication_id = l.medication_id
WHERE l.date IS NULL
ORDER BY e.date DESC, e.name

Add Lab Results

Overview

You (the AI agent) can read lab reports directly. The user shares a PDF or image — you extract all values and store them in Supabase. No external OCR tool needed.

Workflow: Parse a Lab Report

Step 0: User shares the report

When the user says "I have a lab report" or "upload my blood test", ask them to:

Share the lab report as an image (screenshot or photo) or a PDF file. I'll read it and store all the values automatically.

Step 1: Read and extract

Examine the image/PDF carefully. Extract every row in the results table:

What to extractWhere to find it
Report dateHeader of the report
Lab nameHeader (e.g., "Thyrocare", "SRL", "Metropolis")
Test package nameHeader (e.g., "Aarogyam 1.8", "CBC", "Lipid Profile")
Each biomarker nameFirst column
Each valueResult column (numeric)
UnitUnit column
Reference rangeNormal range column
StatusHigh/Low/Normal flag, OR compare value to reference range yourself

Step 2: Map to standard parameter names

Convert lab report parameter names to the standard names below before storing. This enables cross-report tracking over time.

Lab report saysStore as
Vitamin D3 (25-OH), 25-OH Vitamin Dvitamin_d
Vitamin B12, Cyanocobalaminvitamin_b12
SGOT / ASTsgot_ast
SGPT / ALTsgpt_alt
Gamma GT, GGTggt
Alkaline Phosphatase, ALPalkaline_phosphatase
Total Cholesteroltotal_cholesterol
LDL Cholesterol, LDL-Cldl
HDL Cholesterol, HDL-Chdl
Triglyceridestriglycerides
VLDLvldl
Lipoprotein(a), Lp(a)lipoprotein_a
HbA1c, Glycated Haemoglobinhba1c
Fasting Blood Glucose, FBSfasting_glucose
Serum Creatininecreatinine
eGFRegfr
Uric Aciduric_acid
TSHtsh
Free T3, fT3free_t3
Free T4, fT4free_t4
Haemoglobin, Hbhemoglobin
WBC, Total Leucocyte Count, TLCwbc
RBCrbc
Platelets, Platelet Countplatelets
MCVmcv
MCHmch
MCHCmchc
RDW-CVrdw_cv
hs-CRP, High Sensitivity CRPhs_crp
Homocysteinehomocysteine
Ferritinferritin
Serum Iron, Ironiron
UIBCuibc
Total Iron Binding Capacity, TIBCtibc
Folate, Folic Acid, Vitamin B9vitamin_b9_folate
Total Bilirubinbilirubin_total
Direct Bilirubinbilirubin_direct
Albuminalbumin
Total Proteintotal_protein
ESResr
BUN, Blood Urea Nitrogenbun
Apolipoprotein B, Apo Bapo_b

For any parameter not in this table, use snake_case of the exact lab name (e.g., "Calcium" → calcium, "Sodium" → sodium).

Step 3: Determine status

  • If the report already shows H/L/Normal flags, use those
  • Otherwise compare value_numeric to ref_range yourself:
    • Below range minimum → "low"
    • Above range maximum → "high"
    • Within range → "normal"
    • Significantly above critical threshold → "critical_high"
    • Significantly below critical threshold → "critical_low"

Step 4: Show the user a preview before inserting

Before storing, show a table summary:

Extracted from: [Lab Name] — [Test Name] — [Date]

Parameter          | Value  | Unit  | Range    | Status
vitamin_d          | 28.5   | ng/mL | 30-100   | LOW
sgpt_alt           | 42     | U/L   | 0-40     | HIGH
total_cholesterol  | 185    | mg/dL | <200     | NORMAL
...

Store all X values? (y/n)

Step 5: Insert into Supabase

Step 1: Create a Lab Report Entry

curl -s -X POST "$SUPABASE_URL/rest/v1/lab_reports" \
  -H "apikey: $SUPABASE_SERVICE_KEY" -H "Authorization: Bearer $SUPABASE_SERVICE_KEY" \
  -H "Content-Type: application/json" -H "Prefer: return=representation" \
  -d '{
    "patient_id": "PATIENT_UUID",
    "report_date": "2026-03-15",
    "lab": "Thyrocare",
    "test_name": "Aarogyam 1.8",
    "source_file": "lab-reports/2026-03-15_thyrocare_aarogyam.pdf"
  }'

Save the returned id — you need it as report_id for individual results.

Step 2: Insert Lab Results

curl -s -X POST "$SUPABASE_URL/rest/v1/lab_results" \
  -H "apikey: $SUPABASE_SERVICE_KEY" -H "Authorization: Bearer $SUPABASE_SERVICE_KEY" \
  -H "Content-Type: application/json" -H "Prefer: return=representation" \
  -d '[
    {
      "report_id": REPORT_ID,
      "category": "vitamin",
      "parameter": "vitamin_d",
      "value_numeric": 28.5,
      "value_text": null,
      "unit": "ng/mL",
      "ref_range": "30-100",
      "status": "low",
      "interpretation": "Below optimal range",
      "method": null,
      "metadata": null
    },
    {
      "report_id": REPORT_ID,
      "category": "liver",
      "parameter": "sgpt_alt",
      "value_numeric": 42,
      "value_text": null,
      "unit": "U/L",
      "ref_range": "0-40",
      "status": "high",
      "interpretation": "Mildly elevated",
      "method": null,
      "metadata": null
    }
  ]'

Important: When batch inserting, ALL objects must have identical keys (include null for missing fields). Supabase PostgREST requires this.

Lab Result Fields Reference

FieldTypeRequiredNotes
report_idUUIDYesFK to lab_reports
categoryTEXTYese.g., "vitamin", "liver", "lipid", "thyroid", "cbc", "metabolic", "cardiac"
parameterTEXTYesUse consistent names (see below)
value_numericNUMERICConditionalNumeric result — use this for numbers
value_textTEXTConditionalText result — use for non-numeric values like "Reactive"
unitTEXTNoe.g., "ng/mL", "U/L", "mg/dL"
ref_rangeTEXTNoe.g., "30-100", "<40"
statusTEXTYes"normal", "low", "high", "critical_low", "critical_high"
interpretationTEXTNoBrief interpretation
methodTEXTNoLab method used
metadataJSONNoAny additional data

Standard Parameter Names

Use these consistent parameter names for cross-report tracking:

CategoryParameters
Vitaminsvitamin_b12, vitamin_d, vitamin_b9_folate, iron, ferritin
Liversgot_ast, sgpt_alt, ggt, alkaline_phosphatase, bilirubin_total, bilirubin_direct, albumin, total_protein
Lipidstotal_cholesterol, ldl, hdl, triglycerides, vldl, lipoprotein_a, apo_b
Thyroidtsh, t3, t4, free_t3, free_t4
CBChemoglobin, wbc, rbc, platelets, mcv, mch, mchc, rdw_cv, rdw_sd
Metabolichba1c, fasting_glucose, uric_acid, creatinine, bun, egfr
Cardiachs_crp, homocysteine, nt_pro_bnp, troponin
Inflammationesr, hs_crp

Upload Lab Report PDF to Storage (Optional)

Requires a health-reports bucket in Supabase Storage. Create it in the Supabase dashboard (Storage → New bucket → name: health-reports, private). This is optional — the core lab report workflow extracts values directly from images/PDFs without storage.

# Upload to Supabase Storage
curl -s -X POST "$SUPABASE_URL/storage/v1/object/health-reports/lab-reports/2026-03-15_thyrocare_aarogyam.pdf" \
  -H "apikey: $SUPABASE_SERVICE_KEY" -H "Authorization: Bearer $SUPABASE_SERVICE_KEY" \
  -H "Content-Type: application/pdf" --data-binary @/path/to/report.pdf

Get a Signed URL for a Lab Report

curl -s -X POST "$SUPABASE_URL/storage/v1/object/sign/health-reports/lab-reports/2026-03-15_thyrocare_aarogyam.pdf" \
  -H "apikey: $SUPABASE_SERVICE_KEY" -H "Authorization: Bearer $SUPABASE_SERVICE_KEY" \
  -H "Content-Type: application/json" -d '{"expiresIn": 3600}'

Log Weight

Manual Weight Entry

curl -s -X POST "$SUPABASE_URL/rest/v1/daily_weight" \
  -H "apikey: $SUPABASE_SERVICE_KEY" -H "Authorization: Bearer $SUPABASE_SERVICE_KEY" \
  -H "Content-Type: application/json" -H "Prefer: return=representation" \
  -d '{
    "patient_id": "PATIENT_UUID",
    "source": "manual",
    "date": "2026-03-20",
    "weight_kg": 72.5,
    "bmi": null,
    "body_fat_pct": null
  }'

Track Weight Over Time

SELECT date, weight_kg, source
FROM daily_weight
ORDER BY date DESC LIMIT 30

Viewing Logged Data

Recent Daily Logs

SELECT date, mood, energy, stress,
       exercise_done, exercise_type, exercise_minutes,
       symptoms, notes
FROM daily_logs
ORDER BY date DESC LIMIT 7

All Flagged Lab Results

curl -s "$SUPABASE_URL/rest/v1/lab_results?select=id,report_id,category,parameter,value_numeric,value_text,unit,ref_range,status,lab_reports(report_date,lab)&status=neq.normal&order=report_id" \
  -H "apikey: $SUPABASE_SERVICE_KEY" -H "Authorization: Bearer $SUPABASE_SERVICE_KEY"

Or from DuckDB:

SELECT lr.parameter, lr.value_numeric, lr.unit, lr.ref_range, lr.status,
       rep.report_date, rep.lab
FROM lab_results lr
JOIN lab_reports rep ON lr.report_id = rep.id
WHERE lr.status != 'normal'
ORDER BY rep.report_date DESC, lr.category, lr.parameter

Track a Specific Biomarker Across Reports

SELECT lr.value_numeric, lr.unit, lr.status, lr.ref_range,
       rep.report_date, rep.lab
FROM lab_results lr
JOIN lab_reports rep ON lr.report_id = rep.id
WHERE lr.parameter = 'vitamin_d'
ORDER BY rep.report_date

Key biomarkers to track longitudinally: vitamin_b12, vitamin_d, sgot_ast, sgpt_alt, ldl, hba1c, hs_crp, lipoprotein_a, rdw_cv, homocysteine.

After Storing: Offer Analysis

After inserting a lab report, always offer to analyse it:

I've stored all [N] values from your [Lab Name] report.

Flagged results:

  • [parameter]: [value] [unit] — [HIGH/LOW] (range: [ref_range])
  • ...

Would you like me to:

  1. Compare these to your previous reports (if any)?
  2. Cross-reference with your Fitbit data (e.g., elevated liver enzymes + high RHR)?
  3. Flag anything that needs medical attention?

Use the /health-analysis skill to run the correlation analysis.

After Logging: Sync to Local DuckDB

After inserting data via Supabase, pull it to your local DuckDB for analysis:

# Pull latest data
phf pull

This ensures the health-analysis skill has access to the latest logged data.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.