Skip to main content
Design rules define the manufacturing constraints and electrical requirements for your PCB. The DRC (Design Rule Check) engine validates your layout against these rules to ensure manufacturability and correct operation.

Overview

KiCad’s design rule system is built around the DRC_ENGINE class (source/pcbnew/drc/drc_engine.h:131), which evaluates constraints and reports violations. Rules can be simple global settings or complex conditional expressions.

DRC Engine Architecture

DRC_ENGINE Class

Design Constraints

Clearance Rules

Minimum spacing between objects

Track Width

Trace width constraints

Via Size

Via diameter and drill limits

Differential Pairs

Coupled routing requirements

Rule Types

Clearance Constraints

Define minimum spacing between objects:
Electrical clearance between copper features:
Applies between:
  • Track to track (different nets)
  • Track to pad
  • Pad to pad
  • Zone to any copper

Track Constraints

Control trace geometry:
min/opt/max
Minimum: 0.127mm (5 mil) typical for fine-pitchOptimal: 0.254mm (10 mil) for standard signalsMaximum: Unlimited (or limited for controlled impedance)
minimum
Copper ring around drilled holeTypical: 0.15mm minimum for standard PCBs
allowed
Permitted routing anglesCommon: 45° or 90° only (avoid arbitrary angles)

Via Constraints

Typical values:
  • Standard Via: 0.6mm pad, 0.3mm drill
  • Micro Via: 0.4mm pad, 0.2mm drill (laser drilled)
  • Large Via: 1.0mm+ for high current

Differential Pair Rules

For high-speed signals (USB, LVDS, etc.):
USB 2.0 typically requires:
  • Gap: 0.127mm (5 mil)
  • Width: 0.254mm (10 mil)
  • Impedance: 90Ω differential

Custom Design Rules

KiCad supports advanced rule syntax for complex constraints:

Rule File Format

Rules are defined in the .kicad_dru file or board settings:

Rule Conditions

Filter rules using expressions:

DRC Test Providers

The DRC engine runs multiple specialized test providers:
1

Copper Clearance

Provider: drc_test_provider_copper_clearance.cppChecks spacing between all copper features on each layer.
2

Hole Size

Provider: drc_test_provider_hole_size.cppValidates drill diameters against manufacturing limits.
3

Track Width

Provider: drc_test_provider_track_width.cppEnsures all traces meet minimum/maximum width constraints.
4

Connectivity

Provider: drc_test_provider_connectivity.cppChecks for unconnected nets and starved thermals.
5

Schematic Parity

Provider: drc_test_provider_schematic_parity.cppVerifies PCB matches schematic netlist.
6

Silk Clearance

Provider: drc_test_provider_silk_clearance.cppPrevents silkscreen over pads and vias.
7

Text Dimensions

Provider: drc_test_provider_text_dims.cppValidates text size and stroke width.
8

Solder Mask

Provider: drc_test_provider_solder_mask.cppChecks solder mask clearance and bridging.

Running DRC

Interactive DRC

Run from the PCB editor:
  1. Inspect → Design Rules Checker
  2. Select test scope (entire board or specific area)
  3. Choose which violations to check
  4. Run tests and review violations
  5. Navigate to errors from the violations panel

Batch DRC

Run DRC from command line or CI/CD:

Violation Handling

The engine calls violation handlers for each error:

Clearance Caching

For performance, clearance values are cached:

Net Classes

Group nets with common requirements:
Assign nets to classes in schematic or PCB editor. Classes provide default values that can be overridden by specific design rules.

Manufacturing Limits

Typical PCB manufacturer capabilities:
  • Minimum trace: 0.127mm (5 mil)
  • Minimum clearance: 0.127mm (5 mil)
  • Minimum drill: 0.3mm (12 mil)
  • Minimum annular ring: 0.15mm (6 mil)

Best Practices

Begin with relaxed rules that match standard PCB capabilities. Tighten only where necessary for routing density or performance.
Group related nets (power, high-speed, differential pairs) into net classes. Apply class-specific rules rather than per-net rules.
Add comments in custom rules explaining the reasoning. Include links to datasheets or standards.
Run DRC frequently during layout. Fix violations incrementally rather than at the end.
Confirm your design rules match your chosen PCB manufacturer’s capabilities before finalizing the design.

Advanced Features

Length Matching

Ensure equal trace lengths for timing-critical nets:

Creepage and Clearance

For high-voltage designs:

Via Restrictions

Control via placement:

Source Code References

Next Steps

PCB Layout

Apply design rules during routing

Manufacturing Output

Generate fabrication files

Footprint Libraries

Design footprints meeting rules