mysi Find

Skill in Training and nutrition

Meal energy and macros against a walk

Adds up a meal's energy and macronutrients from USDA per-100 g values and sets it against a walk's energy.

Say this to your agent

Use https://mysi.dev/meal-energy-and-macros/ to add up 150 g chicken breast, 75 g rice and 200 g broccoli against a 45 min walk.

Nothing to install, no key, no settings. An agent that can open web pages opens the page, follows the steps with the figures and code on it and gives you the answer.

When to use

  • Someone lists foods with their weights and asks the meal's energy, protein, fat or carbohydrate.
  • Someone asks how a meal's energy compares with a walk of given length, speed and slope.
  • Not for setting calorie or macro targets: this page adds up and compares, nothing more.

Steps

  1. Write down each food and its weight in grams (ounces × 28.349523). Use the weight as the food is listed: raw, or dry for rice, pasta, oats and lentils.
  2. Find each food in the figures below (values per 100 g). If a food is not there, read the dataset at https://mysi.dev/food-nutrients-common/ ; if you cannot open it, ask the user for the food's per-100 g values. Never use nutrient values from memory.
  3. For each food, multiply each per-100 g value by its grams and divide by 100. Write each result down.
  4. Add the foods together, one nutrient at a time: energy in kcal, protein, fat and carbohydrate in g. Round only the final totals, to one decimal.
  5. For the walk call walking_calorie(weight_kg, speed, duration_minutes, incline). speed is slow (2.0 mph), moderate (3.0), brisk (3.5), fast (4.0) or very-fast (4.5); incline is flat (0%), slight (2%), moderate (5%) or steep (10%).
  6. Take calories (gross energy of the walk). If the user asks for energy above resting, take netCalories instead and say so.
  7. Subtract the walk's energy from the meal's energy (meal minus walk) and keep the sign.
  8. Report the meal totals, the walk's energy with which figure was used (gross or net), and the difference, in kcal.

Mistakes this prevents

  • Using cooked-weight values for rice, pasta, oats or lentils listed dry (or the reverse): the figures below for these foods are per 100 g raw or dry, and the dataset holds no cooked items.
  • Using remembered label values instead of the USDA figures below.
  • Counting a walk at a flat MET: the slope adds energy, and the function carries the 2024 Compendium METs and the ACSM slope term.
  • Mixing gross and net walking energy: gross includes the energy a body burns at rest.

Tell the user

  • Food values are USDA FoodData Central Foundation Foods figures per 100 g, rounded to three significant figures; a given product or recipe can differ.
  • Walking energy is a population-average estimate; an individual can differ by 20% or more.

Figures: Energy and macronutrients of common foods

Sources read 4 Dec 2026. Current figures: https://mysi.dev/food-nutrients-common/

The code

Copy each function into your Python tool. Run its check first.

Walking calories

"""Walking calories: energy burned on a walk from body weight, a speed band, the time and the slope.
The level-walking MET comes from the 2024 Adult Compendium of Physical Activities; the slope adds
the grade term of the ACSM walking equation.
Inputs: weight_kg (1 to 300), speed (slow, moderate, brisk, fast, very-fast; default moderate),
duration_minutes (1 to 600, default 30), incline (flat, slight, moderate, steep; default flat).
Returns: calories and netCalories (kcal, 1 decimal), caloriesPerMinute (2 decimals), met
(2 decimals), inclineMultiplier (3 decimals), durationHours (2 decimals).
mysi, Walking calories, mysi.dev/walking-calorie, version 1, changed 2026-12-04. MIT.
"""
import math


def _walking_calorie_num(name, value, low, high):
    if isinstance(value, bool) or not isinstance(value, (int, float)) or not low <= value <= high:
        raise ValueError(f"{name} must be a number from {low} to {high}")
    return float(value)


def _walking_calorie_pick(name, value, table):
    if not isinstance(value, str) or value not in table:
        raise ValueError(f"{name} must be one of: {', '.join(table)}")
    return table[value]


def _walking_calorie_round(value, digits):
    return math.floor(value * 10 ** digits + 0.5) / 10 ** digits  # half up, as the old engine


def walking_calorie(weight_kg, speed="moderate", duration_minutes=30, incline="flat"):
    w = _walking_calorie_num("weight_kg", weight_kg, 1, 300)
    minutes = _walking_calorie_num("duration_minutes", duration_minutes, 1, 600)
    # speed band: (mph, level MET), 2024 Adult Compendium codes 17152, 17190, 17200, 17220, 17230
    mph, level_met = _walking_calorie_pick("speed", speed, {
        "slow": (2.0, 2.8), "moderate": (3.0, 3.8), "brisk": (3.5, 4.8),
        "fast": (4.0, 5.5), "very-fast": (4.5, 7.0)})
    grade = _walking_calorie_pick("incline", incline, {
        "flat": 0.0, "slight": 0.02, "moderate": 0.05, "steep": 0.10})
    v = mph * 1609.344 / 60                    # metres per minute
    met = level_met + 1.8 * v * grade / 3.5    # ACSM walking grade term, 3.5 ml/kg/min = 1 MET
    hours = minutes / 60
    calories = met * w * hours                 # 1 MET = 1 kcal per kg per hour
    return {
        "calories": _walking_calorie_round(calories, 1),
        "netCalories": _walking_calorie_round((met - 1) * w * hours, 1),
        "caloriesPerMinute": _walking_calorie_round(calories / minutes, 2),
        "met": _walking_calorie_round(met, 2),
        "inclineMultiplier": _walking_calorie_round(met / level_met, 3),
        "durationHours": _walking_calorie_round(hours, 2),
    }


WALKING_CALORIE_CASES = [
    ({"weight_kg": 70, "speed": "brisk", "duration_minutes": 30, "incline": "slight"},
     {"calories": 201.8, "netCalories": 166.8, "met": 5.77}),
    ({"weight_kg": 60, "speed": "moderate", "duration_minutes": 60, "incline": "flat"},
     {"calories": 228.0, "netCalories": 168.0, "met": 3.8}),
    ({"weight_kg": 80, "speed": "slow", "duration_minutes": 45, "incline": "steep"},
     {"calories": 333.5, "netCalories": 273.5, "met": 5.56}),
]


def walking_calorie_check(tolerance=1e-3):
    for given, want in WALKING_CALORIE_CASES:
        got = walking_calorie(**given)
        for name, value in want.items():
            close = abs(got[name] - value) <= tolerance * max(1, abs(value))
            assert close, (name, got[name], value)
    return "ok"


if __name__ == "__main__":
    import json, sys
    walking_calorie_check()
    given = dict(a.split("=", 1) for a in sys.argv[1:] if "=" in a)
    js = lambda v: v.lstrip("-")[:1].isdigit() or v[:1] in '[{".' or v in ("true", "false", "null")
    given = {k: json.loads(v) if js(v) else v for k, v in given.items()}
    if given:
        print(json.dumps(walking_calorie(**given)))
Raw file

What it reads

Keep it: save https://mysi.dev/meal-energy-and-macros.md as SKILL.md in a folder named meal-energy-and-macros, and it is a skill in agents that have skill folders.

Tested

Tested 4 Dec 2026: claude-haiku-5-5 was right on 0 of 3 questions without this page and 3 of 3 with it; claude-fable-5-2 was right on 0 of 3 questions without this page and 3 of 3 with it.

Changes

Cite as: mysi, Meal energy and macros against a walk, mysi.dev/meal-energy-and-macros, version 1, changed 2026-12-04. Code MIT.