Overview
KiCad’s design rule system is built around theDRC_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:- Copper Clearance
- Hole to Hole
- Edge Clearance
- Courtyard Clearance
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:Minimum: 0.127mm (5 mil) typical for fine-pitchOptimal: 0.254mm (10 mil) for standard signalsMaximum: Unlimited (or limited for controlled impedance)
Copper ring around drilled holeTypical: 0.15mm minimum for standard PCBs
Permitted routing anglesCommon: 45° or 90° only (avoid arbitrary angles)
Via Constraints
- 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.):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:Net-based Conditions
Net-based Conditions
Layer Conditions
Layer Conditions
Type Conditions
Type Conditions
Property Conditions
Property Conditions
DRC Test Providers
The DRC engine runs multiple specialized test providers:Copper Clearance
Provider:
drc_test_provider_copper_clearance.cppChecks spacing between all copper features on each layer.Hole Size
Provider:
drc_test_provider_hole_size.cppValidates drill diameters against manufacturing limits.Track Width
Provider:
drc_test_provider_track_width.cppEnsures all traces meet minimum/maximum width constraints.Connectivity
Provider:
drc_test_provider_connectivity.cppChecks for unconnected nets and starved thermals.Schematic Parity
Provider:
drc_test_provider_schematic_parity.cppVerifies PCB matches schematic netlist.Silk Clearance
Provider:
drc_test_provider_silk_clearance.cppPrevents silkscreen over pads and vias.Running DRC
Interactive DRC
Run from the PCB editor:- Inspect → Design Rules Checker
- Select test scope (entire board or specific area)
- Choose which violations to check
- Run tests and review violations
- 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:- Standard PCB
- Fine Pitch
- HDI / Advanced
- 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
Start Conservative
Start Conservative
Begin with relaxed rules that match standard PCB capabilities. Tighten only where necessary for routing density or performance.
Use Net Classes
Use Net Classes
Group related nets (power, high-speed, differential pairs) into net classes. Apply class-specific rules rather than per-net rules.
Document Special Rules
Document Special Rules
Add comments in custom rules explaining the reasoning. Include links to datasheets or standards.
Test Early and Often
Test Early and Often
Run DRC frequently during layout. Fix violations incrementally rather than at the end.
Verify with Manufacturer
Verify with Manufacturer
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