{"skills":[{"name":"Compare two spreadsheet versions","description":"Match rows by a stable key and produce a cell-level change list even when records have moved or a key has been reused.","content":"# Compare two spreadsheet versions\n\nMatch rows by a stable key and produce a cell-level change list even when records have moved or a key has been reused.\n\n## When to use this skill\n\n- Someone has an old and a new version of a spreadsheet, price list or export and wants a list of changes.\n- Rows have been reordered, inserted or deleted, so a row-by-row comparison would show false differences.\n- A formula may have changed even though the displayed values look the same.\n\n## When not to use it\n\n- Merging the two versions or deciding which change is right. The skill reports differences for the owner to decide.\n- Auditing the formulas within one version. Use the spreadsheet formula audit skill.\n\n## What you need\n\n- Two labelled tables with column names and a declared row key.\n- Which columns to compare and any explicit type or equivalence rules.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- Which column or columns identify the same record in both versions, such as an order number or SKU?\n- Which columns matter, and have any been renamed, added or removed between versions?\n- Should formulas be compared, or only the displayed values? A values-only export cannot show a formula change.\n\n## Method\n\n1. Keep the original values. Confirm which sheet, columns and key parts describe the same record in both versions. For a composite key, compare the parts separately.\n2. Map columns by name, not position. Resolve renamed, added and removed columns with the owner before comparing, and report under the original name when asked. A missing column is not the same as a blank cell.\n3. Index each version by key. Set aside every key that appears more than once on either side before computing differences, and ask for another identifier when a key is blank.\n4. For the remaining keys, report rows present on only one side. For a shared key, compare the requested columns as text exactly as displayed, preserving identifiers, unless a type rule explicitly allows a conversion.\n5. If formula changes matter, compare the formula text as well as the displayed or calculated values. A changed input can change many calculated cells, so trace each difference back to the cell that was edited.\n6. Check that unique matched, added, removed and ambiguous keys account for every row in both versions. A row that only moved contributes no changed cells.\n\n## Checks before you deliver\n\n- Repeated customer names can describe separate orders. A matching row number provides no evidence that two orders are the same.\n- A missing column has a different meaning from a blank cell. Resolve header changes before comparing values.\n- Comparing by row position. One inserted row makes every later row look changed.\n- Converting values before comparing. 8.50 and 8.5, or 007 and 7, are equal as numbers but different as displayed text; follow the stated comparison rule.\n- Matching one of several rows that share a key. Choosing either row manufactures a match.\n\n## How to present the result\n\nLead with counts of rows added, removed, changed and set aside as ambiguous. Then give the change table sorted by key and column with before and after values, followed by the added and removed keys and the duplicated keys that need a better identifier. Mention rows that only moved, so nobody looks for a change that is not there.\n\n## Worked example\n\n**Request:** Compare price by sku, using display values.\n\n**Supplied material:**\n\n```text\nBefore\nsku,price\nA01,8.50\nB02,4.00\nC03,7.00\nAfter\nsku,price\nC03,7.00\nA01,9.00\nD04,1.50\n```\n\n**Answer:** A01 changed from 8.50 to 9.00. B02 was removed and D04 was added. C03 moved rows and kept its price of 7.00.\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 added, removed and ambiguous as sorted lists of text keys. Return changed as objects with key, column, before and after, sorted by key then column. For display-value comparisons return before and after as strings. For a formula comparison return the original formula strings including the equals sign.\n\n## Sources\n\n- [W3C: Metadata vocabulary for tabular data](https:\/\/www.w3.org\/TR\/tabular-metadata\/): The primaryKey property requires each row to have a unique combination of key values, and column metadata says how values are interpreted. This is why the skill sets aside duplicated keys instead of guessing a match.\n- [Microsoft: Basic tasks in Spreadsheet Compare](https:\/\/support.microsoft.com\/en-us\/excel\/basic-tasks-in-spreadsheet-compare): Spreadsheet Compare lets the user include formulas in a comparison and colours entered values and changed calculated values differently. Its worked example shows a corrected formula changing a calculated total, and Microsoft suggests the tool for finding manually entered totals and broken formulas.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/compare-spreadsheet-versions\n","scope":"contextual","trigger_keywords":["Compare two spreadsheet versions","compare-spreadsheet-versions","compare spreadsheet versions","What changed between last month\u2019s price list and this one?","What changed between last month\u2019s price list and this one","compare these spreadsheets","diff these spreadsheets","compare these workbook versions"],"is_private":true,"is_active":true,"scripts":[{"name":"compare-spreadsheet-versions-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-spreadsheet-versions-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-spreadsheet-versions\ndescription: \"Compare two versions of a spreadsheet or table by a stable row key, list added, removed and changed cells, and set aside keys that are duplicated. Use when someone asks what changed between two workbooks, exports, price lists or registers.\"\nlicense: CC-BY-4.0\nmetadata:\n  author: Raq.com\n  version: \"2026-11-22\"\n  homepage: https:\/\/skills.raq.com\/skills\/compare-spreadsheet-versions\n---\n\n# Compare two spreadsheet versions\n\nMatch rows by a stable key and produce a cell-level change list even when records have moved or a key has been reused.\n\n## When to use this skill\n\n- Someone has an old and a new version of a spreadsheet, price list or export and wants a list of changes.\n- Rows have been reordered, inserted or deleted, so a row-by-row comparison would show false differences.\n- A formula may have changed even though the displayed values look the same.\n\n## When not to use it\n\n- Merging the two versions or deciding which change is right. The skill reports differences for the owner to decide.\n- Auditing the formulas within one version. Use the spreadsheet formula audit skill.\n\n## What you need\n\n- Two labelled tables with column names and a declared row key.\n- Which columns to compare and any explicit type or equivalence rules.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- Which column or columns identify the same record in both versions, such as an order number or SKU?\n- Which columns matter, and have any been renamed, added or removed between versions?\n- Should formulas be compared, or only the displayed values? A values-only export cannot show a formula change.\n\n## Method\n\n1. Keep the original values. Confirm which sheet, columns and key parts describe the same record in both versions. For a composite key, compare the parts separately.\n2. Map columns by name, not position. Resolve renamed, added and removed columns with the owner before comparing, and report under the original name when asked. A missing column is not the same as a blank cell.\n3. Index each version by key. Set aside every key that appears more than once on either side before computing differences, and ask for another identifier when a key is blank.\n4. For the remaining keys, report rows present on only one side. For a shared key, compare the requested columns as text exactly as displayed, preserving identifiers, unless a type rule explicitly allows a conversion.\n5. If formula changes matter, compare the formula text as well as the displayed or calculated values. A changed input can change many calculated cells, so trace each difference back to the cell that was edited.\n6. Check that unique matched, added, removed and ambiguous keys account for every row in both versions. A row that only moved contributes no changed cells.\n\n## Checks before you deliver\n\n- Repeated customer names can describe separate orders. A matching row number provides no evidence that two orders are the same.\n- A missing column has a different meaning from a blank cell. Resolve header changes before comparing values.\n- Comparing by row position. One inserted row makes every later row look changed.\n- Converting values before comparing. 8.50 and 8.5, or 007 and 7, are equal as numbers but different as displayed text; follow the stated comparison rule.\n- Matching one of several rows that share a key. Choosing either row manufactures a match.\n\n## How to present the result\n\nLead with counts of rows added, removed, changed and set aside as ambiguous. Then give the change table sorted by key and column with before and after values, followed by the added and removed keys and the duplicated keys that need a better identifier. Mention rows that only moved, so nobody looks for a change that is not there.\n\n## Worked example\n\n**Request:** Compare price by sku, using display values.\n\n**Supplied material:**\n\n```text\nBefore\nsku,price\nA01,8.50\nB02,4.00\nC03,7.00\nAfter\nsku,price\nC03,7.00\nA01,9.00\nD04,1.50\n```\n\n**Answer:** A01 changed from 8.50 to 9.00. B02 was removed and D04 was added. C03 moved rows and kept its price of 7.00.\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 added, removed and ambiguous as sorted lists of text keys. Return changed as objects with key, column, before and after, sorted by key then column. For display-value comparisons return before and after as strings. For a formula comparison return the original formula strings including the equals sign.\n\n## Sources\n\n- [W3C: Metadata vocabulary for tabular data](https:\/\/www.w3.org\/TR\/tabular-metadata\/): The primaryKey property requires each row to have a unique combination of key values, and column metadata says how values are interpreted. This is why the skill sets aside duplicated keys instead of guessing a match.\n- [Microsoft: Basic tasks in Spreadsheet Compare](https:\/\/support.microsoft.com\/en-us\/excel\/basic-tasks-in-spreadsheet-compare): Spreadsheet Compare lets the user include formulas in a comparison and colours entered values and changed calculated values differently. Its worked example shows a corrected formula changing a calculated total, and Microsoft suggests the tool for finding manually entered totals and broken formulas.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/compare-spreadsheet-versions\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-spreadsheet-versions\nReferenced third-party materials retain their own terms.\n"},{"path":"examples\/worked-example.md","content":"# Prices after a reorder\n\nCompare price by sku, using display values.\n\n## Supplied material\n\nBefore\nsku,price\nA01,8.50\nB02,4.00\nC03,7.00\nAfter\nsku,price\nC03,7.00\nA01,9.00\nD04,1.50\n\n## Worked answer\n\nA01 changed from 8.50 to 9.00. B02 was removed and D04 was added. C03 moved rows and kept its price of 7.00.\n\n## Reasoning\n\nC03 has moved to the first row. Its price is identical.\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":"Compare price by sku, using display values.\nReturn only the JSON specified in SKILL.md for this test.\n\nBefore\nsku,price\nA01,8.50\nB02,4.00\nC03,7.00\nAfter\nsku,price\nC03,7.00\nA01,9.00\nD04,1.50\n"},{"path":"tests\/case-1\/expected.json","content":"{\n    \"added\": [\n        \"D04\"\n    ],\n    \"removed\": [\n        \"B02\"\n    ],\n    \"ambiguous\": [],\n    \"changed\": [\n        {\n            \"key\": \"A01\",\n            \"column\": \"price\",\n            \"before\": \"8.50\",\n            \"after\": \"9.00\"\n        }\n    ]\n}\n"},{"path":"tests\/case-1\/explanation.txt","content":"C03 has moved to the first row. Its price is identical.\n"},{"path":"tests\/case-2\/request.txt","content":"Compare status by order, using display values.\nReturn only the JSON specified in SKILL.md for this test.\n\nBefore\norder,status\n007,new\n008,new\nAfter\norder,status\n008,new\n007,paid\n007,new\n"},{"path":"tests\/case-2\/expected.json","content":"{\n    \"added\": [],\n    \"removed\": [],\n    \"ambiguous\": [\n        \"007\"\n    ],\n    \"changed\": []\n}\n"},{"path":"tests\/case-2\/explanation.txt","content":"Choosing either of the two new rows would manufacture a match.\n"},{"path":"tests\/case-3\/request.txt","content":"Compare the fee formulas by order. The owner confirms fee was renamed handling. The exports include formula text.\nReturn only the JSON specified in SKILL.md for this test.\n\nBefore: R1 fee =2+3, R4 fee =4, R4 fee =9.\nAfter (reordered): R4 handling =9, R1 handling =1+4, R4 handling =4. Both R1 values display 5. Report the column under its original name.\n"},{"path":"tests\/case-3\/expected.json","content":"{\n    \"added\": [],\n    \"removed\": [],\n    \"ambiguous\": [\n        \"R4\"\n    ],\n    \"changed\": [\n        {\n            \"key\": \"R1\",\n            \"column\": \"fee\",\n            \"before\": \"=2+3\",\n            \"after\": \"=1+4\"\n        }\n    ]\n}\n"},{"path":"tests\/case-3\/explanation.txt","content":"R1 has a formula edit even though the result stayed the same. The two R4 records need a more specific key.\n"}],"is_active":true,"is_approved":false}]}]}