Custom DRC exceptions showing as errors when running DRC from kicad-cli
Description
There is a difference in behavior between marking errors/warnings as exclusion in the DRC UI window versus adding custom rule text in the Board Setup > Custom Rules window.
Two example projects attached:
-
DRC excluded in UI, working as expected:
2025-11-15_kicad_drc_exclusion_comment.zip
(this project was taken from a separate but similarly related issue here)
-
DRC excluded by custom rule in .kicad_dru file, not working as expected
Project 1, working as expected
When something is excluded in the DRC window, a key is added to the drc_exclusions array in the kicad project file. For example:
"drc_exclusions": [
[ "silk_edge_clearance|112261905|89000000|11d5c14c-0d24-4c3b-b65b-c3c40e816487|921a8779-39ac-4b47-890b-219dabe9c9c3",
"User comment about why they excluded..."
]
],When DRC is run from the cli, the output JSON looks as expected. Note the "excluded": true line.
kicad-cli pcb drc --format json --severity-all -o out_working.txt /path/to/2025-11-15_kicad_drc_exclusion_comment.kicad_pcb
...
"violations": [
{
"comment": "We are not printing a silkscreen.",
"description": "Silkscreen clipped by board edge",
"excluded": true,
"items": [
{
"description": "Segment on Edge.Cuts",
"pos": {
"x": 110.0,
"y": 89.0
},
"uuid": "11d5c14c-0d24-4c3b-b65b-c3c40e816487"
},
{
"description": "Reference field of D1",
"pos": {
"x": 113.0,
"y": 89.0
},
"uuid": "921a8779-39ac-4b47-890b-219dabe9c9c3"
}
],
"severity": "warning",
"type": "silk_edge_clearance"
}
]Project 2, not working as expected
When creating DRC rules in the Board Setup > Custom Rules window, they are added to a separate file. This is the contents of the file from the second example project.
(version 1)
(rule "courtyard1"
(severity exclusion)
(constraint courtyard_clearance)
(condition "A.Reference == 'R1' && B.Reference == 'C1'")
)The output json from kicad-cli, however, is missing this excluded json key, making it appear as an actual DRC error still.
kicad-cli pcb drc --format json --severity-all -o out_not_working.txt /path/to/kibot-drc-repro.kicad_pcb
...
"violations": [
{
"description": "Courtyards overlap",
"items": [
{
"description": "Footprint C1",
"pos": {
"x": 155.842,
"y": 101.346
},
"uuid": "b90e1724-e645-4f6c-b6d2-95a1b76c433f"
},
{
"description": "Footprint R1",
"pos": {
"x": 156.337,
"y": 103.378
},
"uuid": "d15f09ae-a820-4064-9fb0-d73a428524b5"
}
],
"severity": "error",
"type": "courtyards_overlap"
}
]Steps to reproduce
Reproducing the expected case
- Download and unzip 2025-11-15_kicad_drc_exclusion_comment.zip project
- Note exclusion in kicad_pro file, run DRC in UI and note no errors with one excluded warning
- There might be footprint warnings from different kicad versions, ignore these
- Run
kicad-cli pcb drc --format json --severity-all -o out_working.txt /path/to/2025-11-15_kicad_drc_exclusion_comment.kicad_pcb - Note the excluded: true key in the json
Reproducing the non-expected case
- Download and unzip kibot-drc-repro.zip project
- Note exclusion in .kicad_dru file, but NO exclusions in kicad_pro file
- Run
kicad-cli pcb drc --format json --severity-all -o out_not_working.txt /path/to/kibot-drc-repro.kicad_pcb - Note that the severity of the one violation shows as error and there is no excluded flag. I would expect either the severity to show "excluded" or there to be an excluded: true KVP.
KiCad Version
Tested on kicad 9.0.7 and 10.0.1, here is my local version info. Issue also occurs on remote Ubuntu 24.04 VM using the kicad latest container.
Edit: re-pasting without gitlab formatting to hopefully pass the auto-closing bot check Application: KiCad PCB Editor arm64 on arm64
Version: 9.0.7, release build
Libraries: wxWidgets 3.2.8 FreeType 2.13.3 HarfBuzz 10.1.0 FontConfig 2.15.0 libcurl/8.7.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.64.0
Platform: macOS Sequoia Version 15.7.4 (Build 24G517), 64 bit, Little endian, wxMac OpenGL: Apple, Apple M1 Pro, 2.1 Metal - 89.4
Build Info: Date: Jan 1 2026 21:36:00 wxWidgets: 3.2.8 (wchar_t,wx containers) Boost: 1.87.0 OCC: 7.8.1 Curl: 8.7.1 ngspice: 44.2 Compiler: Clang 16.0.0 with C++ ABI 1002 KICAD_IPC_API=ON