assistant-skills/food-tracking/SKILL.md

4.2 KiB

Food Tracking

Manage food items and daily food log entries in MongoDB (lists.food_items, lists.food_log).

Scripts

Both scripts are standalone Python CLIs. Run with uv run --with pymongo:

food_items.py — lists.food_items

Reference item catalog: what foods exist, their nutrition, serving sizes, etc.

# Path relative to skill directory
SCRIPT="skills/food-tracking/scripts/food_items.py"

# Add a new food item
uv run --with pymongo "$SCRIPT" add \
  --name "Kefir Oats" \
  --type food \
  --serving "1.5 cups" \
  --description "Whole milk kefir with old-fashioned rolled oats" \
  --nutrition '{"calories": 228, "protein_g": 12.1, "fat_g": 7.0, "carbs_g": 30.1, "fiber_g": 3.5, "sugar_g": 6.3}'

# Add with aliases (for flexible name matching)
uv run --with pymongo "$SCRIPT" add \
  --name "Dave's Killer Bread 21 Whole Grains" \
  --type food \
  --serving "1 slice (45g)" \
  --aliases "large bread,large toast" \
  --nutrition '{"calories": 110, "protein_g": 6, "fat_g": 1.5, "carbs_g": 22}'

# Add a medicine
uv run --with pymongo "$SCRIPT" add \
  --name "Excedrin Migraine" \
  --type medicine \
  --max-dosage "2 caplets"

# Add with arbitrary extra fields via JSON
uv run --with pymongo "$SCRIPT" add \
  --name "Chicken Breast" \
  --type food \
  --serving "4 oz" \
  --nutrition '{"calories": 187, "protein_g": 35, "fat_g": 4, "carbs_g": 0}' \
  --extra '{"recipe_notes": "grilled, no oil"}'

# Get all items
uv run --with pymongo "$SCRIPT" get

# Filter by type
uv run --with pymongo "$SCRIPT" get --type food

# Search by name
uv run --with pymongo "$SCRIPT" get --name "kefir"

# Update an item by name
uv run --with pymongo "$SCRIPT" update --name "Kefir Oats" --set-serving "2 cups"

# Update an item by _id
uv run --with pymongo "$SCRIPT" update --id "6a11b0c3..." --set-nutrition '{"calories": 300, "protein_g": 15, "fat_g": 9, "carbs_g": 40}'

# Update aliases
uv run --with pymongo "$SCRIPT" update --name "Kefir Oats" --set-aliases "kefir oats,ko"

# Unset a field
uv run --with pymongo "$SCRIPT" update --name "Excedrin Migraine" --unset max_dosage

# Merge arbitrary fields
uv run --with pymongo "$SCRIPT" update --name "Chicken Breast" --set-extra '{"tags": ["dinner", "high-protein"]}'

food_log.py — lists.food_log

Daily consumption log: what was eaten, when, and how much.

SCRIPT="skills/food-tracking/scripts/food_log.py"

# Log a food entry
uv run --with pymongo "$SCRIPT" add --name "Kefir Oats" --type food --amount 1 --unit "serving"

# Log a medicine
uv run --with pymongo "$SCRIPT" add --name "Excedrin Migraine" --type medicine --amount 1 --unit "caplet"

# Log with extra fields
uv run --with pymongo "$SCRIPT" add --name "Coffee" --type food --amount 2 --unit "cups" --extra '{"caffeine_mg": 200}'

# Get today's log
uv run --with pymongo "$SCRIPT" get --today

# Get last 7 days
uv run --with pymongo "$SCRIPT" get --days 7

# Filter by name or type
uv run --with pymongo "$SCRIPT" get --name "Excedrin"
uv run --with pymongo "$SCRIPT" get --type medicine

# Update an entry (requires --id from a previous get)
uv run --with pymongo "$SCRIPT" update --id "6a11a937..." --set-amount 2 --set-unit "caplets"

# Unset a field
uv run --with pymongo "$SCRIPT" update --id "6a11a937..." --unset unit

# Delete an entry
uv run --with pymongo "$SCRIPT" delete --id "6a11a937..."

Workflow Notes

  • When logging food, the assistant should run food_items.py get --name <item> first to confirm the item exists and show its nutrition info.
  • For new foods not in the catalog, add the item first, then log it.
  • Always present nutrition info back to the user when logging food (pull from food_items so the user sees the macros).
  • Always include nutrition info in food log entries for any non-medicine type. Use --extra with a "nutrition" JSON object containing the relevant macros (calories, protein_g, fat_g, carbs_g, fiber_g, sugar_g, etc.) pulled from the food item's catalog entry.
  • When searching the internet for nutrition facts, use USDA FoodData Central as the source, then store the result as a food item.
  • The --extra flag on both scripts accepts arbitrary JSON, useful for fields not covered by named flags (e.g., recipe details, tags, notes).