Use this skill when a user wants late fees worked out for a tool library or lending scheme: reading returns of borrowed tools (tool, member, outDay, dueDays, backDay) from input.json and writing a per-member late-fees.csv of late tools and whole-pound fees. Not for other fee schemes, or for reports other than late-fees.csv.
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 Tool Return Fees?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/gabrielmoreira-tool-return-fees-9bfa3af4)
---
name: tool-return-fees
description: "Use this skill when a user wants late fees worked out for a tool library or lending scheme: reading returns of borrowed tools (tool, member, outDay, dueDays, backDay) from input.json and writing a per-member late-fees.csv of late tools and whole-pound fees. Not for other fee schemes, or for reports other than late-fees.csv."
---
# Tool return late fees
Compute per-member late fees from `input.json` and write `late-fees.csv` in the same folder. Do the arithmetic by hand, carefully; no scripts are needed.
## Input
`input.json` holds `returns`: an array of `{tool, member, outDay, dueDays, backDay}`. All day values are integers (day numbers / day counts). If the file or `returns` is missing, tell the user and write nothing.
## Rules (derived from the worked examples)
For each return:
- `dueDay = outDay + dueDays`
- `daysLate = backDay - dueDay`
- If `daysLate <= 0` the tool is on time: no fee, not counted as late. Returning exactly on the due day is on time.
- If `daysLate >= 1` the tool is late: `toolFee = min(daysLate, 5)` pounds (1 pound per day late, capped at 5 per tool).
Per member (match `member` exactly, case-sensitive):
- `late_tools` = number of that member's late returns
- `fee` = sum of their `toolFee` values (the cap applies per tool, not per member, so a member can owe more than 5)
## Steps
1. Read `input.json`.
2. For each return compute `dueDay`, `daysLate`, `toolFee` as above. Write the numbers down per return before summing.
3. Group late returns by member and compute `late_tools` and `fee`.
4. Drop members with no late tools.
5. Sort rows by `fee` descending; break ties by member name ascending (alphabetical, case-insensitive).
6. Write `late-fees.csv` beside `input.json`.
7. Re-check each member's sum and the sort order before finishing.
## Output format
- Header line exactly: `member,late_tools,fee`
- One row per member with at least one late tool: `name,count,fee` — integers only, no pound sign, no quotes (unless a name contains a comma or quote, then quote it CSV-style).
- Newline-separated lines, trailing newline at end.
- If nobody is late, write only the header line.
- Empty `returns` array: header only.
## Worked example
Returns: drill/Gil out 3 due 7 back 10 → due 10, on time. ladder/Dana out 1 due 7 back 16 → due 8, 8 late → capped 5. sander/Gil out 4 due 3 back 9 → due 7, 2 late → 2. jigsaw/Abel out 2 due 7 back 12 → due 9, 3 late → 3.
```csv
member,late_tools,fee
Dana,1,5
Abel,1,3
Gil,1,2
```
## Ambiguity
- Back day before out day or non-integer values: treat by the formulas (a negative `daysLate` is on time) and mention the oddity to the user.
- Missing field in a return: skip that return and tell the user.