component-search

Original🇺🇸 English
Translated
1 scriptsChecked / no sensitive code detected

Search for and add electronic components to a Zener PCB project using LCSC + easyeda2kicad. Use when designing a board, module, or subsystem and you need a part package that is not already in the workspace or covered by stdlib generics. Covers MPN → LCSC C-number lookup, `easyeda2kicad` import, and generation of a Zener component wrapper (.zen) from the imported `.kicad_sym`.

10installs
Added on

NPX Install

npx skill4agent add nasheed-x/pcb-skills component-search

Tags

Translated version includes tags in frontmatter

Component Search (LCSC + easyeda2kicad)

Find and add component packages to a Zener project without relying on a private registry. The pipeline is:
MPN  ──►  LCSC C-number  ──►  easyeda2kicad  ──►  .kicad_sym + .kicad_mod + .step  ──►  Zener wrapper (.zen)
Use this workflow any time you need a part that isn't already in the workspace
components/
tree or covered by stdlib generics (
@stdlib/generics/Resistor.zen
,
Capacitor.zen
,
Led.zen
,
Thermistor.zen
, …).

Hard Stop Before Manual Creation

If LCSC has no entry for the MPN, or
easyeda2kicad
fails on the resolved C-number, don't fall back to hand-drawing a symbol/footprint silently. Report what failed, offer manual creation as an option, and get explicit user confirmation.

Search Priority

Always search in this order. Move down only when the higher tier doesn't apply.
  1. Workspace
    components/
    tree
    glob
    or
    finder
    for the MPN. If the part is already imported, reuse it via
    Module("./components/<Mfr>/<MPN>/<MPN>.zen")
    .
  2. stdlib generics — for plain R, C, L, LED, diode, NPN/PNP, MOSFET, thermistor: use the generic, never import a vendor part.
  3. LCSC + easyeda2kicad — for ICs, modules, connectors, crystals, anything with a specific MPN.

Step 1 — MPN → LCSC C-number

LCSC parts have a numeric
Cxxxxxx
ID. easyeda2kicad needs that ID, not the MPN. Use the agent's web tools:
web_search  query="<MPN> site:lcsc.com"
read_web_page  url=<top LCSC product page>  objective="Find the LCSC C-number (e.g. C25804) and confirm package."
Tips:
  • LCSC product URLs look like
    https://www.lcsc.com/product-detail/.../C25804.html
    — the trailing
    Cxxxxx
    before
    .html
    is the C-number.
  • The product page also lists package, datasheet, stock, and price — capture these for the user.
  • Some MPNs map to multiple C-numbers (different reels, suffixes, manufacturers). Pick the one that matches the requested package and shows real stock.
  • If no LCSC hit, try the base MPN family (drop
    -TR
    ,
    -R7
    , reel/packaging suffixes).
When the user supplies a C-number directly, skip this step.

Step 2 — Import via easyeda2kicad

Resolve the manufacturer and a clean MPN slug first (no spaces, replace
/
with
_
). Pick a target package directory under
components/<Manufacturer>/<MPN>/
.
bash
mkdir -p components/<Manufacturer>/<MPN>
cd components/<Manufacturer>/<MPN>

easyeda2kicad --full --lcsc_id=Cxxxxx --output <MPN> --overwrite
This writes:
  • <MPN>.kicad_sym
    — symbol library (single symbol)
  • <MPN>.pretty/<something>.kicad_mod
    — footprint, inside a
    .pretty
    folder
  • <MPN>.3dshapes/<something>.{wrl,step}
    — 3D model
