/cooklang:nutrition-goalsfrom cooklang
Modifies existing Cooklang recipes (.cook) or meal plans (.menu) to meet numeric nutrition targets like calories per serving or daily protein. Measures, edits, verifies, and saves changes.
Ships in cooklang. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Needs the Cook MCP server (tools like render_report and validate). If these tools are missing, the Cook MCP server isn't connected: if you installed the cooklang plugin or extension, check that its cook server is running (e.g. /mcp) or reinstall it; otherwise add it from https://github.com/cook-md/cook-mcp. Never estimate nutrition from your own knowledge instead.
Use when the user wants to change a recipe or meal plan so it hits numeric
nutrition targets — "make this 600 kcal per serving", "get my week to 150 g
protein per day", "more protein, same calories". You measure with the Cook
nutrition service (through render_report), choose edits, verify them
before saving, save, and confirm.
Nutrition data needs a cook.md login and Cook Basic or Cook Pro. On
"authentication required" call login; on "subscription required" show the
user the pricing link from the error. The direct nutrition tools (get_nutrition, aggregate_nutrition, lookup_ingredient, …) return JSON login_required (call login) or plan_required (show the user checkout_url) instead.
This skill changes food to reach numbers. For evaluation-only questions where no change is wanted ("is this healthy?", "how much protein is in this?"), follow the nutrition-reports skill instead.
Not for selection. "Find me three dinners over 35% protein", "which of my
recipes are high protein", "plan a week that averages 150 g protein from what I
already have" are screening requests: nothing gets edited, and the number is
a filter over existing files. Running this skill's per-file measure-and-edit
loop over a candidate list is how a three-dinner question turns into a hundred
tool calls. Follow nutrition-reports (its "Screening a shortlist" section) and,
if a .menu is wanted at the end, meal-planning. Come back here only once a
specific file has been chosen and has to change to hit the number.
kcal, protein_g, fat_g, sat_fat_g,
carb_g, sugar_g, fiber_g; micros/vitamins by key via nutrient_total
(e.g. "sodium_mg", "iron_mg"). nutrient_total returns 0 for an unknown
key — if a micro baseline reads 0 for an ingredient list that plainly
contains it, suspect the key, not the food..menu plans). If the
recipe declares servings and the user just says "600 kcal", per-serving vs
total is genuinely ambiguous — ask. Otherwise don't ask; state your reading.within_tol(value, target, 5)); use the user's
figure when given. For "keep X the same", hold X within ±5 % of its current
value.Read the file with read_recipe (you need its source to edit it), then render
it with render_report (input_path = the file). Emit machine-readable lines —
the ITEM lines are your lever map (which ingredients dominate which nutrient):
{% set t = macros(ingredients) %}
{% set servings = metadata.servings | default(1) | int %}
TOTAL kcal={{ t.kcal | round(1) }} protein={{ t.protein_g | round(1) }} fat={{ t.fat_g | round(1) }} carb={{ t.carb_g | round(1) }} fiber={{ t.fiber_g | round(1) }}
PER_SERVING ({{ servings }}) kcal={{ (t.kcal / servings) | round(1) }} protein={{ (t.protein_g / servings) | round(1) }}
{% set agg = aggregate_nutrition(ingredients) %}
{% for it in agg.items -%}
ITEM {{ it.ingredient }} | {{ it.amount.value }} {{ it.amount.unit }} | kcal={{ it.macros.kcal | round(1) }} protein={{ it.macros.protein_g | round(1) }} | {{ it.confidence }}
{% endfor -%}
{% for f in agg.failures -%}
FAILED {{ f.ingredient }} — {{ f.error.message }}
{% endfor -%}
FAILED ingredients contribute nothing to the totals — tell the user the
numbers exclude them rather than silently trusting the total. Flag estimated
confidence items when they dominate a target nutrient.
For .menu plans the template reads plan.days (each day's scaled
.ingredients) instead of ingredients; see the "Meal plans" section of
nutrition-reports and https://nutrition.cook.md/docs/guides/plan.
Prefer the least invasive tier that can reach the target; move down only when the current tier cannot:
lookup_ingredient finds catalog names,
check_category keeps a swap in its category (e.g. oily fish), and
get_nutrition compares per-amount profiles before you commit.Keep the dish's character: a few decisive changes beat many tiny ones. Round
to practical cooking amounts and keep the recipe's existing unit style. The
cooklang://syntax resource covers the edit mechanics for .cook and
.menu files.
Write the full edited file text, then render it with render_report using
input (the edited text) and kind ("cook" or "menu") instead of
input_path — the same measuring template, so numbers are comparable. Nothing
is saved yet. Refine at most ~3 rounds; if the targets stay unreachable within
the allowed tiers, stop and present the closest achievable numbers with a
plain explanation of the gap (e.g. "without swapping the rice, 40 g protein
forces ~750 kcal").
To compare a few alternatives quickly without writing each one out, sum
nutrition_for_amount over a candidate list (item shape — macros live under
.macros); it raises a template error when an ingredient can't be resolved,
so fix the name/unit and re-render:
{% set candidate = [
{"name": "chicken breast", "amount": 300, "unit": "g"},
{"name": "olive oil", "amount": 1, "unit": "tbsp"},
{"name": "basmati rice", "amount": 150, "unit": "g"}
] %}
{% set servings = 2 %}
{% set ns = namespace(kcal=0.0, protein=0.0) %}
{% for c in candidate %}
{% set n = nutrition_for_amount(c.name, c.amount, c.unit) %}
{% set ns.kcal = ns.kcal + n.macros.kcal %}
{% set ns.protein = ns.protein + n.macros.protein_g %}
{% endfor %}
CANDIDATE total kcal={{ ns.kcal | round(1) }} protein={{ ns.protein | round(1) }}
CANDIDATE per-serving kcal={{ (ns.kcal / servings) | round(1) }}
KCAL_OK={{ within_tol(ns.kcal / servings, 600, 5) }}
validate on the edited text, then save with write_recipe (.cook) or
write_menu (.menu), always the full file content. This overwrites the
user's file: if they asked to see options first, or the change is large (tier
3), confirm before saving.olive oil 3 tbsp → 1 tbsp), not a full diff, and where you saved it.Re-render the saved file with input_path and the same measuring template. If
the numbers differ from step 4, say so and fix — the saved file is what the
user will cook from.
Offer (don't push) to save the targets as a reusable checks template so future
edits can be re-validated (the nutrition-reports flow), at
reports/goals.<recipe-slug>.md.jinja (or under config/reports/ if that is
where the collection keeps its templates — Cook Editor does), with write_config:
{% import "ck" as ck %}
{% set t = macros(ingredients) %}
{% set servings = metadata.servings | default(1) | int %}
# Goals — {{ metadata.title | default("Recipe") }}
- Energy: {{ (t.kcal / servings) | round }} kcal per serving
- Protein: {{ (t.protein_g / servings) | round(1) }} g per serving
{{ ck.between(t.kcal / servings, 570, 630, "kcal per serving") }}
{{ ck.min(t.protein_g / servings, {"min": 40}, "Protein per serving (g)") }}
{% set checks = all_checks() %}
**{{ checks | selectattr("ok") | list | length }} of {{ checks | length }} checks passed.**
Render it later with template_path: "reports/goals.<recipe-slug>.md.jinja".
(ck.min/ck.max/ck.range take a target object like {"min": 40};
ck.between takes scalar bounds.)
Full reference at https://nutrition.cook.md/docs/guides/functions.
| Function | Returns |
|---|---|
macros(ingredients) | flattened totals {kcal, protein_g, fat_g, sat_fat_g, carb_g, sugar_g, fiber_g} |
aggregate_nutrition(ingredients) | {items, failures, totals, confidence_breakdown}; each item has .ingredient, .amount.value/.unit/.mass_g, .macros.*, .confidence |
nutrition_for_amount(name, amount, unit, prep?, standard?) | one full item (same shape as items[]) for an arbitrary hypothetical amount |
nutrient_total(ingredients, key) | number; micros then vitamins ("sodium_mg", "vit_d_iu") |
within_tol(actual, target, tol_pct) | bool — within tol_pct % of target |
compare(actual, target, op) | bool — op is gte/lte/eq |
convert(amount, from, to, ingredient?) | unit conversion (ingredient needed for volume/count) |
record_check(label, ok) / all_checks() | record and read passed/failed checks (used by ck macros) |
aggregate_nutrition / macros (both skip
unresolved ingredients; aggregate_nutrition lists them under failures), never with
nutrition_for(ingredient) in a loop — that aborts on the first miss.nutrition_for_amount,
clearly marked as translated by you.render_report returns an error result on failure:
login, show the user the code and link,
retry once they've approved.What SKILL.md sets; muted values are Claude Code's defaults
14 skills in this plugin
/cooklang-editingUse when writing a new Cooklang recipe or editing or fixing a .cook file - ingredients, cookware, timers, steps, sections, or resizing a recipe for good. For metadata/frontmatter changes use the metadata skill; to just show scaled amounts use scale-recipe. Not for meal plans (.menu) or importing from a URL/text./cooklang-validationUse when checking or validating Cooklang - one .cook recipe, a folder, or the whole collection - for syntax errors and broken references, or when asked to fix or clean up Cooklang (e.g. a stray ingredient list or unbraced multi-word names)./export-recipeUse when the user wants a Cooklang recipe (.cook) or meal plan (.menu) in another format - Markdown for a blog or notes, JSON or YAML for an app, plain text to paste or print, HTML, LaTeX - or a reusable export template. Not for importing into Cooklang (recipe-import).npx claudepluginhub cooklang/cooklang-skills --plugin cooklangOther plugins' skills for the same job