CLI command design

prjpcb

Creates PrjPcb skeletons from editable JSONC configs through generated MCO operations.

Purpose

prjpcb is the public seed workflow for new Altium PrjPcb fixtures and simple generated designs. The config is the editable source of truth; generated MCO operations perform the actual PrjPcb, SchDoc, and PcbDoc writes.

Usage

altium-cruncher prjpcb
altium-cruncher prjpcb create
altium-cruncher prjpcb init demo --layers 4
altium-cruncher prjpcb init demo.project.jsonc --project-name demo --layers 4
altium-cruncher prjpcb create demo.project.jsonc --emit-mco demo.mco.json --json
altium-cruncher prjpcb create demo.project.jsonc --defaults --project-name demo --force
altium-cruncher prjpcb add-sheet demo.PrjPcb Power.SchDoc --sheet-style D

Arguments

ArgumentContract
prjpcbCommand group entry point. With no subcommand, prints command help.
createWith no config target, writes prjpcb_init.jsonc when no project config exists in the current directory. A subsequent no-target run loads the existing config and creates the project skeleton.
init configWrites a commented JSONC config using schema altium_cruncher.project_skeleton.a0. A bare name such as demo writes demo.project.jsonc and infers project name demo.
create configLoads a JSONC config, writes a normalized config copy next to the generated PrjPcb unless overridden, compiles the config to MCO, and executes it. Bare names resolve to NAME.project.jsonc.
add-sheet prjpcb sheetCreates one new .SchDoc and adds it to an existing .PrjPcb.
--defaultsFor create, writes and uses a default config if the requested config path does not exist.
--project-name, --layersSeed values used by init and by create --defaults.
--write-config, --emit-mcoWrite the normalized config copy and generated operation payload to explicit paths.
--force, --dry-run, --json, --json-outputFollow the shared MCO command semantics for overwrite, non-mutating planning, stdout JSON, and sidecar JSON report output.

Config Shape

The A0 config contains project, schematics, and optional pcb sections. project.parameters writes PrjPcb parameters. Each schematic row writes a SchDoc and defaults sheet_style to D. The PCB section can set a rectangular board outline, generated rigid layer stack, editable single mechanical_layers, and grouped mechanical_layer_pairs with top and bottom layer rows. Generated JSONC templates document valid mechanical layer ids, indexes, default names, and mechanical layer kind enum values. mechanical_layer_profile remains an optional shorthand for standard_component_pairs, but generated configs expand the rows so users can edit them directly.

MCO Shape

prjpcb create compiles to project.create, zero or more project.add_parameter operations, one schdoc.create per schematic, an optional pcbdoc.create, and one project.add_document per generated document. prjpcb add-sheet compiles to schdoc.create followed by project.add_document.

Stackup Scope

The project config supports generated rigid stacks in this release. It deliberately does not accept .stackup or .stackupx imports until Altium Monkey exposes stackup-file to PcbDoc authoring as a supported writer path.

Output

A first no-target prjpcb create run writes the sample JSONC config only; the next no-target run uses that config to write the PrjPcb, configured schematic sheets, and optional PcbDoc. prjpcb init writes a JSONC config. prjpcb create CONFIG writes the normalized config copy, optional emitted MCO, PrjPcb, configured schematic sheets, optional PcbDoc, and a JSON or human-readable MCO execution report. prjpcb add-sheet writes the new SchDoc and updates the existing PrjPcb document list.

Tests

Coverage lives in tests/test_prjpcb_command.py. It validates generated config schema conformance, bare-name config creation, no-target create config bootstrap and reuse, MCO shape, clean JSON stdout, PrjPcb parameter/document links, SchDoc default D sheets, generated PcbDoc stack readback, and mechanical layer kind readback.