Flatten the footprint so the Zener wrapper can reference it as a single file next to the
.zen
:
bash
mv <MPN>.pretty/*.kicad_mod ./<MPN>.kicad_mod
rmdir <MPN>.pretty
(Keep
<MPN>.3dshapes/
as a folder —
.kicad_mod
references the 3D model by relative path inside it.)
If the user wants to skip the 3D model for size, drop
--full
and use
--symbol --footprint
. Note that
pcb
does not require a 3D model to build.

Step 3 — Generate the Zener wrapper

Use the bundled generator script to turn the imported
.kicad_sym
into a starter
.zen
:
bash
python3 <SKILL_DIR>/scripts/zener-wrap.py \
  --kicad-sym components/<Manufacturer>/<MPN>/<MPN>.kicad_sym \
  --footprint <MPN>.kicad_mod \
  --mpn <MPN> \
  --manufacturer "<Manufacturer>" \
  --output components/<Manufacturer>/<MPN>/<MPN>.zen
The generator parses the
.kicad_sym
and emits a
.zen
skeleton with:
  • top docstring (MPN, manufacturer, package — fill in description by hand)
  • mpn
    /
    manufacturer
    configs
  • one
    io()
    per pin, classified as
    Power
    ,
    Ground
    , or generic
    Net
    by name
  • Component(...)
    with the
    pins=
    dict mapping the original KiCad pin names to those ios
After generation, read the file and clean it up by hand:
  • Group related ios (split power, signal, control bundles).
  • Rename ios to integrator-facing names where it improves clarity (
    +IN_A
    IN_POS_A
    ).
  • Add
    voltage="..."
    to every
    Power
    io per the datasheet.
  • Replace
    Net
    with
    Analog
    /
    Digital
    / typed interfaces from
    @stdlib/interfaces.zen
    where appropriate.
  • Remove
    no_connect
    pins from the
    pins=
    dict — leave them out, don't expose as ios.
  • Drop the auto-generated docstring and replace with a short, integrator-facing one (one paragraph: what it is, where it's used, key constraint).
See
idiomatic-zener
for the full style rules. See
reference-design
if you want to grow the wrapper into a richer reusable design with surrounding circuitry.

Step 4 — Workspace manifest

The new component package needs a
pcb.toml
so the workspace can resolve it. Create:
toml
# components/<Manufacturer>/<MPN>/pcb.toml
[package]
name = "<MPN>"
description = "<one-line description>"
If the workspace
pcb.toml
declares
members = [..., "components/*", ...]
(most do), the package is auto-discovered. Verify with:
bash
pcb build components/<Manufacturer>/<MPN>
Fix any errors before instantiating from a board.

Step 5 — Use it

python
MyPart = Module("./components/<Manufacturer>/<MPN>/<MPN>.zen")

MyPart(
    name="U1",
    VDD=vdd_3v3,
    GND=gnd,
    # ...
)

Verifying Sourcing with
pcb bom

Once the part is wired into a board, sanity-check sourcing:
bash
pcb bom boards/<Board>/<Board>.zen -f json
For an easyeda2kicad-imported part, the BOM will pick up the MPN you set in the wrapper (
mpn=
config default). LCSC stock is the same source easyeda2kicad pulled from, so the
Cxxxxx
you used is your sourcing record — capture it in the docstring or a
.zen
comment for traceability.

Generator Script

Path:
<SKILL_DIR>/scripts/zener-wrap.py
Usage:
bash
python3 zener-wrap.py \
  --kicad-sym path/to/<MPN>.kicad_sym \
  --footprint <MPN>.kicad_mod \
  --mpn <MPN> \
  --manufacturer "<Manufacturer>" \
  --output path/to/<MPN>.zen \
  [--datasheet docs/<MPN>.pdf]   # optional
Pin classification rules:
  • GND
    ,
    VSS
    ,
    VEE
    ,
    AGND
    ,
    DGND
    ,
    V-
    Ground
  • VCC
    ,
    VDD
    ,
    VPP
    ,
    VBUS
    ,
    VS
    ,
    V+
    ,
    AVDD
    ,
    DVDD
    ,
    VIN
    ,
    VOUT
    Power
  • everything else →
    Net
The script never throws on unusual pin names — it sanitizes any string into a valid Zener identifier and falls back to
PIN_<num>
for unnamed pins.

Common Issues

  • easyeda2kicad: HTTP 404 on C-number — wrong C-number, or the part has been delisted. Re-search LCSC or pick the alternate-source listing.
  • Pin names look like
    ~{NAME}
    (with overbar markup)
    — KiCad wraps inverted pin names in
    ~{...}
    . The generator strips the markup for the io identifier but preserves the original string in the
    pins=
    dict so the symbol still matches.
  • Footprint references a 3D model that wasn't downloaded — happens with
    --symbol --footprint
    only. Either re-run with
    --full
    , or edit the
    .kicad_mod
    to remove the
    (model ...)
    block.
  • Symbol uses
    ~
    /
    #
    / spaces in pin names
    — the generator handles these. If the resulting Zener identifier is awkward, rename the io by hand and update the
    pins=
    mapping to keep the original KiCad name on the right.