Writing

PCB design rules:
classes, keepouts and placement areas

Set a fab's limits in one step, give some nets their own clearance and width, keep copper out of an area, and hold a group of parts inside another. Checks, the autorouter, the pours and Sakura all read the same rules.

By the Cherry Blossom team

Where do you set PCB design rules?

In the Inspector, with nothing selected. It shows the project, and four of its sections hold the rules: Design rules, Net classes, Clearance rules and Nets. There is no separate rules dialog, and every length shows in mm or mil, whichever you prefer.

Start with Fab capability. It sets the limits a fab decides in one step: Conservative (8 mil), Standard (6 mil), Fine (5 mil) or Advanced (4 mil). Change any value after that and the field reads Custom. Under it the rules are grouped as traces, clearance (copper to copper, copper to board edge, hole to hole), vias and holes, solder mask and paste, and copper pours. Every rule there is used by routing, the pours, Checks or the Gerbers.

At a glance

Which rule does what?

Five kinds of rule, and the parts of the editor that follow each one.

RuleWhat it setsFollowed by
Design rulesBoard-wide limits: trace width, copper to copper, copper to edge, hole to hole, vias, mask and paste, poursChecks, the autorouter, new traces and vias, pours, the Gerbers
Net classesA clearance, trace width and via size for a group of netsChecks, the autorouter, new copper, pours, the KiCad export, fabrication notes
Clearance rulesA clearance for one pair of nets, or for one part's pads against every other netChecks, the autorouter, pours, stitching vias, the KiCad export, fabrication notes
KeepoutsKeep tracks, vias, pads, pours or parts out of an areaThe autorouter (tracks and vias), pours, Re-pack (parts), Checks (all five)
Placement areasHold the parts of a sheet, a component class or a group inside an areaRe-pack and Sakura's layout place them inside; Checks reports any outside

How do net classes work?

A net class gives a group of nets its own clearance, trace width and via size, so supply nets can be wide and high-voltage nets far apart while signals stay small. Every net starts in the Default class, which is the design rules. Click Add under Net classes, name the class, then list its nets or give Patterns: net names with * and ?, or a regular expression, as KiCad’s net class patterns work. A net is in the first class that lists it, then the first whose pattern fits.

Two nets are checked at the larger of their classes’ clearances, never below the board’s minimum. The autorouter lays each net at its class’s width with its class’s vias, and a class’s clearance widens a pour’s gap round that net. A class’s trace width is what new copper starts at; Checks doesn’t test traces against it, and KiCad doesn’t either. One net can also get its own width in the Nets section (Trace width for the net), which wins over its class.

When do you need a clearance rule instead?

When one pair of nets, or one part’s pads, needs a different gap from the one their classes give. A class holds its nets the same distance from every other net, which can’t say that a relay’s contacts sit closer than its Mains class allows, or that two nets need more room than their classes ask for.

Under Clearance rules, pick a net and another net and press +, or choose Add one for a part’s pads. Set the clearance, larger or smaller than the classes’. Where several rules apply, the largest wins, and the board’s minimum clearance still holds. Checks, the autorouter, the pours and the stitching vias all use it, and the KiCad export writes it as a custom rule in a .kicad_dru file.

How do you keep copper or parts out of an area?

Draw a keepout, for example under a module’s antenna or round a mounting hole. Press K, or pick Draw a keepout from the zone tools, and click the corners of the area. The Inspector’s Keeps out switches choose what it forbids: tracks, vias, pads, copper pours and parts. A new keepout starts with tracks, vias and pours, on the layer shown.

The autorouter routes no track or via through it, pours leave it empty with no gap, and Re-pack places no part in it. Checks reports each case as an error, such as “A via is inside a keepout that keeps vias out”, and names the keepout when you have named it. Keepouts inside a footprint, which come with a KiCad board, move, turn and flip with the part, and the router, pours and Checks follow them too.

How do you keep a group of parts together?

Draw a placement area, so a power stage or an analog front end stays where you want it each time the board is laid out again. Press J, or pick Draw a placement area, and click its corners. In the Inspector, Holds the parts of picks whose parts belong in it: the parts of a schematic sheet, of a component class, or of a group. A line under it says how many parts it picks and which are outside. A part gets classes in its own Inspector, under Component classes, separated by commas.

Re-pack and Sakura’s layout pack those parts inside the area. When Sakura moves one with place_parts, it goes to the nearest spot inside, or the move is refused with a note to make the area bigger. A part dragged by hand is not held in, so Checks reports one left outside as an error. On export the area is written as a KiCad 9 placement rule area, and an area for a group, which is KiCad 10’s, is written switched off with a note. If your schematic is split into sheets, one area per sheet keeps each sheet’s parts together on the board (more on sheets in blocks, Tidy and sheets).

