Review a TLS certificate inventory (input.json with today and a certificates array of domain, expiresDay, autoRenew) and write renewals.csv and renewal-counts.json listing the certificates that are expired or need renewing. Use whenever the user asks which certificates are expiring, expired, superseded, or need action, or mentions certificate inventory, expiresDay, autoRenew, renewals.csv or renewal-counts.json, even if they don't name this skill. Works by hand-calculation only, with no scripts.
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 Cert Renewals?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/gabrielmoreira-cert-renewals-585ea18b)
---
name: cert-renewals
description: Review a TLS certificate inventory (input.json with today and a certificates array of domain, expiresDay, autoRenew) and write renewals.csv and renewal-counts.json listing the certificates that are expired or need renewing. Use whenever the user asks which certificates are expiring, expired, superseded, or need action, or mentions certificate inventory, expiresDay, autoRenew, renewals.csv or renewal-counts.json, even if they don't name this skill. Works by hand-calculation only, with no scripts.
---
# Certificate renewals
You can only read and write files, so do the work carefully by hand, writing down intermediate tables as you go. Mistakes usually come from skipped steps, so follow them in order.
## Steps
1. **Read `input.json`** in the working folder. Take `today` (whole number) and `certificates` (array of `{domain, expiresDay, autoRenew}`). The output files go in the same folder as `input.json`.
2. **Keep one certificate per domain.** Group entries by `domain`. For each domain keep only the entry with the largest `expiresDay`. Discard the rest, wherever they sit in the list. (Expiry days within a domain are never equal, so there are no ties.) Scan the whole list for every domain. Duplicates are often far apart. Compare numbers numerically, not as text (95 is smaller than 100).
3. **Compute `days_left = expiresDay - today`** for each kept certificate. Double-check the sign: a past expiry gives a negative number.
4. **Classify each kept certificate:**
- `days_left <= 0`: status `expired`. List it whatever `autoRenew` is. Expiring today (0) is expired.
- `1 <= days_left <= 30`: status `renew`, but only if `autoRenew` is not true. If `autoRenew` is true, omit it.
- `days_left > 30`: omit.
Judge `autoRenew` only on the kept (latest) certificate. A superseded certificate's flag is irrelevant. Superseded certificates never produce rows, even if they are expired.
5. **Sort the rows** by `days_left` ascending (most negative first). Break ties by `domain` in ascending ASCII order (compare character by character; `-` and `.` and digits come before letters, and shorter comes first when one is a prefix of the other).
6. **Write `renewals.csv`**:
```
domain,days_left,status
old.example.org,-12,expired
api.example.net,30,renew
```
- The first line is exactly `domain,days_left,status`.
- One line per listed certificate, with plain integers (negative with a leading `-`, no `+`, no decimals), and no spaces or quotes.
- End with a newline. If nothing is listed, the file contains just the header line.
7. **Write `renewal-counts.json`**: an object with exactly the keys `expired` and `renew`, each the count of rows with that status (0 if none). For example:
```json
{"expired": 2, "renew": 1}
```
No other keys. The counts must add up to the number of CSV rows.
## Before finishing
Re-check: every domain appears at most once in the CSV; each row's days_left equals expiresDay minus today for that domain's latest certificate; boundary cases (0 and 1 days, 30 and 31 days) are classified correctly; the order is right; the counts match the rows. Then give the user a short summary of what was written.
## Worked example
today = 400. `shop.example.net` expires 400 gives 0, expired. `api.example.net` expires 430 gives 30: renew if autoRenew is false, omitted if true. `mail.example.net` appears with 405 and 520: only 520 counts, which gives 120, so it is omitted.