Use this skill when a gift shop wants slow-selling stock marked down for a clearance rail: reading input.json items (sku, priceCents, weeks in stock) and writing clearance.csv with was/now clearance prices. Covers requests like 'work out clearance prices', 'markdown old stock', 'which items go on the clearance rail'. Not for general price changes or sales promotions.
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 Clearance Markdowns?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/gabrielmoreira-clearance-markdowns-453aa1d7)
---
name: clearance-markdowns
description: "Use this skill when a gift shop wants slow-selling stock marked down for a clearance rail: reading input.json items (sku, priceCents, weeks in stock) and writing clearance.csv with was/now clearance prices. Covers requests like 'work out clearance prices', 'markdown old stock', 'which items go on the clearance rail'. Not for general price changes or sales promotions."
---
# Clearance markdowns
Turn `input.json` (stock with ticket price and age) into `clearance.csv` (only items old enough, with their reduced price).
## Inputs
- `input.json` in the working folder: `{"items":[{"sku": string, "priceCents": integer, "weeks": integer}, ...]}`.
- If the file is missing or has no `items` array, stop and tell the user; do not invent data.
## Rules (all arithmetic is integer, in cents)
For each item, by `weeks`:
| weeks | Clearance? | nowCents |
|---|---|---|
| < 4 (including 0 or negative) | No: omit the item | n/a |
| 4 to 7 | Yes, 25% off | `floor(priceCents * 3 / 20) * 5` |
| >= 8 | Yes, 50% off | `floor(priceCents / 10) * 5` |
These are "75% of price, rounded DOWN to a multiple of 5 cents". Never round up or to nearest.
- Equivalent check: `nowCents = floor(priceCents * pct / 100 / 5) * 5` where pct = 75 or 50.
- Boundaries: 3 weeks is excluded, 4 is 75%, 7 is 75%, 8 is 50%.
- Do the multiplication first, then floor the division (do not pre-round 75% of the price).
## Steps
1. Read `input.json`.
2. Drop items with `weeks < 4`.
3. For each remaining item compute `nowCents` with the table.
4. Sort remaining rows by `sku`, ascending, plain character-code order (case-sensitive; e.g. `BAG` < `CAP` < `TEE`). Not input order.
5. Format money as `cents/100` with exactly two decimals, a dot, no currency symbol, no thousands separator: 899 -> `8.99`, 1200 -> `12.00`, 5 -> `0.05`. Compute with integer division: `floor(c/100)` + `.` + two-digit `c mod 100`.
6. Write `clearance.csv` next to `input.json`: first line `sku,was,now`, then one line per item `sku,was,now` where `was` is the original `priceCents` formatted. Use `\n` line endings, a trailing newline, no quotes, no spaces.
## Edge cases
- No qualifying items: write only the header line `sku,was,now`.
- Duplicate skus: keep each as its own row (stable order as in input).
- `weeks` or `priceCents` missing/non-integer on an item: skip that item and mention it in your reply.
- Price 0 gives `0.00,0.00`; a negative price: skip and mention it.
- Overwrite an existing `clearance.csv`.
## Worked example
Input items: TEE-31 1998c 4wk; MUG-07 1200c 3wk; SCF-12 2400c 8wk.
- TEE-31: 4 weeks -> `floor(1998*3/20)=floor(299.7)=299` -> 1495 -> `14.95`.
- MUG-07: 3 weeks -> omitted.
- SCF-12: 8 weeks -> `floor(2400/10)*5=1200` -> `12.00`.
```csv
sku,was,now
SCF-12,24.00,12.00
TEE-31,19.98,14.95
```
Verify before finishing: every `now` ends in 0 or 5 in the cents digit and is below `was`; rows are sorted; no item under 4 weeks appears.