Use this skill when a tool library, lending library or similar borrowing scheme needs late return fees worked out per member from an input.json of returns (tool, member, outDay, dueDays, backDay) and written to late-fees.csv. Covers late tools, overdue days, whole-pound fees and member summaries. Not for fines on other schemes or for non-fee 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 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-3f0be25a)
---
name: tool-return-fees
description: "Use this skill when a tool library, lending library or similar borrowing scheme needs late return fees worked out per member from an input.json of returns (tool, member, outDay, dueDays, backDay) and written to late-fees.csv. Covers late tools, overdue days, whole-pound fees and member summaries. Not for fines on other schemes or for non-fee reports."
---
# Tool return late fees
Turn `input.json` into `late-fees.csv`, one row per member who returned at least one tool late. Work by reading the file and computing by hand; no commands are needed.
## Input
`input.json` in the working folder (the same folder the output goes in):
`{"returns": [{"tool", "member", "outDay", "dueDays", "backDay"}, ...]}`. Days are integer day numbers.
## Rules (per returned tool)
- `dueDay = outDay + dueDays`
- `daysLate = backDay - dueDay`
- If `daysLate <= 0` the tool is on time: fee 0, not counted as late. Returning exactly on the due day is on time. Negative values (early return) are also on time.
- If `daysLate >= 1`: `toolFee = min(daysLate, 5)` pounds (£1 per day late, capped at £5 per tool).
- The cap applies to each tool separately, never to a member's total (a member can owe more than 5).
## Per member
- `late_tools` = number of that member's tools with `daysLate >= 1`.
- `fee` = sum of that member's `toolFee` values.
- Group by the `member` string exactly as written (case-sensitive; do not merge variants unless they differ only in leading/trailing spaces, which you trim).
- Omit members with `late_tools = 0` entirely.
## Output: `late-fees.csv`
- Header line exactly: `member,late_tools,fee`
- One row per member, integers only (no £ sign, no decimals).
- Sort by `fee` descending; ties broken by `member` ascending (alphabetical, A–Z). Do not sort by late_tools.
- Lines end with a newline; no blank lines, no extra columns. If no member is late, write only the header line.
- Quote a member name only if it contains a comma or quote (standard CSV).
## Steps
1. Read `input.json`.
2. For each return, compute `dueDay`, `daysLate`, `toolFee`; write them down in a working list.
3. Total per member; drop members with no late tools.
4. Sort as above.
5. Write `late-fees.csv` beside `input.json`, then re-read it and recheck each row's arithmetic.
## Edge cases
- Empty `returns`: header only.
- Missing or non-numeric field in a record: skip that record and mention it in your reply; do not guess values.
- Do not ask questions; apply the rules above.
## Worked example
Returns: drill Gil out 3 due 7 back 10 → dueDay 10, late 0. Ladder Dana out 1 due 7 back 16 → dueDay 8, late 8 → fee 5. Sander Gil out 4 due 3 back 9 → dueDay 7, late 2 → fee 2. Jigsaw Abel out 2 due 7 back 12 → dueDay 9, late 3 → fee 3.
```csv
member,late_tools,fee
Dana,1,5
Abel,1,3
Gil,1,2
```