hashgraph-online/awesome-codex-plugins / plugins/aklofas/kicad-happy/skills/bom
bom
VerifiedBOM (Bill of Materials) management for electronics projects — the workflow skill that coordinates DigiKey, Mouser, LCSC, element14, JLCPCB, PCBWay, and KiCad skills around a unified BOM lifecycle. Create, update, and maintain BOMs with part numbers, costs, quantities stored as KiCad symbol properties. ALWAYS trigger this skill for any task involving component sourcing, pricing, ordering, distributor searches, BOM export, or fabrication preparation — even if the user names a specific distributor or fab house (e.g. "search DigiKey for...", "generate JLCPCB BOM", "order from Mouser"). This skill analyzes the schematic for sourcing gaps, recommends which distributor/fab skills to call for each gap, and writes results back as symbol properties — the agent (or user) performs the actual searches via the called skills. Also trigger on phrases like "what parts do I need", "order components", "how much will this cost", "export for JLCPCB", "find parts for this board", "compare pricing", or "check stock".
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 22.3 KB |
| references/kicad-fields.md | markdown | 3.2 KB |
| references/ordering-and-fabrication.md | markdown | 5.1 KB |
| references/part-number-conventions.md | markdown | 19.2 KB |
| scripts/_core_path.py | script | 697 B |
| scripts/bom_fields.py | script | 5.4 KB |
| scripts/bom_manager.py | script | 60.5 KB |
| scripts/edit_properties.py | script | 18.2 KB |
| scripts/kicad_sexp.py | script | 10.6 KB |
| scripts/sync_datasheet_urls.py | script | 16.2 KB |
| scripts/translate_bom_pnp.py | script | 28.8 KB |
scripts/bom_fields.py
View on GitHub#!/usr/bin/env python3
"""Field-name aliases and per-symbol part-number lookups shared by the BOM scripts."""
from __future__ import annotations
import re
import _core_path # noqa: F401
from kicad_core.fields import (MPN_FIELD_ALIASES, MPN_FIELD_ALIASES_PRIMARY,
MPN_FIELD_ALIASES_GENERIC, DIGIKEY_FIELD_ALIASES,
normalize_field_name)
# A Value that is exactly one of these marks the part not fitted; BOM tools and the
# pick-and-place translator share the list.
DNP_VALUE_MARKERS = frozenset({"dnp", "dnf", "dni", "dnm", "nopop", "no pop", "nostuff",
"no stuff", "do not place", "do not populate", "do not fit",
"noload", "no load"})
# Cell values of a DNP-named field (DNP, DNM, DONOTPLACE, ...) that mean not fitted.
DNP_FIELD_SET = frozenset({"yes", "true", "1", "dnp", "y", "x", "*"})
# Values of a population column (POPULATE, Populate, Fitted) that mean the part
# is not fitted, compared lower-case against the whole stripped cell.
POPULATE_UNFITTED = frozenset({"0", "no", "false", "n", "dnp", "dnf", "do not fit",
"do not populate", "not fitted", "unfitted"})
# ---------------------------------------------------------------------------
# Field name aliases — maps every known variant to a canonical name
# ---------------------------------------------------------------------------
FIELD_ALIASES: dict[str, list[str]] = {
# Shared with analyze_schematic / analyze_pcb (kicad_core.fields), plus
# the bom-local ambiguous extras the analyzers deliberately exclude.
"mpn": sorted(MPN_FIELD_ALIASES | {"mp", "mfn"}),
"manufacturer": [
"Manufacturer", "Manufacturer_Name", "Manufacturer Name",
"Mfr", "MFR", "MF", "Mfg", "MANUFACTURER",
],
"digikey": sorted(DIGIKEY_FIELD_ALIASES),
"mouser": [
"Mouser", "Mouser Part Number", "Mouser Part", "Mouser_PN",
"Mouser PN",
],
"lcsc": [
"LCSC", "LCSC Part #", "LCSC Part Number", "LCSC Part",
"LCSCStockCode", "LCSC_PN", "LCSC PN", "JLCPCB", "JLCPCB Part",
"JLC",
],
"element14": [
"Newark", "Newark Part Number", "Newark_PN", "Newark PN",
"Farnell", "Farnell Part Number", "Farnell_PN", "Farnell PN",
"element14", "element14 Part Number", "element14_PN",
],
}
# Build reverse lookup: NORMALIZED field name -> canonical name (case- and
# whitespace-insensitive, so "Manufacturer P/N" == "manufacturer p/n").
_ALIAS_LOOKUP: dict[str, str] = {}
for canonical, aliases in FIELD_ALIASES.items():
for alias in aliases:
_ALIAS_LOOKUP[normalize_field_name(alias)] = canonical
def _canonical_for(name: str):
"""Canonical BOM field for an actual KiCad property name, or None."""
return _ALIAS_LOOKUP.get(normalize_field_name(name))
def _first_nonblank_stripped(props: dict, aliases: frozenset) -> str:
"""First value whose normalized key is in *aliases* and whose .strip() is
non-empty, returned stripped."""
for key, value in props.items():
v = str(value).strip()
if v and normalize_field_name(key) in aliases:
return v
return ""
def _pick_mpn_from_props(props: dict) -> str:
"""Alias-scan fallback for the mpn canonical (manufacturer-specific aliases
before generic ones; bom-local `mp`/`mfn` count as generic). Whitespace-only
values are skipped."""
return (_first_nonblank_stripped(props, MPN_FIELD_ALIASES_PRIMARY)
or _first_nonblank_stripped(props, MPN_FIELD_ALIASES_GENERIC | frozenset({"mp", "mfn"})))
# KiCad "Supplier N" slots: a name field (`Supplier 1` = "DigiKey") and a part number field whose
# spelling varies between projects; the slot number ties the two together.
_SUPPLIER_NAME_MAP = {
"digikey": "digikey", "digi-key": "digikey",
"mouser": "mouser",
"lcsc": "lcsc", "jlcpcb": "lcsc",
"newark": "element14", "farnell": "element14", "element14": "element14",
"arrow": "arrow",
}
_SLOT_NAME_RE = re.compile(r'^Supplier[\s_]*(\d+)$', re.IGNORECASE)
_PN_WORD = r'(?:#|number|num|no\.?|p/n|pn)'
_SLOT_PN_RE = re.compile(
rf'^Supplier[\s_]*(?:(\d+)[\s_]*(?:part[\s_]*)?{_PN_WORD}|part[\s_]*{_PN_WORD}[\s_]*(\d+))$',
re.IGNORECASE)
def _slot_pn_number(name: str):
"""Slot number of a `Supplier N` part number field name, or None."""
m = _SLOT_PN_RE.match(name.strip())
return int(m.group(1) or m.group(2)) if m else None
def _symbol_slots(props: dict, project_slots: dict[int, str] | None = None) -> dict[str, str]:
"""Distributor -> part number from this symbol's own `Supplier N` fields (lowest slot wins).
A slot the symbol does not name takes the distributor the whole project names for it
(*project_slots*); a slot the symbol names with another or unknown name never does.
"""
names = {}
for name, value in props.items():
m = _SLOT_NAME_RE.match(name.strip())
if m and str(value).strip():
names[int(m.group(1))] = _SUPPLIER_NAME_MAP.get(str(value).strip().lower())
for slot, dist in (project_slots or {}).items():
names.setdefault(slot, dist)
out: dict[str, str] = {}
pns = sorted((_slot_pn_number(n), n) for n in props if _slot_pn_number(n) is not None)
for slot, name in pns:
dist = names.get(slot)
pn = str(props[name]).strip()
if dist in ("digikey", "mouser", "lcsc", "element14") and pn and pn != "~":
out.setdefault(dist, pn)
return out
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |