Skip to content

Autowiring

The autowire_schematic tool analyzes unconnected nets in a KiCad schematic and automatically selects the best wiring strategy for each one. It provides a single-call alternative to manually deciding wire vs label vs power symbol for every net.

TaskExample prompt
Preview wiring planAutowire my schematic at /path/to/project.kicad_sch
Apply wiringAutowire my schematic at /path/to/project.kicad_sch with dry_run=False
Wire specific nets onlyAutowire only the SPI nets in my schematic
Exclude power netsAutowire my schematic, excluding GND and VCC
Adjust distance thresholdAutowire with direct_wire_max_distance=30

For each unconnected net, the tool walks through these checks in order:

PriorityConditionStrategyRationale
1Power net (name matches GND/VCC/+3V3/etc, or pin type is power_in/power_out)Power symbolStandard KiCad convention for power rails
2Single-pin netNo-connect flagAvoids ERC warnings on intentionally unused pins
3Cross-sheet netGlobal labelGlobal labels are required for inter-sheet connectivity
4High fanout (>5 pins by default)Global labelLabels scale better than wire stars for many connections
5Two-pin net, distance <= 10mmDirect wireShort enough that a wire is cleaner than a label
6Two-pin net, distance > 50mmLocal labelToo far for a clean wire run
7Two-pin net, mid-range with >2 crossingsLocal labelAvoids visual clutter from crossing wires
8Two-pin net, mid-range with few crossingsDirect wireWire is the simplest connection
93-4 pin netLocal labelStar topology with labels is cleaner than a wire tree

All thresholds are tunable via tool parameters.

Autowire defaults to dry_run=True — it shows you the plan without touching the schematic:

Autowire my schematic at ~/Projects/KiCad/amplifier/amplifier.kicad_sch

The response includes:

  • Strategy summary — counts by method (e.g., 12 direct wires, 8 local labels, 4 power symbols, 2 no-connects)
  • Per-net plan — each net’s chosen method and the reasoning
  • Batch file — the generated JSON written to .mckicad/autowire_batch.json

Once you have reviewed the dry run, apply with:

Autowire my schematic at ~/Projects/KiCad/amplifier/amplifier.kicad_sch with dry_run=False

This calls apply_batch internally, which means you get collision detection, label placement optimization, and power symbol stub generation automatically.

To wire only specific nets:

Autowire only the MOSI, MISO, and SCK nets in my schematic

To exclude nets you have already wired manually:

Autowire my schematic, excluding USB_D_P and USB_D_N

To exclude entire components (e.g., a connector you want to wire by hand):

Autowire my schematic, excluding refs J1 and J2

The default thresholds work well for typical schematics, but you can adjust them:

ParameterDefaultEffect
direct_wire_max_distance50.0mmPins farther apart get labels instead of wires
crossing_threshold2More crossings than this triggers label fallback
high_fanout_threshold5Nets with more pins than this get global labels

For dense boards with tight pin spacing:

Autowire my schematic with direct_wire_max_distance=25 and crossing_threshold=1

For sparse layouts where longer wires are acceptable:

Autowire my schematic with direct_wire_max_distance=80
{
"strategy_summary": {
"direct_wire": 12,
"local_label": 8,
"global_label": 3,
"power_symbol": 6,
"no_connect": 2
},
"total_nets_classified": 31,
"nets_skipped": 45
}

nets_skipped includes already-connected nets plus any you excluded — these are not counted in the classification total.

Each net entry explains the decision:

{
"net": "SPI_CLK",
"method": "local_label",
"pin_count": 2,
"reason": "long distance (67.3mm > 50.0mm)"
}

The reason field traces which branch of the decision tree was taken.

The generated .mckicad/autowire_batch.json uses the same schema as apply_batch. You can inspect it, edit it manually, and apply it yourself if you want to tweak individual connections before committing:

Show me the contents of .mckicad/autowire_batch.json

The crossing estimator checks whether a proposed direct wire between two pins would cross existing wires. It uses axis-aligned segment intersection: a horizontal wire crosses a vertical wire when their X/Y ranges overlap (strict inequality — touching endpoints do not count).

This keeps the schematic visually clean by falling back to labels when wires would create crossing patterns.

Power nets are identified by two methods:

  1. Name matching — GND, VCC, VDD, VSS, +3V3, +5V, +12V, +1.8V, VBUS, VBAT, and variants (AGND, DGND, PGND, etc.)
  2. Pin type metadata — if any pin on the net has pintype of power_in or power_out in the netlist, the net is treated as power regardless of its name

This handles custom power rails that do not follow standard naming conventions.

  1. Place all components and set values/footprints
  2. Wire critical signal paths manually (connect_pins, add_wire)
  3. Run autowire_schematic in dry-run to preview
  4. Review the plan — adjust thresholds or exclude specific nets if needed
  5. Apply with dry_run=False
  6. Run validate_schematic to verify
  7. Open in KiCad to visually inspect
  • Always dry-run first — review the plan before applying. The default dry_run=True exists for good reason.
  • Wire critical nets manually — for sensitive analog paths, differential pairs, or impedance-controlled traces, use add_wire or connect_pins directly, then let autowire handle the rest.
  • Use exclude_nets for partially-wired designs — if you have already connected some nets, exclude them to avoid duplicate labels.
  • Run ERC after autowiringvalidate_schematic confirms the wiring is electrically correct.

If autowire reports 0 nets classified:

  1. Check that kicad-cli is available — autowire needs it to export the netlist. Set KICAD_CLI_PATH if needed.
  2. Verify the schematic has components — an empty schematic has no nets to wire.
  3. Check if nets are already connected — autowire skips nets that appear in the connectivity graph. Run analyze_connectivity to see what is already wired.
  1. Check pin types in the netlist — a pin with power_in type will force POWER_SYMBOL even if the net name is unusual.
  2. Adjust thresholds — if too many nets get labels when you want wires, increase direct_wire_max_distance.
  3. Use only_nets/exclude_nets — wire the problematic net manually and exclude it from autowire.
  1. Provide a pre-exported netlist — use export_netlist to create one, then pass it as netlist_path.
  2. Check kicad-cli version — KiCad 9+ is required for the kicadsexpr format.
  3. Check schematic validity — run validate_schematic to catch structural issues.

The wiring strategy decision tree is informed by KICAD-autowire (MIT, arashmparsa), which demonstrated the concept of automated wiring strategy selection. The mckicad implementation is original, built on the existing batch pipeline.