Use this skill when an office manager needs to share out limited stationery or supplies from a cupboard: working out how much each person gets when requests exceed stock, from an input.json with stock and requests, and writing stationery-issued.csv. Not for ordering new stock or general inventory reports.
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 Stationery Issue?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/gabrielmoreira-stationery-issue-57000cdf)
---
name: stationery-issue
description: "Use this skill when an office manager needs to share out limited stationery or supplies from a cupboard: working out how much each person gets when requests exceed stock, from an input.json with stock and requests, and writing stationery-issued.csv. Not for ordering new stock or general inventory reports."
---
# Stationery issue
Allocate cupboard stock to requests and write `stationery-issued.csv` next to `input.json`.
## Input
`input.json` in the working folder:
- `stock`: array of `{item, quantity}`.
- `requests`: array of `{person, item, quantity}` in arrival order.
Items are in stock, quantities are whole numbers, and names match exactly. If `input.json` is missing or unreadable, stop and tell the user. Do not guess data.
## Rules
1. **Combine per person and item.** For each (item, person) pair, `asked` = sum of all that person's request quantities for that item. A pair's position is the arrival index of its **first** request.
2. **Allocate per item, first come first served by pair position.** Start with `remaining` = stock quantity. For each pair of that item in position order:
`issued = min(asked, remaining)`, then `remaining = remaining - issued`.
Combining comes first: a person's later request counts at their first position (so it can beat someone who asked in between).
3. A zero `issued` is still a row. If `asked` is 0, `issued` is 0. Never issue negatives; `remaining` never goes below 0.
## Output
Write `stationery-issued.csv` beside `input.json` (overwrite if present):
- Header line exactly: `item,person,asked,issued`
- One row per (item, person) pair.
- Row order: items in `stock` order; within an item, pairs in position order (rule 1).
- Omit items with no requests (no rows).
- Plain values, no spaces after commas, `\n` line endings, newline after last row. Wrap a value in double quotes only if it contains a comma or quote (double any inner quote).
## Steps
1. Read `input.json`.
2. Build the pairs by walking `requests` in order, summing duplicates and noting first positions.
3. For each stock item in order, allocate per rule 2 and emit rows.
4. Write the CSV, then re-read it and check: row count equals number of distinct pairs, and per item `sum(issued) <= stock` and `issued <= asked`.
## Worked example
Stock: pens 10. Requests: amy 4, liv 5, amy 3 (all pens).
- amy: asked 7 (position 1); liv: asked 5 (position 2).
- amy issued min(7,10)=7, remaining 3; liv issued min(5,3)=3.
```csv
item,person,asked,issued
pens,amy,7,7
pens,liv,5,3
```