| name | import-inventory |
| description | Import a possession/household inventory from any format the user supplies — CSV, Excel, JSON, Markdown table, free-text bullet list, photo of a handwritten list, or a folder of mixed files — and normalize it into the workspace's canonical item schema. Preserves the original in imports/ verbatim, then appends to inventory/master.json with stable IDs and de-duped headers. |
Import inventory
When to invoke
The user wants to load items into Declutter Genie. They might say "here's my list", paste a table, point at a spreadsheet, or hand over a freeform brain-dump.
Preconditions
Resolve the workspace path from $CLAUDE_USER_DATA/declutter-genie/config.json. If missing, run setup-workspace first.
Accept input in any of these forms
- File path(s) — CSV, TSV, XLSX, ODS, JSON, YAML, Markdown, plain text.
- A pasted block in chat — table, bullets, prose, or messy mixed.
- A directory — walk it and ingest every supported file.
- An image of a list — read it (Claude can OCR via Read on the image).
- A URL — fetch and treat as text.
Pipeline
- Preserve the source. Copy / write the raw input to
<workspace>/imports/<YYYY-MM-DD>-<slug>.<ext> exactly as received. Never rewrite the user's original.
- Detect format. Decide whether the source is structured (CSV / XLSX / JSON / Markdown table) or unstructured (bullets / prose). For XLSX use
python3 -c "import openpyxl..." or ssconvert if available; fall back to asking the user to export as CSV.
- Map columns to the canonical schema (see
setup-workspace for the schema). Use heuristic header matching first ("description"→description, "value"/"price"/"worth"→est_value, "where"/"location"/"room"→location, "qty"/"quantity"/"count"→qty, "condition"/"state"→condition). Show the proposed column mapping to the user and let them correct it before commit.
- Extract from unstructured input. For bullet lists or prose, parse each item into a row by best-effort. If the user wrote "Old ThinkPad T480 in the office cupboard, probably worth 200 shekels", extract
name=ThinkPad T480, condition=fair (from "old"), location=office cupboard, est_value=200, currency=ILS.
- Generate stable IDs. Slug from
name + short hash. Don't re-mint if an item with the same id already exists; instead update fields.
- Merge into
inventory/master.json. Append new items, update existing ones. Bump schema_version only on breaking changes.
- Report a summary. New items added, items updated, columns unmapped, rows that needed user judgement.
When in doubt, ask once
If ambiguity is structural (e.g. two columns both look like "name"), ask the user once with the proposed mapping. Don't ask per-row.
Output
- Updated
<workspace>/inventory/master.json.
- Original preserved at
<workspace>/imports/....
- Brief import report printed to chat: counts, mapping, anything skipped.
After import, suggest the user run find-duplicates or suggest-discards next.