kicad monkey v2026.11.30
On This Page (7)

kcr project-lib

Extract symbols, footprints, metadata, and embedded STEP models from a KiCad project into metadata-preserving project-local library artifacts.

CommandAliasesCategoryRuntimeConfigGuide
kcr project-libkcr project-library, kcr project-local-lib, kcr local-libraryProjects, Libraries & AssetsPython kcrNone (CLI flags only)Projects, Variants & Design

Usage

sh
kcr project-lib [-h] [-o OUTPUT]
    [--symbol-library-dir SYMBOL_LIBRARY_DIR]
    [--footprint-library-dir FOOTPRINT_LIBRARY_DIR]
    [--symbol-library-name SYMBOL_LIBRARY_NAME]
    [--footprint-library-name FOOTPRINT_LIBRARY_NAME]
    [--include-models] [--embed-board-models]
    [--no-update-library-tables]
    [--relink-dry-run | --relink-sources]
    [--repair-cache-links] [--no-embed-models]
    [--no-embed-external-models]
    [--all-embedded-models]
    [--include-asset-scan]
    [--validate-kicad-cli]
    [--kicad-cli KICAD_CLI]
    [file]

Positional Arguments

ArgumentDescription
fileKiCad .kicad_pro project; optional when one .kicad_pro is in CWD

Options

FlagDescription
-o, --output OUTPUTOutput directory (default: ./local-library)
--symbol-library-dir SYMBOL_LIBRARY_DIRSymbol library folder under the output directory (default: .kicad_pro stem)
--footprint-library-dir FOOTPRINT_LIBRARY_DIRFootprint .pretty folder under the output directory (default: <.kicad_pro stem>.pretty)
--symbol-library-name SYMBOL_LIBRARY_NAMESymbol library nickname to add to sym-lib-table (default: symbol folder name)
--footprint-library-name FOOTPRINT_LIBRARY_NAMEFootprint library nickname to add to fp-lib-table (default: .pretty folder stem)
--include-modelsWrite decoded embedded STEP/STP model files into models/
--embed-board-modelsAfter extraction, embed resolved external STEP models natively into the project .kicad_pcb at deduplicated board scope (dry-run when --relink-dry-run is set)
--no-update-library-tablesExtract artifacts without editing project sym-lib-table/fp-lib-table
--relink-dry-runWrite a source_relink.json plan without editing schematic or PCB files. Mutually exclusive with --relink-sources.
--relink-sourcesRewrite source schematic and PCB references to the generated local libraries. Mutually exclusive with --relink-dry-run.
--repair-cache-linksWith relink dry-run/apply, repair placed schematic lib_name aliases when exactly one embedded cache symbol matches by member name
--no-embed-modelsDo not copy board-level embedded model payloads into extracted footprints
--no-embed-external-modelsDo not embed resolvable external STEP/STP model references into extracted footprints
--all-embedded-modelsScan the full project and write every embedded STEP/STP payload to models/
--include-asset-scanInclude full project asset/model scan in library_extraction.json
--validate-kicad-cliValidate generated libraries with kicad-cli; project-lib apply mode also runs a before/after schematic ERC library-hygiene gate
--kicad-cli KICAD_CLIExplicit kicad-cli executable for --validate-kicad-cli

How It Works

kcr project-lib (aliases project-library, project-local-lib, local-library) extracts all symbols, footprints, metadata, and embedded 3D STEP models used by a .kicad_pro into a metadata-preserving project-local library under -o <dir> (default ./local-library — not ./output/project-lib).

By default, it writes:

Conflict & Flag Interaction Rules

  1. --relink-dry-run vs --relink-sources (mutually exclusive):
    • --relink-dry-run computes and writes source_relink.json without editing any .kicad_sch or .kicad_pcb file.
    • --relink-sources rewrites schematic and PCB symbol/footprint references to point at the newly extracted project-local libraries.
  2. --relink-sources + --no-update-library-tables -> exit code 2:
    • Hard error! Relinking schematics and PCBs to new local library nicknames without registering those nicknames in sym-lib-table/fp-lib-table would break KiCad resolution. Remove --no-update-library-tables or switch to --relink-dry-run.
  3. --repair-cache-links requires a relink flag -> exit code 2:
    • Passing --repair-cache-links without either --relink-dry-run or --relink-sources fails immediately with exit code 2.
  4. --embed-board-models inherits dry-run state from --relink-dry-run:
    • When --embed-board-models is set alongside --relink-dry-run, board STEP embedding also runs in dry-run mode (no .kicad_pcb write). Without --relink-dry-run, it runs embed-models in apply mode (subject to KiCad .lck lock checks) using <output>/models as an extra search directory when present.
  5. --include-models vs --all-embedded-models:
    • By default, decoded STEP files are embedded inside extracted .kicad_mod footprints without writing loose .step files to models/. Passing --include-models or --all-embedded-models writes decoded STEP/STP files into <output>/models/.
  6. --validate-kicad-cli:
    • Runs kicad-cli library validation against the generated libraries (and in --relink-sources apply mode, runs a before/after schematic ERC library-hygiene gate). Any validation failure returns exit code 1 even though artifacts were written.

Quick Examples

sh
# Preview source relinking without modifying project files
kcr project-lib project.kicad_pro --relink-dry-run
sh
# Extract project-local libraries with embedded STEP models and relink references
kcr project-lib project.kicad_pro --relink-sources
sh
# Also embed resolved external STEP models directly into the project's .kicad_pcb
kcr project-lib project.kicad_pro --relink-sources --embed-board-models
kicad-monkey v2026.11.30·Docs updated 2026.12.01 15:43 UTC (fd9b75b)