Compute weekly garden-centre loyalty card points from input.json (purchases array of {member, cents}) and write loyalty-points.csv beside it. Use whenever asked for points earned by card holders, points card totals, or loyalty-points.csv, even if the rules are not restated.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Loyalty Points?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/gabrielmoreira-loyalty-points-16422295)
---
name: loyalty-points
description: Compute weekly garden-centre loyalty card points from input.json (purchases array of {member, cents}) and write loyalty-points.csv beside it. Use whenever asked for points earned by card holders, points card totals, or loyalty-points.csv, even if the rules are not restated.
---
# Loyalty points
You cannot run code, so do the arithmetic by hand, carefully, and write the file with the Write tool.
## Rules (derived from the worked examples)
Score **each purchase separately**, then add up per member:
1. `base = floor(cents / 100)` — whole currency units; drop the remainder (no rounding up). 899 → 8, 99 → 0, 4999 → 49.
2. If `cents >= 5000` (50.00 or more, inclusive), the purchase earns **double**: `points = base * 2`. 5000 → 100, 5099 → 100, 7500 → 150, 12050 → 240.
3. Otherwise `points = base`.
4. A member's total is the sum of their per-purchase points. Do not add cents together first and then floor: Ben's 5000 + 349 is 100 + 3 = 103, and the doubling applies only to the big purchase. Likewise the remainders of separate purchases are never combined.
## Steps
1. Read `input.json` from the working folder. Use `purchases[].member` and `purchases[].cents`.
2. For every purchase, write down member, cents, points per the rules above.
3. Sum by member. Treat names as exact strings (case-sensitive, no trimming changes). Every member who appears gets a row, including those with 0 points (e.g. a single 99-cent purchase).
4. Sort rows by points **descending**; break ties by member name **ascending** (alphabetical, e.g. Dee before Eve at 20 each).
5. Write `loyalty-points.csv` in the same folder as `input.json`:
- First line exactly `member,points`
- One line per member: `name,points` — integers only, no spaces, no quotes (quote a name only if it contains a comma or quote)
- Newline after each line, including the last
- If `purchases` is empty, the file contains just the header line.
6. Re-check: re-add each member's total once more, confirm the sort order and that the row count equals the number of distinct members.
## Check against the examples
- Ana 1299, 4250 → 12 + 42 = 54; Ben 5000, 349 → 100 + 3 = 103; Cal 899 → 8. Output order: Ben, Ana, Cal.
- Gus 99 → 0 still appears, last.
- Hal 5099, 450 → 100 + 4 = 104; Kai 4999 → 49 (just under the threshold, not doubled).