This skill should be used when the user asks about buying parts or costing a batch, for example "check stock", "price for 100 boards", "what does the BOM cost", "quote the client", "check my BOM", "find an alternative", "second source", "is this part obsolete", "lead time" or "MOQ". It looks parts up through the DigiKey, Mouser and Nexar APIs with the user's own keys and reports price, stock and lifecycle risks.
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 Parts Sourcing?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/gkochievi-parts-sourcing)
---
name: parts-sourcing
description: This skill should be used when the user asks about buying parts or costing a batch, for example "check stock", "price for 100 boards", "what does the BOM cost", "quote the client", "check my BOM", "find an alternative", "second source", "is this part obsolete", "lead time" or "MOQ". It looks parts up through the DigiKey, Mouser and Nexar APIs with the user's own keys and reports price, stock and lifecycle risks.
user-invocable: false
---
# Parts sourcing: live stock, price, lifecycle and alternates
Answer "can I buy this, how many, at what price, and for how long" with live data from official distributor APIs, never from memory. Two scripts do the work: `scripts/parts_lookup.py` for one part or a keyword search, `scripts/bom_check.py` for a whole BOM. Background, API setup and the lifecycle vocabulary are in `references/sourcing-and-lifecycle.md`. Choosing parts for JLCPCB assembly (Basic / Extended classes, footprints, verifying an LCSC number) stays in `pcb-design/references/part-selection.md`.
## Procedure
### 1. Pin down the part
- Get the full manufacturer part number (MPN), the manufacturer and the package before any lookup. If the user gives a value ("10 µF 0805 25 V") or a generic name ("an LDO"), run a keyword search and have the user pick one MPN; do not choose a part silently.
- Confirm the package against the footprint on the board. A matching MPN family with a different suffix can be a different package, temperature grade or packaging.
- Never invent an MPN, a distributor number or an LCSC number. An LCSC number is used only when the user's BOM holds it or after it was checked on its lcsc.com product page (`https://www.lcsc.com/product-detail/<C-number>.html`).
### 2. Check that keys exist, ask only when needed
- Run `scripts/parts_lookup.py providers` first. It shows which providers have keys (never the keys themselves), local call counts and the cache folder.
- Ask for keys only when a live lookup is actually needed and no provider is configured. Tell the user which variables to set and where to create them; never ask them to paste a secret into the chat:
- DigiKey: `DIGIKEY_CLIENT_ID`, `DIGIKEY_CLIENT_SECRET` (developer.digikey.com, production app subscribed to Product Information V4).
- Mouser: `MOUSER_API_KEY` (mouser.com/api-search request form).
- Nexar / Octopart: `NEXAR_CLIENT_ID`, `NEXAR_CLIENT_SECRET` (portal.nexar.com, application with the Supply scope).
- Or a keys file outside the project, passed with `--keys-file` (TOML or JSON, mode 0600). Setup details: `references/sourcing-and-lifecycle.md` sections 7 and 8.
- With no keys at all, still help: parse and group the BOM with `bom_check.py --no-lookup`, list what must be checked, and give the distributor search links in prose.
### 3. Look up one part
```sh
scripts/parts_lookup.py mpn <MPN> --qty <N> # stock, best price for N, lifecycle, datasheet
scripts/parts_lookup.py search "<keywords>" --limit 5
scripts/parts_lookup.py alternates <MPN> # Nexar similarParts, Mouser SuggestedReplacement
```
- Always pass `--qty` with the real buy quantity (qty per board × boards plus spares). The script applies MOQ, order multiple and price breaks, flags stock below the quantity and shows a "better value" when the next price break costs less in total.
- Use `--json` when you need to process the result; summarise it for the user in a short table (distributor, stock, unit and extended price, lifecycle, datasheet).
- Add `--nexar-pro` only when the user's Nexar plan includes specs and datasheets; on other plans the script retries without them and says so.
### 4. Check a BOM
```sh
scripts/bom_check.py <bom.csv> --boards <N> --attrition <percent> [--min-extra <pieces>] --md report.md
```
- Ask for the number of boards; it is required. Ask the assembler's attrition rule; the script adds no spares unless told.
- Run with `--no-lookup` first when the BOM layout is unfamiliar: it confirms the detected columns, merged lines and DNP rows without using quota. Pick the MPN column with `--mpn-col` if it was not found.
- It reads KiCad BOM exports, JLCPCB BOMs (Comment, Designator, Footprint, LCSC Part #) and the kicad-generator `make_bom.py` files (`<PREFIX>_BOM.csv` and `<PREFIX>_Parts_not_assembled.csv`).
- Report per line: found or not, stock against the needed quantity, best offer and price, lifecycle, single-source and datasheet risks; then cost per board and per order. Put lines that fail first.
- Lines with only an LCSC number come back as "check on lcsc.com (no official API)" with the product link. Tell the user to check those by hand and to add MPNs to the BOM.
### 5. Cost a batch and quote a client
```sh
scripts/quote.py out/Board_1.0_BOM.csv --qty 5,50,500 --prices prices.csv --kicad-pcb out/Board/Board.kicad_pcb \
--pcb 5=8.10,50=31.40,500=189.00 --labor-hours 6 --rate 45 --markup 15 --client "..." --project "..."
```
- Per quantity: parts at their price break (MOQ and breaks applied, attrition when asked), the PCB price the user copies from the fab's quote page (`--pcb N=PRICE`), JLCPCB's assembly fees and the user's engineering hours, NRE and markup. It writes `quote.md`, `quote.html` (print to PDF), `quote.json` and `quote_lines.csv`.
- Prices come from a price file (`part, qty, unit_price, currency, type` with type basic / extended for JLCPCB's part class, copied from the LCSC / JLCPCB part pages) or `--live` (distributor APIs through `bom_check.py`). A line without a price stays out of the totals and is listed; a missing part class counts as extended.
- Assembly fees come from `scripts/data/jlcpcb_assembly_fees.json`, taken from JLCPCB's own price page with its update date: re-check the page before quoting a customer and update the file when it changed. Economic (default) or `--service standard`; solder joints, sides and board area from `--kicad-pcb`, or `--joints SMD,THT`.
- Shipping, taxes and duties are never included; the quote says so.
### 6. Judge the risks
| Finding | What to tell the user |
|---|---|
| Not found | check the MPN spelling and suffix; the part may be a custom or regional number |
| Short (stock < needed everywhere) | lead time, smaller first build, or an alternate; never promise stock will return |
| Single source | name the distributor; suggest a second distributor or a second part |
| NRND | fine for this build; plan a replacement before the next one |
| EOL / last time buy / obsolete | replace now, or a lifetime buy if the product is near its end; give the last-buy date when DigiKey reports one |
| No datasheet link | get the manufacturer's datasheet before trusting the footprint |
| Distributor marks it discontinued | the maker may still sell it elsewhere; check other authorised distributors |
| Only broker or unauthorised offers | counterfeit risk: see section 5 of the reference before buying |
### 7. Alternates
- Treat every alternate as a candidate. Compare pinout (including NC pins and the exposed pad), package and land pattern, absolute maximum and operating ratings, key parameters, thermal data, firmware differences and qualification, using the table in `references/sourcing-and-lifecycle.md` section 4.
- Prefer the manufacturer's own recommended replacement when one exists.
- State plainly which checks were done against which datasheet, and which were not done.
### 8. Report
- Give the time of the lookup and say that stock and prices change; re-run before ordering.
- Mark computed numbers (needed quantity, extended price, totals) as computed.
- Name the provider for each number. Never mix in remembered prices or stock.
- Offer the Markdown or CSV report (`--md`, `--csv`) for the project folder.
## Defaults and traps
- **Official APIs only.** DigiKey Product Information v4, Mouser Search API v1 and the Nexar supply API. No scraping and no unofficial LCSC, JLCPCB or Octopart endpoints, even if the user suggests one. LCSC and JLCPCB APIs exist but need an application and approval; they are not implemented (reference section 6.3).
- **Quotas:** DigiKey 120 calls per minute and 1000 per day; Mouser 30 per minute and 1000 per day; Nexar counts every part returned (evaluation app: 100 parts for its lifetime). The scripts space calls, count them per day on this computer, cache answers for an hour and default Nexar to 3 parts per query. Use `--cache-only` to re-run a report without spending quota.
- **Keys:** environment variables or a keys file outside the project only. The scripts refuse key-like entries in `boulder.toml` and a keys file inside the project, never print keys or tokens, and keep tokens in the user cache folder with mode 0600.
- **Missing keys** stop the scripts with exit 2 and a message naming the variables and the sign-up pages. Relay that message; do not try another route.
- **Stock is a snapshot.** DigiKey's product total adds all packagings; the per-packaging figure is what one order line can take. Nexar −1 means "does not carry it", −2 "in stock, no number", −3 "unknown", −4 "RFQ".
- **DigiKey `Discontinued` is not `EndOfLife`.** The first is DigiKey's own decision; the second is the manufacturer's.
- **Currency:** DigiKey uses the site's currency unless `--currency` is set (USD on the US site); Nexar prices come in the seller's currency or Nexar's converted price. BOM totals are split per currency.
- **Sandbox:** `--digikey-sandbox` checks the connection only; its data is not real.
- **Single-source verdicts** need two distributor APIs or Nexar; with one provider the script notes that it could not decide.
- **Unverified field names:** DigiKey's ProductVariation model could not be read from its Swagger file; the script reads `DigiKeyProductNumber`, `PackageType` and `StandardPricing` by the names used in DigiKey's other v4 models and degrades to empty fields if they differ (reference section 7.1). Say so if DigiKey numbers or prices come back empty.
## References
| File | Use for |
|---|---|
| `references/sourcing-and-lifecycle.md` | reading stock, factory stock and lead time per API; MOQ, order multiples, price breaks, cut tape, reels, Digi-Reel; attrition; lifecycle terms (Active, NRND, LTB, EOL, Obsolete) with sources and the script's mapping; drop-in and second-source checklist; counterfeit risk and authorised channels; JLCPCB Basic / Extended / consigned / Global Sourcing parts and LCSC numbers; LCSC and JLCPCB API access conditions; DigiKey, Mouser and Nexar setup, endpoints and quotas; key privacy; troubleshooting; corrections to common advice |
## Scripts
| Script | Use | Example |
|---|---|---|
| `scripts/parts_lookup.py mpn` | one MPN across the configured providers: offers with stock, MOQ, price breaks, lifecycle, datasheet, product link; best offer at `--qty` | `parts_lookup.py mpn STM32F072CBT6 --qty 100` |
| `scripts/parts_lookup.py search` | keyword search | `parts_lookup.py search "LDO 3.3V SOT-23-5" --limit 5` |
| `scripts/parts_lookup.py alternates` | replacement candidates from Nexar `similarParts` and Mouser `SuggestedReplacement` | `parts_lookup.py alternates AP2112K-3.3TRG1 --providers nexar` |
| `scripts/parts_lookup.py providers` | which keys are set, quotas, cache folder; no network | `parts_lookup.py providers` |
| `scripts/bom_check.py` | whole BOM: needed quantity, stock, best price, lifecycle, single-source and datasheet risks, totals per board and per order; text, `--json`, `--csv`, `--md` | `bom_check.py out/board_BOM.csv --boards 50 --attrition 3 --md bom_report.md` |
| `scripts/quote.py` | batch cost at several quantities (parts, PCB, JLCPCB assembly fees, engineering, markup) and a client quote (Markdown, HTML, JSON, CSV) | `quote.py out/board_BOM.csv --qty 10,100 --prices prices.csv --kicad-pcb out/b/b.kicad_pcb --pcb 10=6,100=40` |
Each prints a readable report, or one JSON object with `--json`; exit 0 ok or warn, 1 a check failed (part not found, not enough stock, EOL or obsolete), 2 usage or runtime error (missing keys, every provider failed). Non-secret settings come from the command line, then `[parts_lookup]` and `[bom_check]` in `boulder.toml` (provider list, currency, DigiKey site, cache lifetime, boards, attrition). Boards and attrition are never guessed.
## Related skills
- `kicad-generator`: writes the JLCPCB BOM and the parts-not-assembled list that `bom_check.py` reads (`kicad-generator/references/production-files.md`); keep the `MPN` field filled in `parts.json`.
- `board-review`: run `bom_check.py` as part of "is it ready to order"; obsolete, short or single-source lines are findings with a severity.
- `ask-gela`: record sourcing decisions, second sources and lifetime buys in the decision log; re-run the BOM check at each build phase.
- `pcb-design`: JLCPCB part classes, feeder fees, footprint checks and LCSC number verification (`pcb-design/references/part-selection.md`, `pcb-design/references/jlcpcb-dfm-assembly.md`).
## Next step
When this is done, say what comes next: fix the flagged BOM lines in the project; the order is placed by a person; `bringup-and-test` when the boards arrive.