KiCad PCB authoring

One of the kicad_skills usage guides for the eda CLI — all of them. Plain Markdown: read it directly, or hand it to whatever assistant you use.

How to lay out a board, for an agent that writes .kicad_pcb files. The board review guide covers judging one; this guide is the authoring direction, distilled from laying out five generated boards and fixing what their physics got wrong. Unlike the schematic side, almost every check here already existed as a rule — the improvements were in how to satisfy them, which is what this records.

The required checks

./bin/eda.sh pcb drc     hardware/                # KiCad's own DRC, zone-refilled
./bin/eda.sh pcb review  hardware/ --text         # the toolkit's rules
./bin/eda.sh gate        hardware/ --policy ai-generated --text

Run DRC through the toolkit, not raw kicad-cli: the wrapper refills zones first and uses consistent severities, and a raw run on the other KiCad version will report zone-fill artefacts that are not real. Where both KiCad images exist, run the wrapper under each — zone fill algorithms differ between releases.

Then render both sides and look at them:

./bin/eda.sh pcb render hardware/ -o /tmp/pcb --dpi 300 --views front back --no-3d

The rules see loop areas and track widths; only the plot shows a board that reads as machine work.

Floorplan before routing

Route quality cannot rescue a scattered floorplan. layout.connection_span builds the shortest possible tree between the footprints on each net and reports any single edge over 25 mm. It measures pad-to-pad Euclidean distance, not the copper, so an autorouter cannot make it pass by drawing a straight line and cannot make it fail merely by taking a detour.

Use it before routing: put the connector, protection, conversion, load and control blocks in signal-flow order; rotate packages so the pins face the block they serve; then run pcb review. Ground is excluded because its plane is global. A backplane or mechanically constrained front panel may genuinely need long connections; encode that fact as a project threshold or a net-specific waiver instead of training every generated board to accept it.

Decoupling: the loop is the deliverable

layout.decoupling_distance and layout.decoupling_via measure the two halves of one physical quantity — the loop inductance between an IC’s supply pin, its capacitor, and the plane.

Two layers and the return path

On a two-layer board the back is the ground plane, and every track routed on it cuts a channel through the plane. Any top-side signal crossing the channel has its return current detoured around it: the loop grows by the detour (route.return_path).

Static copper is a wall

Every via, track and pad you declare is an obstacle the router cannot move. The failures this caused, each costing a rip-up spiral or an unroutable net:

Corners, clearance, and sensitive paths

The board explains itself in silk

Building the board, not just routing it

Everything above is about whether the circuit works. This is about whether the board can be made — a separate question with its own failures, and the one an agent generating artwork forgets, because none of it shows up in a netlist.

Connectors, pours and returns

The numbers behind the look

A reviewer can tell a hand-routed board from an autorouted one across the room, and DRC, ERC and every list-shaped check pass both. The tell is statistical, and tools/board_signature.py measures it, so “looks autorouted” becomes a comparison instead of an opinion. Run it over KiCad’s own demo projects and your board side by side; the corpus baseline (16 parsable demo boards) for hand-routed two-layer work:

measure human range what a miss looks like
second-layer share of copper 10–47% everything on one face: the plane was priced as untouchable, so the front grew wandering channels
median segment length 1.8–3.5 mm 0.75 mm: the router’s grid cell became the drawing’s rhythm
corners per dm of track 9–25 38: the same stutter counted the other way
corner angles 91–98% at 45° staircases and odd angles are machine artefacts
vias per dm of track 0.3–16 a uniform stitching carpet reads as a printed pattern, not a decision

Three habits of the hand-routed boards are worth copying outright — all three are visible in one glance at the interf_u demo:

Width, angles, and what to waive

Where the rules live

eda gate --list-rules prints all of them. The ones this guide exists to satisfy: layout.decoupling_distance, layout.decoupling_via, layout.connection_span, route.return_path, route.detour, route.wander, route.acute_angle, track.thin_power, plus KiCad’s own DRC. What cannot be a rule — where to spend the escape budget, how hard to price the plane layer, when a crossing is cheap enough to keep — is this guide, and the rendered board.