A Claude Code slash command for managing electronic parts inventory through the Part-DB API. Add parts, attach datasheets, update quantities from your terminal.
A .md file you drop into your project's .claude/commands/ directory. Once installed, typing /partdb-update in Claude Code gives it full context on how to interact with your Part-DB instance via its JSON-LD API.
It encodes API knowledge that isn't obvious from Part-DB's docs:
- The
_typediscriminator required for attachment uploads (undocumented, causes 400 errors without it) - Two-step part creation (Part-DB rejects nested objects, so you create the part first, then the lot)
- Datasheet sourcing table (which CDN mirrors work, since many manufacturer sites block downloads)
- Common error patterns and fixes
# Copy the skill into your project
mkdir -p .claude/commands
cp partdb-update.md .claude/commands/Then open the file and replace the placeholder values:
| Placeholder | Replace with |
|---|---|
YOUR_PARTDB_HOST |
Your Part-DB server IP/hostname (e.g. 192.168.1.100) |
YOUR_PARTDB_PORT |
Your Part-DB port (default: 8080) |
YOUR_API_TOKEN |
Your Part-DB API token (or a reference to where you store it) |
In Claude Code:
/partdb-update add 10x 100nF ceramic capacitors from Mouser order
/partdb-update attach datasheets to all parts missing them
/partdb-update update quantity of ESP32-S3 to 5
/partdb-update show current inventory
- Log into your Part-DB instance
- Go to your user settings
- Under "API Tokens", create a new token with full permissions
- Copy the token into the skill file or store it in a secure location the skill references
The skill is just markdown. Edit it freely:
- Add your categories. Replace the generic category lookup with your actual category IDs.
- Add supplier-specific notes. If you always order from certain suppliers, add their conventions.
- Adjust the datasheet sourcing table. Add or remove CDN mirrors based on what works for your parts.
- Add your own error patterns. As you hit new API quirks, document them in the error table.
Claude Code slash commands are markdown files in .claude/commands/. When invoked, the file content becomes part of Claude's context. No code execution, no plugins. Just structured knowledge that tells Claude how to call the API correctly.
This pattern works for any API-driven tool. The key sections:
- Access info. URL, auth, content types.
- Step-by-step workflows. The happy path for common operations.
- Gotchas and error tables. The stuff that wastes hours when you don't know it.
- Verification steps. How to confirm the operation worked.
Built for managing an electronics inventory on an Unraid homelab. The original had hardcoded IPs and paths. This version replaces those with placeholders but keeps all the API knowledge intact.
MIT