| name | find-duplicates |
| description | Identify duplicate or near-duplicate items in the workspace inventory — exact name matches, fuzzy name matches, and functional duplicates (multiple kettles, multiple HDMI cables of the same length). Outputs a grouped duplicates report and recommends which to keep based on condition and value. |
Find duplicates
When to invoke
User asks "do I have duplicates", wants to consolidate, or runs after import-inventory to clean the merged list.
Preconditions
<workspace>/inventory/master.json exists with items.
Detection passes
- Exact match on normalized
name (lowercased, trimmed, punctuation stripped).
- Fuzzy match on
name using a similarity threshold (Levenshtein or token-set ratio ≥ 0.85). E.g. "ThinkPad T480" and "Lenovo Thinkpad T-480".
- Functional duplicates — same
category plus a shared key noun in name or description. E.g. three items with category=kitchen and "kettle" in name. Use looser matching here; flag for user judgement, don't auto-merge.
- Bundle duplicates — same name with
qty > 1 already collapsed → just note the count, don't flag as a problem.
Recommendation per group
For each duplicate group, recommend which copy to keep:
- Prefer better
condition (new > good > fair > poor > broken).
- Prefer higher
est_value if conditions are equal.
- Prefer the one in a more accessible
location (in-use room over storage box).
- Surface ties to the user.
Output
Write <workspace>/analysis/duplicates.md:
## Group: <canonical name>
- KEEP: <item> (id, location, condition)
- DISCARD/SELL/DONATE: <item> (id, location, condition) — reason
- DISCARD/SELL/DONATE: <item> (id, ...)
Print a summary count to chat: "12 duplicate groups, 19 redundant items".
Offer to push the redundant items into suggest-discards, identify-resale-targets, or identify-donation-targets based on each item's value and condition.