KiCAD Custom DRC Rules

I got a board sent back by JLCPCB the other day due to a DRC rule I haven’t come across before. The rule is:

If the copper area is less than 30% of the outer layers then the trace-trace space should be at least 0.15mm.

This is in contrast to their normal specification of 0.9mm. So this called for a custom DRC rule.

(version 1)
(rule top_bottom_clearance
	(constraint clearance (min 0.15mm))
	(condition "A.Layer == 'F.Cu' || A.Layer == 'B.Cu'"))

Worked great!

The editor is reactive and suggests valid keywords which made writing the rule almost as easy as clicking a box.