What about backdrill, via filling and length tuning?

These show on a board with a stackup: in the project’s Copper layers section, set Layers to 4 or more and apply, or import a multilayer board from KiCad. A via’s Inspector then has IPC-4761 protection (Filling, Capping, and Covering and Plugging on each side), a Backdrill and a Tertiary drill with their size and the layers they run between, and Post-machining on each side as a counterbore or a countersink. The board’s own defaults sit with the design rules.

The drill export writes two Excellon files for each backdrill span, the Gerbers add a file for each protection step, and the fabrication notes list both under VIA PROTECTION and BACKDRILL AND POST-MACHINING.

Tuning patterns come in with a KiCad board. Select one to change its target, shortest and longest length, spacing and largest bend; the numbers are kept for the next tuning, and Take apart leaves plain tracks. On a board with tuning patterns, the trace Inspector also shows the net’s length: tracks, vias, inside the package and in total. The fabrication notes list them under TUNING AND LENGTHS. For the rest of what a KiCad board keeps, see the KiCad import post.

Can the AI set design rules?

Yes. Sakura reads the rules with get_design and sets them with set_design_rules, set_net_class, set_net_width and set_clearance_rule. It draws keepouts and placement areas with set_pour, gives parts classes with update_component, and keeps a part inside its area when it moves it. draw_trace refuses a trace that would add a clearance, board edge or keepout error the board didn’t have.

Via protection, backdrills and tuning patterns are read-only to it: it can see them, and you change them. An AI assistant of your own gets the same tools through the MCP server, on every plan. The rest of what Sakura does is in what our AI agent can do.

Start for free
Honest limits

What don't the rules cover yet?

Read these before you rely on a rule for a board you are about to order.

Routing and checks

  • The autorouter routes the two outer layers only.
  • A class’s differential pair and micro via sizes are kept and exported, but nothing routes or checks them yet.
  • A class’s trace width is not a check.
  • A part dragged by hand can leave its placement area; Checks then reports it.

KiCad files

  • Of a .kicad_dru rules file, only the courtyard overlap rule is applied. The rest is kept.
  • The editor can’t draw a new tuning pattern; they come from a KiCad import.
  • The KiCad export writes KiCad 9 files, which can’t hold via protection, backdrills or post-machining, so they are left out of it.

Questions

Open the PCB, select nothing, and the Inspector shows the project with four sections for rules: Design rules, Net classes, Clearance rules and Nets. Pick a Fab capability first (Conservative 8 mil, Standard 6 mil, Fine 5 mil or Advanced 4 mil) to set a fab's limits in one step, then change any value by hand. Lengths show in mm or mil.

A net class is a named group of nets that share a clearance, a trace width and a via size, so power nets can be wider and further apart than signals. In Cherry Blossom every net starts in the Default class, which is the design rules. You add a class with Add under Net classes and list its nets by name or by pattern, such as USB_*.

A keepout is an area of the board where certain things may not go. In Cherry Blossom you draw one with K and choose what it keeps out: tracks, vias, pads, copper pours or parts. The autorouter avoids it for tracks and vias, pours leave it empty, Re-pack keeps parts out, and Checks reports anything inside as an error.

A placement rule area is a region where a set of parts has to sit: the parts of one schematic sheet, of one component class, or of one group. KiCad 9 added them, and Cherry Blossom reads and writes them. You draw one with J, and Re-pack, Sakura and Checks keep those parts inside it.

Yes. It lays each net at its class's trace width with its class's vias, keeps the larger of two classes' clearances between two nets, follows clearance rules, and stays out of keepouts that keep out tracks or vias, including keepouts drawn inside a part's footprint. It routes the two outer layers only, and does not route differential pairs.

Yes, on a board with a stackup (four copper layers or more, or a board imported from KiCad). A via can have IPC-4761 protection (filling, capping, covering, plugging), a backdrill and a tertiary drill, and a counterbore or countersink. The drill export writes two files per backdrill span, the Gerbers add a file per protection step, and the fabrication notes list both. The KiCad export, which writes KiCad 9 files, leaves them out.

Net classes and design rules from the project file come in, along with placement rule areas, component classes and tuning patterns. Of a .kicad_dru rules file, only the courtyard overlap rule is applied; the rest is kept. On export, net classes go back into the .kicad_pro and clearance rules are written as custom rules in a .kicad_dru.

Set your board's rules once.

Checks, the autorouter, the pours and Sakura all follow them.

By signing up, you agree to our Terms of Service and Privacy Policy.