A CLI tool for generating KiCad symbol library entries. Fetches part data from distributors (DigiKey) or manual entry, derives symbols from existing KiCad libraries, and writes them to your custom libraries following consistent naming and field conventions.
Requires Python 3.14+ and uv.
git clone --recurse-submodules <repo-url>
cd pklg
uv syncpklg addThe interactive flow prompts you through:
- Component type -- capacitor, resistor, inductor, or generic
- Distributor -- DigiKey (API) or manual entry
- Distributor part number -- used to fetch product details
- Component-specific prompts -- depends on the type selected (see below)
- Editor review -- opens
$EDITORwith a TOML file to review/edit all fields before committing - Confirmation -- final yes/no before writing the symbol
For passive components, pklg auto-detects package code and electrical value from the distributor data and maps them to standard SMD footprints (0201 through 2220). Values are formatted in EE shorthand (4u7, 10k, 330n).
The symbol is derived from the generic C, R, or L symbol in KiCad's Device.kicad_sym library and written to MyLib_Capacitor.kicad_sym, MyLib_Resistor.kicad_sym, or MyLib_Inductor.kicad_sym respectively.
For anything else, pklg lets you browse and pick a source symbol from any KiCad symbol library -- both the standard KiCad libraries and any 3rdparty libraries you configure.
Properties already present on the source symbol (reference designator, footprint, datasheet, description) are automatically carried over. You only need to provide a component name and package code.
The flow:
- Pick a source library (searchable, includes standard + 3rdparty)
- Pick a symbol to derive from
- Pick or create a target custom library
- Enter component name (defaults to source symbol name)
- Enter package code
- Review in editor, confirm
Config file: ~/.config/pklg.toml (created automatically on first run).
# Required: where to write your custom symbol libraries
library_path = "/home/user/kicad-libs/Symbols"
# Optional: path to KiCad's standard symbol libraries (default shown)
standard_symbol_library_path = "/usr/share/kicad/symbols/"
# Optional: custom library filename prefix (default: "MyLib_")
library_prefix = "MyLib_"
# Optional: additional directories to scan for .kicad_sym files (recursive)
# Useful for KiCad 3rdparty plugin libraries
extra_symbol_paths = ["/home/user/.local/share/kicad/9.0/3rdparty/symbols"]
# Required for DigiKey distributor
[digikey]
client_id = "your-client-id"
client_secret = "your-client-secret"| Key | Required | Default | Description |
|---|---|---|---|
library_path |
Yes | -- | Directory where custom .kicad_sym files are written |
standard_symbol_library_path |
No | /usr/share/kicad/symbols/ |
KiCad standard symbol library path |
library_prefix |
No | MyLib_ |
Prefix for custom library filenames |
extra_symbol_paths |
No | [] |
Additional directories to scan recursively for source .kicad_sym files |
digikey.client_id |
For DigiKey | -- | DigiKey API client ID |
digikey.client_secret |
For DigiKey | -- | DigiKey API client secret |
Register an application at DigiKey API to get a client ID and secret. pklg uses the client credentials OAuth2 flow (no browser login required).
pklg follows the naming convention documented at https://meschter.me/posts/kicad-lib-conventions/.
Symbol names: <RefDes>_<Value>_<Package>_<Manufacturer>_<MPN>
- Only characters
A-Z a-z 0-9 _ - . , +are allowed (spaces are replaced with hyphens) - Examples:
C_100nF_0402_Murata_GRM155R71C104KA88U_nRF54L15-QFXX_QFN-48_Nordic-Semiconductor-ASA_NRF54L15-QFAA-R
Library names: MyLib_<Function>.kicad_sym
- Examples:
MyLib_Capacitor.kicad_sym,MyLib_MCU.kicad_sym,MyLib_Connector.kicad_sym
Fields written to each symbol:
| Field | Source |
|---|---|
| Value | Component name / EE shorthand value |
| Footprint | Auto-detected or from source symbol |
| Datasheet | From distributor or source symbol |
| Description | From distributor or source symbol |
| Manufacturer | From distributor |
| Manufacturer Part Number | From distributor |
| Distributor Link 1 | Product URL from distributor |
| Distributor 1 Part Number | The part number you entered |
| Distributor Link 2 | Optional, set in editor |
| Distributor 2 Part Number | Optional, set in editor |
Before writing any symbol, pklg opens your $EDITOR (defaults to vi) with a TOML file containing all fields. You can edit any value, including the symbol name and target library. Delete all content to abort.
uv sync # install dependencies
uv run pytest tests/ -v # run tests
uv run ruff check # lint