Skip to content
Back to skills

Loyalty Points

ASecurity

Use this skill when a garden centre (or similar shop) needs weekly points-card loyalty points worked out per card holder from a list of purchases (member, cents) in input.json, and written to loyalty-points.csv ranked by points.

  • 24 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 6, 2026
data

Security analysis

A100/100

Scanned December 6, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill loyalty-points --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Loyalty Points?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Loyalty Points
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-loyalty-points-5040cdbf/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-loyalty-points-5040cdbf)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: loyalty-points
description: "Use this skill when a garden centre (or similar shop) needs weekly points-card loyalty points worked out per card holder from a list of purchases (member, cents) in input.json, and written to loyalty-points.csv ranked by points."
---

# Loyalty points

Turn this week's purchases into a ranked points table per card holder.

## When to use
- `input.json` in the working folder has `purchases`: an array of `{ "member": string, "cents": integer }`, and the user wants `loyalty-points.csv` beside it.
- Not for other reward schemes, other file formats, or inputs without this shape (tell the user instead of guessing).

## Rules (exact)
For each purchase:
- `base = floor(cents / 100)` (whole currency units paid; cents are dropped, never rounded up).
- `points = base * 2` if `cents >= 5000`, otherwise `points = base`.
- Rate is applied per purchase, never to a member's combined total.
- If `cents < 0` (refund) or `base` is 0, the purchase earns 0 points (never negative).

A member's points = sum of `points` over all their purchases. Members are matched by exact `member` string (case-sensitive; do not trim or merge variants).

## Steps
1. Read `input.json`.
2. For each purchase compute `points` with the rules above. Do the arithmetic carefully, writing each purchase's value down.
3. Sum per member. Every member who appears gets a row, even with 0 points.
4. Sort by points descending; ties by member name ascending (plain character order).
5. Write `loyalty-points.csv` beside `input.json` (overwrite if present):
   - First line exactly `member,points`.
   - One line per member: `name,points` (integer, no decimals), `\n` line endings, trailing newline.
   - If a name contains a comma, quote or newline, wrap in double quotes and double inner quotes.
   - If `purchases` is empty, write only the header line.
6. Re-read the file and re-check sums and ordering.

## Worked example
Purchases: Ana 1299, Ben 5000, Ana 4250, Cal 899, Ben 349.
- Ana: 12 + 42 = 54. Ben: 5000 → 50×2 = 100, 349 → 3, total 103. Cal: 8.

```csv
member,points
Ben,103
Ana,54
Cal,8
```

Edge: Hal 5099 and 450 → 50×2 + 4 = 104 (floor first, then double). Kai 4999 → 49 (below 5000, no doubling).

## Missing or odd input
- If `input.json` or `purchases` is missing, stop and report it; do not invent data.
- A non-integer `cents`: use `floor(cents / 100)` on the value as given and mention it in your reply.
- A purchase lacking `member` or `cents`: skip it and tell the user.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in data →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.