Create a .rules file in /etc/udev/rules.d/ with a numeric prefix (e.g., 99-mydevice.rules) — files without a .rules extension are ignored
Write match rules using SUBSYSTEM, ATTR, KERNEL, or other key-value pairs followed by assignment rules (NAME, SYMLINK, MODE, OWNER, GROUP, RUN, etc.) on the same line
Use ACTION=="add" or ACTION=="remove" to restrict rules to specific device events
Run udevadm control --reload-rules to reload all rules files without rebooting
Test with udevadm test /sys/path/to/device to see which rules would match and what actions would be taken
For persistent rule ordering, prefix filenames numerically: lower numbers are processed first (e.g., 10-early.rules runs before 99-late.rules)
Known gotchas
All rules files across all udev rules directories (/usr/lib/udev/rules.d, /usr/local/lib/udev/rules.d, /run/udev/rules.d, /etc/udev/rules.d) are sorted and processed together in lexicographic order by filename — a file named 10-foo.rules in /etc/ is processed before 50-bar.rules in /usr/lib/ regardless of directory
When files share the same filename across directories, /etc/udev/rules.d takes highest priority over /run/udev/rules.d which takes priority over /usr/lib/udev/rules.d — this allows local overrides of vendor-supplied rules without modifying system files
udev processes ALL matching rules in order — it does not stop at the first match; use GOTO and LABEL to skip sections, and use OPTIONS+="last_rule" (deprecated) or structured labels to short-circuit further processing when needed
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp