{"skills":[{"name":"Compare grocery offers by unit price","description":"Work out which comparable pack gives the lowest price per 100 g, 100 ml or item at the price you can actually pay.","content":"# Compare grocery offers by unit price\n\nWork out which comparable pack gives the lowest price per 100 g, 100 ml or item at the price you can actually pay.\n\n## When to use this skill\n\n- Someone is choosing between pack sizes, brands or shops and wants the cheapest per kilo, litre or item.\n- A multibuy, 'two for' or loyalty-card price is on offer and the shopper wants to know whether it is better value for them.\n- Tinned or jarred food shows both net and drained weight and the person wants a fair comparison.\n\n## When not to use it\n\n- Judging quality, nutrition or whether two products are genuinely interchangeable.\n- Deciding whether a shop's label breaks price marking law. In Great Britain trading standards enforce the Price Marking Order; the skill only does the arithmetic.\n\n## What you need\n\n- Pack weights, volumes or counts and the prices available to this shopper.\n- Promotion quantity, eligibility and any stated basis such as drained weight.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- Which unit should the comparison use: per 100 g, per kg, per litre or per item? Shelf labels in Great Britain show per kg, per litre or per item, so other bases need converting.\n- How many packs will you actually buy and use? A multibuy only counts if you will buy and use the whole bundle.\n- Do you hold the loyalty card or membership that any member price needs?\n- For tins and jars, should the comparison use drained weight? If so, every option needs its drained weight.\n\n## Method\n\n1. Choose one basis before dividing: weight, volume or count, and drained weight for solid food in liquid when the person asks for it. Use the same basis for every option and never mix weight with volume.\n2. For each option, find the purchase with the lowest unit price the shopper can use: a single pack, or a multibuy bundle only if they can buy and use that many, taking the smallest quantity that gets that price. A loyalty price counts only if they hold the card. If they need an exact number of packs, price that many using whole bundles plus singles.\n3. Convert units consistently, for example grams to kilograms, add up the total quantity bought and divide the till price by it. Keep full precision until the comparison is made, then round for display.\n4. If a required quantity is missing, such as an unstated drained weight, leave that option's unit price unknown and do not name a cheapest option.\n5. Recalculate rather than copy a shelf label's unit price. The label may show the single price only, or a different basis from the one the person asked for.\n6. Give the till total as well as the unit price, and say plainly when the better unit price needs a bigger spend or when a different option is cheaper at the till.\n\n## Checks before you deliver\n\n- The regular shelf unit price may not reflect a loyalty offer.\n- A 400 g tin weight and a 240 g drained weight refer to different quantities. Comparing them as if identical favours the wetter product.\n- A multibuy the shopper cannot use, such as three jars when they need two, is not a saving.\n- Rounding unit prices before comparing can create a false tie or reverse a close result.\n- Comparing a per 100 g figure on one label with a per kg figure on another without converting.\n\n## How to present the result\n\nLead with the cheapest option on the basis the person asked for, with its unit price and till cost. Then give a short table: option, quantity bought, till total and unit price. If the better unit price needs a bigger spend or a multibuy, say so plainly, and name any option that cannot be compared and the figure that is missing.\n\n## Worked example\n\n**Request:** Find the cheapest oats per 100 g. I can buy up to two packs.\n\n**Supplied material:**\n\n```text\nRed: 450 g \u00a31.35 each. Blue: 350 g \u00a31.20 each, or two for \u00a32.00. No loyalty card required.\n```\n\n**Answer:** Two Blue packs give you 700 g for \u00a32, about 28.57p per 100 g. Red is 30p per 100 g but costs only \u00a31.35 at the till for its 450 g pack.\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\nFor each labelled offer give basket_gbp and unit_gbp as objects keyed by offer, using the requested unit and rounding unit prices to four decimal places. Use null for an unavailable quantity. Return cheapest as the offer name, 'tie', or null if any required comparison is incomplete. cheapest refers to unit price at the eligible basket quantity. When the request compares till totals as well, return lowest_till_total as the offer name, tie or null. In the ordinary shopping advice, explain the difference between outlay and unit price.\n\n## Sources\n\n- [GOV.UK: Price Marking Order 2004 government guidance](https:\/\/www.gov.uk\/government\/publications\/price-marking-order-2004-government-guidance\/price-marking-order-2004-government-guidance): Guidance for Great Britain on the order as amended from 6 April 2026. Unit prices are per kilogram, litre or item; where a loyalty price applies, each selling price and its unit price must be shown; and for solid food in a liquid medium the unit price must refer to the drained net weight. Northern Ireland has its own order.\n- [Competition and Markets Authority: unit pricing](https:\/\/www.gov.uk\/government\/publications\/unit-pricing-information-for-consumers\/unit-pricing-information-for-consumers): The CMA explains how to compare products by unit price per weight, volume or item and shows that a bigger pack can cost more per unit. It dates from 2015, so the units on labels now follow the 2026 rules above.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/compare-grocery-unit-prices\n","scope":"contextual","trigger_keywords":["Compare grocery offers by unit price","compare-grocery-unit-prices","compare grocery unit prices","Which pack of oats is cheapest per kilo?","Which pack of oats is cheapest per kilo","compare supermarket unit prices","cheaper per kilo","cheapest per kilo","cheaper per kilogram","compare these supermarket prices"],"is_private":true,"is_active":true,"scripts":[{"name":"compare-grocery-unit-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":"compare-grocery-unit-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: compare-grocery-unit-prices\ndescription: \"Compare grocery offers on price per kilogram, litre, 100 g or item, using drained weight where it applies and only the multibuy or loyalty prices the shopper can actually use. Use when someone asks which pack is cheaper per kilo, whether a multibuy is worth it, or how two shops' unit prices compare.\"\nlicense: CC-BY-4.0\nmetadata:\n  author: Raq.com\n  version: \"2026-11-23\"\n  homepage: https:\/\/skills.raq.com\/skills\/compare-grocery-unit-prices\n---\n\n# Compare grocery offers by unit price\n\nWork out which comparable pack gives the lowest price per 100 g, 100 ml or item at the price you can actually pay.\n\n## When to use this skill\n\n- Someone is choosing between pack sizes, brands or shops and wants the cheapest per kilo, litre or item.\n- A multibuy, 'two for' or loyalty-card price is on offer and the shopper wants to know whether it is better value for them.\n- Tinned or jarred food shows both net and drained weight and the person wants a fair comparison.\n\n## When not to use it\n\n- Judging quality, nutrition or whether two products are genuinely interchangeable.\n- Deciding whether a shop's label breaks price marking law. In Great Britain trading standards enforce the Price Marking Order; the skill only does the arithmetic.\n\n## What you need\n\n- Pack weights, volumes or counts and the prices available to this shopper.\n- Promotion quantity, eligibility and any stated basis such as drained weight.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- Which unit should the comparison use: per 100 g, per kg, per litre or per item? Shelf labels in Great Britain show per kg, per litre or per item, so other bases need converting.\n- How many packs will you actually buy and use? A multibuy only counts if you will buy and use the whole bundle.\n- Do you hold the loyalty card or membership that any member price needs?\n- For tins and jars, should the comparison use drained weight? If so, every option needs its drained weight.\n\n## Method\n\n1. Choose one basis before dividing: weight, volume or count, and drained weight for solid food in liquid when the person asks for it. Use the same basis for every option and never mix weight with volume.\n2. For each option, find the purchase with the lowest unit price the shopper can use: a single pack, or a multibuy bundle only if they can buy and use that many, taking the smallest quantity that gets that price. A loyalty price counts only if they hold the card. If they need an exact number of packs, price that many using whole bundles plus singles.\n3. Convert units consistently, for example grams to kilograms, add up the total quantity bought and divide the till price by it. Keep full precision until the comparison is made, then round for display.\n4. If a required quantity is missing, such as an unstated drained weight, leave that option's unit price unknown and do not name a cheapest option.\n5. Recalculate rather than copy a shelf label's unit price. The label may show the single price only, or a different basis from the one the person asked for.\n6. Give the till total as well as the unit price, and say plainly when the better unit price needs a bigger spend or when a different option is cheaper at the till.\n\n## Checks before you deliver\n\n- The regular shelf unit price may not reflect a loyalty offer.\n- A 400 g tin weight and a 240 g drained weight refer to different quantities. Comparing them as if identical favours the wetter product.\n- A multibuy the shopper cannot use, such as three jars when they need two, is not a saving.\n- Rounding unit prices before comparing can create a false tie or reverse a close result.\n- Comparing a per 100 g figure on one label with a per kg figure on another without converting.\n\n## How to present the result\n\nLead with the cheapest option on the basis the person asked for, with its unit price and till cost. Then give a short table: option, quantity bought, till total and unit price. If the better unit price needs a bigger spend or a multibuy, say so plainly, and name any option that cannot be compared and the figure that is missing.\n\n## Worked example\n\n**Request:** Find the cheapest oats per 100 g. I can buy up to two packs.\n\n**Supplied material:**\n\n```text\nRed: 450 g \u00a31.35 each. Blue: 350 g \u00a31.20 each, or two for \u00a32.00. No loyalty card required.\n```\n\n**Answer:** Two Blue packs give you 700 g for \u00a32, about 28.57p per 100 g. Red is 30p per 100 g but costs only \u00a31.35 at the till for its 450 g pack.\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\nFor each labelled offer give basket_gbp and unit_gbp as objects keyed by offer, using the requested unit and rounding unit prices to four decimal places. Use null for an unavailable quantity. Return cheapest as the offer name, 'tie', or null if any required comparison is incomplete. cheapest refers to unit price at the eligible basket quantity. When the request compares till totals as well, return lowest_till_total as the offer name, tie or null. In the ordinary shopping advice, explain the difference between outlay and unit price.\n\n## Sources\n\n- [GOV.UK: Price Marking Order 2004 government guidance](https:\/\/www.gov.uk\/government\/publications\/price-marking-order-2004-government-guidance\/price-marking-order-2004-government-guidance): Guidance for Great Britain on the order as amended from 6 April 2026. Unit prices are per kilogram, litre or item; where a loyalty price applies, each selling price and its unit price must be shown; and for solid food in a liquid medium the unit price must refer to the drained net weight. Northern Ireland has its own order.\n- [Competition and Markets Authority: unit pricing](https:\/\/www.gov.uk\/government\/publications\/unit-pricing-information-for-consumers\/unit-pricing-information-for-consumers): The CMA explains how to compare products by unit price per weight, volume or item and shows that a bigger pack can cost more per unit. It dates from 2015, so the units on labels now follow the 2026 rules above.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/compare-grocery-unit-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\/compare-grocery-unit-prices\nReferenced third-party materials retain their own terms.\n"},{"path":"examples\/worked-example.md","content":"# A multibuy the shopper can use\n\nFind the cheapest oats per 100 g. I can buy up to two packs.\n\n## Supplied material\n\nRed: 450 g \u00a31.35 each. Blue: 350 g \u00a31.20 each, or two for \u00a32.00. No loyalty card required.\n\n## Worked answer\n\nTwo Blue packs give you 700 g for \u00a32, about 28.57p per 100 g. Red is 30p per 100 g but costs only \u00a31.35 at the till for its 450 g pack.\n\n## Reasoning\n\nBlue costs more at the till but supplies 700 g at the lower unit price.\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":"Find the cheapest oats per 100 g. I can buy up to two packs.\nReturn only the JSON specified in SKILL.md for this test.\n\nRed: 450 g \u00a31.35 each. Blue: 350 g \u00a31.20 each, or two for \u00a32.00. No loyalty card required.\n"},{"path":"tests\/case-1\/expected.json","content":"{\n    \"basket_gbp\": {\n        \"Red\": 1.35,\n        \"Blue\": 2\n    },\n    \"unit_gbp\": {\n        \"Red\": 0.3,\n        \"Blue\": 0.2857\n    },\n    \"cheapest\": \"Blue\"\n}\n"},{"path":"tests\/case-1\/explanation.txt","content":"Blue costs more at the till but supplies 700 g at the lower unit price.\n"},{"path":"tests\/case-2\/request.txt","content":"Compare these beans on drained weight per 100 g.\nReturn only the JSON specified in SKILL.md for this test.\n\nNorth: 400 g tin, 240 g drained, 72p. South: 425 g tin, no drained weight supplied, 76p.\n"},{"path":"tests\/case-2\/expected.json","content":"{\n    \"basket_gbp\": {\n        \"North\": 0.72,\n        \"South\": 0.76\n    },\n    \"unit_gbp\": {\n        \"North\": 0.3,\n        \"South\": null\n    },\n    \"cheapest\": null\n}\n"},{"path":"tests\/case-2\/explanation.txt","content":"South cannot be compared until its drained quantity is known.\n"},{"path":"tests\/case-3\/request.txt","content":"I need exactly two jars, with no use for a third. Compare cost per drained kg and the till total.\nReturn only the JSON specified in SKILL.md for this test.\n\nVale \u00a31.90 per jar or 3 for \u00a34.80, 400 g net but 240 g drained per jar. Mill \u00a32 each, 300 g drained. Both single prices available.\n"},{"path":"tests\/case-3\/expected.json","content":"{\n    \"basket_gbp\": {\n        \"Vale\": 3.8,\n        \"Mill\": 4\n    },\n    \"unit_gbp\": {\n        \"Vale\": 7.9167,\n        \"Mill\": 6.6667\n    },\n    \"cheapest\": \"Mill\",\n    \"lowest_till_total\": \"Vale\"\n}\n"},{"path":"tests\/case-3\/explanation.txt","content":"Mill has the cheaper drained kilogram. Two Vale jars cost 20p less at the till and supply 120 g less food.\n"}],"is_active":true,"is_approved":false}]}]}