{"skills":[{"name":"Calculate ingredient cost per portion","description":"Use actual pack prices and recipe quantities to cost the food served, keeping the till spend and the cost of ingredients used separate.","content":"# Calculate ingredient cost per portion\n\nUse actual pack prices and recipe quantities to cost the food served, keeping the till spend and the cost of ingredients used separate.\n\n## When to use this skill\n\n- A caf\u00e9, caterer or home cook wants the ingredient cost of each portion of a dish.\n- Someone has supplier prices or receipts and a recipe and wants a recipe cost sheet.\n- Someone asks what a trial batch really cost per portion they could sell, or why the shop cost more than the recipe used.\n\n## When not to use it\n\n- Setting a menu price or margin. This skill stops at ingredient cost; labour, energy, packaging and overheads need costing separately.\n- Measuring the yield itself. Use the trim yield skill to weigh the losses, then cost with the measured yield.\n\n## What you need\n\n- Each ingredient's purchase pack quantity, pack price, amount used and currency, including any relevant edible yield.\n- The actual number of saleable portions produced. Identify ingredients supplied without a price.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- What does each ingredient cost, and what quantity does that price buy? A missing price stays unknown rather than zero.\n- Is each recipe quantity weighed as bought, or after peeling, trimming or cooking? If after, what yield did you measure?\n- How many portions were actually fit to sell, rather than planned?\n- Do you want the cost of what the recipe uses, the cost of buying whole packs from empty, or both?\n\n## Method\n\n1. List every ingredient, including oil, garnish, seasoning and finishing items, and copy each label exactly as supplied.\n2. Put the price and the recipe quantity in the same unit and preparation state. If the price is per as-bought weight and the recipe gives an edible weight, divide the edible weight by the yield first: 600 g peeled at an 80% yield uses 750 g as bought.\n3. Cost used = as-bought quantity used \u00f7 pack quantity \u00d7 pack price. Carry unrounded values and show three decimals per ingredient. A missing price makes that ingredient, and every total that depends on it, unknown.\n4. Batch cost is the sum of the ingredient costs. Cost per saleable portion = batch cost \u00f7 portions actually fit to sell. Spoiled or rejected portions keep their ingredients in the batch cost but leave the divisor, and zero saleable portions leaves the unit cost unknown.\n5. If the shopping cost is wanted, round each ingredient's required as-bought quantity up to whole packs and price those packs. Report it beside the used cost, not instead of it.\n6. Keep ingredient cost apart from labour, energy, packaging and margin. If a selling price is given, food cost % = cost per portion \u00f7 selling price \u00d7 100; say whether that price includes VAT or other sales tax.\n7. Date the cost sheet and re-cost when supplier prices change, since the result is only as current as its prices.\n\n## Checks before you deliver\n\n- Someone buying one \u00a35 pack to use a fifth spends \u00a35 at the till but uses \u00a31 of the pack in the recipe.\n- Rounding each small spice allowance before summing can distort the portion cost.\n- Costing a peeled weight at the as-bought price understates cost: 600 g of peeled potatoes at \u00a32 per kg is \u00a31.20 before the 80% yield and \u00a31.50 after it.\n- Dividing by planned rather than saleable portions: \u00a37.80 over four fish portions is \u00a31.95, but with one spoiled each saleable portion carries \u00a32.60.\n- Treating a missing price as zero gives a confident total that is wrong.\n\n## How to present the result\n\nLead with the ingredient cost per saleable portion and the batch cost. Then give a costing table: ingredient, quantity used, as-bought quantity, pack size and price, cost used. Show the cost of buying whole packs from empty separately if asked, and list any missing price that blocks the totals.\n\n## Worked example\n\n**Request:** What does each finished portion cost in ingredients?\n\n**Supplied material:**\n\n```text\nServes 4. Potatoes: \u00a32 per 1000 g as bought, 600 g peeled needed, measured yield 80%. Cheese: \u00a33 per 300 g, use 90 g. Chives: \u00a31 per 20 g, use 4 g.\n```\n\n**Answer:** Each of the four portions uses 65p of ingredients. The potatoes cost \u00a31.50 after allowing for peel, the cheese 90p and the chives 20p. The batch uses \u00a32.60 from packs that cost \u00a36 to buy from empty.\n\n## Structured output for tests\n\nFor an ordinary job, answer in the format above and point back to the supplied evidence. Use this structure only for the test cases published with this skill, or when someone asks for structured JSON.\n\nReturn used_cost_gbp keyed by ingredient (number to three decimal places or null), batch_gbp and per_portion_gbp (rounded to two decimals or null if any cost is missing); return buy_from_empty_gbp as whole-pack cost for the batch assuming empty stock, or null when unknown. Copy each ingredient label exactly as supplied, preserving capitals.\n\n## Sources\n\n- [BC Cook Articulation Committee: controlling food costs](https:\/\/opentextbc.ca\/basickitchenandfoodservicemanagement\/chapter\/controlling-food-costs\/): The catering textbook names standard yields, portion sizes and portion costs among its five food cost standards, and shows a recipe cost sheet that extends each ingredient's unit cost by the quantity used, divides by the yield and compares the portion cost with the selling price as a food cost percentage.\n- [Institute of Child Nutrition: Basic Culinary Math participant's workbook](https:\/\/theicn.org\/resources\/118\/basic-culinary-math-for-school-nutrition-professionals\/106918\/basic-culinary-math-participants-workbook.pdf): Lesson I divides a case price by its servings to get cost per serving, and Lesson IV distinguishes as-purchased from edible-portion quantities and calculates recipe and per-serving costs from purchase prices.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/cost-a-portion-from-pack-prices\n","scope":"contextual","trigger_keywords":["Calculate ingredient cost per portion","cost-a-portion-from-pack-prices","cost a portion from pack prices","What does one portion of this dish cost in ingredients?","What does one portion of this dish cost in ingredients","cost per portion","cost this recipe","recipe portion cost"],"is_private":true,"is_active":true,"scripts":[{"name":"cost-a-portion-from-pack-prices-check","description":"Compare a saved JSON answer with a published test. Pass tests\/case-1\/expected.json (or another case) and the path to your answer.","language":"python","filename":"cost-a-portion-from-pack-prices-check.py","content":"from pathlib import Path\nimport runpy\n\nrunpy.run_path(str(Path(__file__).parent \/ 'tests' \/ 'check.py'), run_name='__main__')\n","supporting_files":[{"path":"SKILL.md","content":"---\nname: cost-a-portion-from-pack-prices\ndescription: \"Cost the ingredients in one portion from pack prices, pack sizes and the amounts a recipe uses, allowing for prep losses and portions that cannot be sold. Use when someone asks for cost per portion, food cost per plate, a recipe cost sheet, or why the shopping cost more than the recipe used.\"\nlicense: CC-BY-4.0\nmetadata:\n  author: Raq.com\n  version: \"2026-11-22\"\n  homepage: https:\/\/skills.raq.com\/skills\/cost-a-portion-from-pack-prices\n---\n\n# Calculate ingredient cost per portion\n\nUse actual pack prices and recipe quantities to cost the food served, keeping the till spend and the cost of ingredients used separate.\n\n## When to use this skill\n\n- A caf\u00e9, caterer or home cook wants the ingredient cost of each portion of a dish.\n- Someone has supplier prices or receipts and a recipe and wants a recipe cost sheet.\n- Someone asks what a trial batch really cost per portion they could sell, or why the shop cost more than the recipe used.\n\n## When not to use it\n\n- Setting a menu price or margin. This skill stops at ingredient cost; labour, energy, packaging and overheads need costing separately.\n- Measuring the yield itself. Use the trim yield skill to weigh the losses, then cost with the measured yield.\n\n## What you need\n\n- Each ingredient's purchase pack quantity, pack price, amount used and currency, including any relevant edible yield.\n- The actual number of saleable portions produced. Identify ingredients supplied without a price.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- What does each ingredient cost, and what quantity does that price buy? A missing price stays unknown rather than zero.\n- Is each recipe quantity weighed as bought, or after peeling, trimming or cooking? If after, what yield did you measure?\n- How many portions were actually fit to sell, rather than planned?\n- Do you want the cost of what the recipe uses, the cost of buying whole packs from empty, or both?\n\n## Method\n\n1. List every ingredient, including oil, garnish, seasoning and finishing items, and copy each label exactly as supplied.\n2. Put the price and the recipe quantity in the same unit and preparation state. If the price is per as-bought weight and the recipe gives an edible weight, divide the edible weight by the yield first: 600 g peeled at an 80% yield uses 750 g as bought.\n3. Cost used = as-bought quantity used \u00f7 pack quantity \u00d7 pack price. Carry unrounded values and show three decimals per ingredient. A missing price makes that ingredient, and every total that depends on it, unknown.\n4. Batch cost is the sum of the ingredient costs. Cost per saleable portion = batch cost \u00f7 portions actually fit to sell. Spoiled or rejected portions keep their ingredients in the batch cost but leave the divisor, and zero saleable portions leaves the unit cost unknown.\n5. If the shopping cost is wanted, round each ingredient's required as-bought quantity up to whole packs and price those packs. Report it beside the used cost, not instead of it.\n6. Keep ingredient cost apart from labour, energy, packaging and margin. If a selling price is given, food cost % = cost per portion \u00f7 selling price \u00d7 100; say whether that price includes VAT or other sales tax.\n7. Date the cost sheet and re-cost when supplier prices change, since the result is only as current as its prices.\n\n## Checks before you deliver\n\n- Someone buying one \u00a35 pack to use a fifth spends \u00a35 at the till but uses \u00a31 of the pack in the recipe.\n- Rounding each small spice allowance before summing can distort the portion cost.\n- Costing a peeled weight at the as-bought price understates cost: 600 g of peeled potatoes at \u00a32 per kg is \u00a31.20 before the 80% yield and \u00a31.50 after it.\n- Dividing by planned rather than saleable portions: \u00a37.80 over four fish portions is \u00a31.95, but with one spoiled each saleable portion carries \u00a32.60.\n- Treating a missing price as zero gives a confident total that is wrong.\n\n## How to present the result\n\nLead with the ingredient cost per saleable portion and the batch cost. Then give a costing table: ingredient, quantity used, as-bought quantity, pack size and price, cost used. Show the cost of buying whole packs from empty separately if asked, and list any missing price that blocks the totals.\n\n## Worked example\n\n**Request:** What does each finished portion cost in ingredients?\n\n**Supplied material:**\n\n```text\nServes 4. Potatoes: \u00a32 per 1000 g as bought, 600 g peeled needed, measured yield 80%. Cheese: \u00a33 per 300 g, use 90 g. Chives: \u00a31 per 20 g, use 4 g.\n```\n\n**Answer:** Each of the four portions uses 65p of ingredients. The potatoes cost \u00a31.50 after allowing for peel, the cheese 90p and the chives 20p. The batch uses \u00a32.60 from packs that cost \u00a36 to buy from empty.\n\n## Structured output for tests\n\nFor an ordinary job, answer in the format above and point back to the supplied evidence. Use this structure only for the test cases published with this skill, or when someone asks for structured JSON.\n\nReturn used_cost_gbp keyed by ingredient (number to three decimal places or null), batch_gbp and per_portion_gbp (rounded to two decimals or null if any cost is missing); return buy_from_empty_gbp as whole-pack cost for the batch assuming empty stock, or null when unknown. Copy each ingredient label exactly as supplied, preserving capitals.\n\n## Sources\n\n- [BC Cook Articulation Committee: controlling food costs](https:\/\/opentextbc.ca\/basickitchenandfoodservicemanagement\/chapter\/controlling-food-costs\/): The catering textbook names standard yields, portion sizes and portion costs among its five food cost standards, and shows a recipe cost sheet that extends each ingredient's unit cost by the quantity used, divides by the yield and compares the portion cost with the selling price as a food cost percentage.\n- [Institute of Child Nutrition: Basic Culinary Math participant's workbook](https:\/\/theicn.org\/resources\/118\/basic-culinary-math-for-school-nutrition-professionals\/106918\/basic-culinary-math-participants-workbook.pdf): Lesson I divides a case price by its servings to get cost per serving, and Lesson IV distinguishes as-purchased from edible-portion quantities and calculates recipe and per-serving costs from purchase prices.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/cost-a-portion-from-pack-prices\n"},{"path":"LICENSE.txt","content":"Original Raq.com instructions and synthetic examples: CC BY 4.0.\nhttps:\/\/creativecommons.org\/licenses\/by\/4.0\/\nAttribution: Raq.com, https:\/\/skills.raq.com\/skills\/cost-a-portion-from-pack-prices\nReferenced third-party materials retain their own terms.\n"},{"path":"examples\/worked-example.md","content":"# A garnish and a peeling loss\n\nWhat does each finished portion cost in ingredients?\n\n## Supplied material\n\nServes 4. Potatoes: \u00a32 per 1000 g as bought, 600 g peeled needed, measured yield 80%. Cheese: \u00a33 per 300 g, use 90 g. Chives: \u00a31 per 20 g, use 4 g.\n\n## Worked answer\n\nEach of the four portions uses 65p of ingredients. The potatoes cost \u00a31.50 after allowing for peel, the cheese 90p and the chives 20p. The batch uses \u00a32.60 from packs that cost \u00a36 to buy from empty.\n\n## Reasoning\n\nThe recipe consumes \u00a32.60, though buying whole packs from an empty kitchen costs \u00a36.\n"},{"path":"tests\/check.py","content":"\"\"\"Check a saved agent answer locally with Python 3 (standard library only).\"\"\"\nimport json\nimport math\nimport sys\nfrom pathlib import Path\n\n\ndef compare(expected, actual, path=\"$\", accepted=None):\n    if isinstance(expected, bool) or isinstance(actual, bool):\n        if expected is not actual:\n            yield path\n    elif isinstance(expected, (int, float)) and isinstance(actual, (int, float)):\n        if not math.isclose(expected, actual, rel_tol=0, abs_tol=1e-8):\n            yield path\n    elif isinstance(expected, dict) and isinstance(actual, dict):\n        for key in sorted(set(expected) | set(actual)):\n            if key not in expected or key not in actual:\n                yield f\"{path}.{key}\"\n            elif not any(\n                not list(compare(option, actual[key]))\n                for option in (accepted or {}).get(key, [])\n            ):\n                yield from compare(expected[key], actual[key], f\"{path}.{key}\")\n    elif isinstance(expected, list) and isinstance(actual, list):\n        if len(expected) != len(actual):\n            yield f\"{path} (length)\"\n        for i, (left, right) in enumerate(zip(expected, actual)):\n            yield from compare(left, right, f\"{path}[{i}]\")\n    elif type(expected) != type(actual) or expected != actual:\n        yield path\n\n\ndef main():\n    if len(sys.argv) != 3:\n        raise SystemExit(\"Usage: python3 check.py expected.json answer.json\")\n    try:\n        expected, actual = [json.loads(Path(p).read_text(encoding=\"utf-8\")) for p in sys.argv[1:]]\n        alternatives = Path(sys.argv[1]).with_name(\"accepted.json\")\n        accepted = json.loads(alternatives.read_text(encoding=\"utf-8\")) if alternatives.is_file() else {}\n    except (ValueError, OSError) as error:\n        raise SystemExit(str(error))\n    differences = list(compare(expected, actual, accepted=accepted))\n    if differences:\n        raise SystemExit(\"Different fields: \" + \", \".join(differences))\n    print(\"Pass\")\n\n\nif __name__ == \"__main__\":\n    main()\n"},{"path":"tests\/README.md","content":"Give your agent SKILL.md and one request.txt in a fresh session. Keep the expected answer aside. Save the reply as answer.json, then run this from the tests folder:\n\n    python3 check.py case-1\/expected.json answer.json\n\nEach case also has an explanation. Where accepted.json exists, the checker accepts the alternatives listed there.\n"},{"path":"tests\/case-1\/request.txt","content":"What does each finished portion cost in ingredients?\nReturn only the JSON specified in SKILL.md for this test.\n\nServes 4. Potatoes: \u00a32 per 1000 g as bought, 600 g peeled needed, measured yield 80%. Cheese: \u00a33 per 300 g, use 90 g. Chives: \u00a31 per 20 g, use 4 g.\n"},{"path":"tests\/case-1\/expected.json","content":"{\n    \"used_cost_gbp\": {\n        \"Potatoes\": 1.5,\n        \"Cheese\": 0.9,\n        \"Chives\": 0.2\n    },\n    \"batch_gbp\": 2.6,\n    \"per_portion_gbp\": 0.65,\n    \"buy_from_empty_gbp\": 6\n}\n"},{"path":"tests\/case-1\/explanation.txt","content":"The recipe consumes \u00a32.60, though buying whole packs from an empty kitchen costs \u00a36.\n"},{"path":"tests\/case-2\/request.txt","content":"Cost this trial batch using the actual yield.\nReturn only the JSON specified in SKILL.md for this test.\n\nMakes 5 saleable portions, not the 6 planned. Lentils \u00a32 per 500 g, use 250 g. Oil use 30 ml from a 500 ml bottle, price missing.\n"},{"path":"tests\/case-2\/expected.json","content":"{\n    \"used_cost_gbp\": {\n        \"Lentils\": 1,\n        \"Oil\": null\n    },\n    \"batch_gbp\": null,\n    \"per_portion_gbp\": null,\n    \"buy_from_empty_gbp\": null\n}\n"},{"path":"tests\/case-2\/explanation.txt","content":"The known lentil cost remains usable. Five portions do not justify guessing the oil cost.\n"},{"path":"tests\/case-3\/request.txt","content":"What's the ingredient cost per portion I can sell?\nReturn only the JSON specified in SKILL.md for this test.\n\nFish \u00a39 per 1.5 kg raw, 60% edible yield, 750 g edible fish used. Oil \u00a33 for 1 L, 100 mL used. Four portions made, one spoiled before sale.\n"},{"path":"tests\/case-3\/expected.json","content":"{\n    \"used_cost_gbp\": {\n        \"Fish\": 7.5,\n        \"Oil\": 0.3\n    },\n    \"batch_gbp\": 7.8,\n    \"per_portion_gbp\": 2.6,\n    \"buy_from_empty_gbp\": 12\n}\n"},{"path":"tests\/case-3\/explanation.txt","content":"The batch used 1.25 kg of raw fish. Three saleable portions carry the \u00a37.80 ingredient cost. From empty the two whole packs cost \u00a312.\n"}],"is_active":true,"is_approved":false}]}]}