Skip to content

KiCadRoutingTools: preserve project rules

Checked on 2026-10-18 with KRT plugin 0.22.1 / Rust router 0.22.0, KiCad 10.0.7 and the bundled Python 3.9 on Apple Silicon.

Every KRT routing command in this project must use both controls:

export KICAD_INRUN_FLOOR_SYNC=0

Also pass --no-fix-drc-settings to each routing command. The environment variable disables the intermediate project-rule sync. The CLI flag disables the final project-settings write. Both controls are required to preserve the project rules. Keep authored constraints as the validation authority; do not accept a route by lowering its DRC requirements.

Codex environment

The repository's .codex/config.toml sets:

[shell_environment_policy.set]
KICAD_INRUN_FLOOR_SYNC = "0"

Codex loads project configuration for trusted projects and injects the value into spawned commands. A running session may need to reload before it uses the new configuration; check the actual command environment. Keep passing --no-fix-drc-settings explicitly. The setting is project-scoped and does not change an already-running KiCad GUI or ordinary terminal shells. For commands outside Codex, prefix the routing invocation with KICAD_INRUN_FLOOR_SYNC=0 or export it in that shell.

Use the KiCad-compatible interpreter (KICAD_PYTHON) for the installed toolchain. On this macOS installation, the PCM package is under ~/Documents/KiCad/10.0/3rdparty/plugins/com_github_drandyhaas_kicadroutingtools/; the routing entry point is py_router/route.py. Its GUI-installed dependencies are in KiCad's bundled Python environment. No separate MCP server is needed to invoke the CLI.

Observed failure and workaround

The smoke test copied the microphone breakout under build/, removed its five /CLK segments with KiCad's native API, and routed that net with --no-fix-drc-settings --escalation off. The input project declared:

Setting Input KRT output with only the CLI flag
Default net-class clearance 0.20 mm 0.20 mm
Minimum copper-to-hole clearance 0.25 mm 0.20 mm

In the installed py_router/route.py, the intermediate apply_routed_floors() call passes clearance=config.clearance without a separate hole-clearance argument. compute_targets() in fix_kicad_drc_settings.py falls back to that copper-clearance value for min_hole_clearance. The intermediate call checks KICAD_INRUN_FLOOR_SYNC but does not check --no-fix-drc-settings.

The router's obstacle-building log explicitly used the original 0.25 mm hole clearance. Independent KiCad DRC with the original project rules restored found zero errors and zero unconnected items. It retained two missing-library warnings from the isolated copy and added one track-endpoint/via-centre warning.

A repeat with both controls routed the net successfully and preserved the entire input project JSON unchanged. Footprint/pad-net and other-net copper preservation were checked on the first run. This is a bounded tool smoke test; it does not validate KRT's handling of the ear's flex constraints or every custom rule.

The local evidence is in build/work/krt-smoke-20261018-p70152yx/: routing.log, krt-project-changes.json, routed-drc.json, verification.json and the repeat under no-floor-sync/. These are ignored derived outputs.

For future routing, copy all relevant PCB/project/rule inputs under build/, hash the sources, compare the resulting project rules, and run KiCad DRC against the authored constraints. Recheck the workaround after KRT updates.

Upstream status

Filed #1285: CLI --no-fix-drc-settings still lowers min_hole_clearance via in-run floor sync on 2026-10-18 after searching existing issues and pull requests. The report includes the reproduction command, observed settings change, relevant code paths, verified workaround and a link to #693. No board files were attached. Related reports are:

Keep both workaround controls until the CLI defect is fixed and reverified.