Skip to content
Back to skills

Gift Card Ledger

ASecurity

Replay a day of gift card load/spend events from input.json against starting card balances, enforcing a card limit, and write card-balances.csv and declined.json. Use whenever the user mentions gift cards, card loads/spends, limitCents, till events, a daily card ledger/replay, or card-balances.csv / declined.json, even if they don't name this skill.

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

Works with

  • cli

Security analysis

A100/100

Scanned December 6, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill gift-card-ledger --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Gift Card Ledger?

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

Security grade badge for Gift Card Ledger
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-gift-card-ledger-367a77fa/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-gift-card-ledger-367a77fa)

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: gift-card-ledger
description: Replay a day of gift card load/spend events from input.json against starting card balances, enforcing a card limit, and write card-balances.csv and declined.json. Use whenever the user mentions gift cards, card loads/spends, limitCents, till events, a daily card ledger/replay, or card-balances.csv / declined.json, even if they don't name this skill.
---

# Gift card ledger replay

You cannot run code, so do the work by careful reading and hand calculation. All arithmetic is in integer cents; convert to dollars only when writing the CSV. This avoids rounding errors.

## Input (input.json, in the working folder)
- `limitCents`: max balance a card may hold.
- `cards`: `[{card, balanceCents}]`, every issued card (card is an 8-digit string; keep it as text, preserving leading zeros).
- `events`: `[{seq, card, type, cents}]`, to be applied in the listed order. Do NOT sort by seq or card; the array order is the order applied (seq may be non-monotonic).

## Procedure
1. Read input.json. Build a working table: card -> current balance (cents), initialised from `cards`.
2. For each event, in array order, decide using the *current* balance (earlier events in the day change it):
   - Card not in the table: declined, no change (never open a new card).
   - `load`: if balance + cents <= limitCents, accept (balance += cents; landing exactly on the limit is OK). Otherwise decline whole: no change, no partial top-up.
   - `spend`: if cents <= balance, accept (balance -= cents; exactly the balance leaves 0). Otherwise decline whole: no change, no partial payment.
   - A declined event does not stop later events; a later smaller event on the same card may still be accepted.
   - Record the seq of every declined event, in order applied.
3. For long inputs, work card by card in a scratch note file (e.g. `scratch.txt` in the working folder) listing each event as `seq type cents -> balance` or `seq DECLINED`, so you can recheck. Delete nothing needed; extra scratch files are fine but don't alter input.json.
4. Recheck: every card's final balance must be between 0 and limitCents, and equal start + accepted loads - accepted spends.

## Outputs (same folder as input.json)
**card-balances.csv**
- Header exactly `card,balance`, then one row per card in `cards` (including cards with no events), no blank trailing rows beyond the final newline.
- Order by card number ascending (all 8 digits, so string order equals numeric order). Not the order in `cards`.
- balance = final cents as dollars with exactly two decimals, no currency sign, no thousands separators: cents/100 with the last two digits as decimals. Pad: 5 -> `0.05`, 100 -> `1.00`, 123456 -> `1234.56`, 0 -> `0.00`.
- Card written as the original 8-char string.

**declined.json**
- A JSON array of seq numbers (numbers, not strings) of declined events in the order applied, e.g. `[3,7,12]`; `[]` if none.

## Example
limit 50000, card holds 48000 cents: load 2000 -> accepted (50000); load 1 -> declined; spend 60000 -> declined; ends at `500.00`.

## Pitfalls
- Judge against the running balance, not the starting balance.
- Unknown cards are declined and are NOT added to the CSV.
- Don't use floating-point dollars; stay in cents.
- Duplicate card entries in `cards` are not expected; if they occur, keep one row per distinct listed card and mention it.

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 tools →

Comments

Loading comments…

Newsletter

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