/jitx-skills:jitx-layout-constraintsfrom jitx-skills
Defines PCB layout constraints in JITX to meet electrical requirements: voltage clearance, current capacity, isolation, noise coupling, return paths. Covers net classes, clearance rules, pour rules, via stitching, fencing, and routing structures.
Ships in jitx-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill adds the constraints that make a layout perform electrically. JITX routes to the rules it is given: a board that builds clean can still arc across an isolation gap, overheat a power trace or couple a switch node into a receiver. Explanation: Layout Constraints.
Invoke the base jitx skill first. Add jitxexamples, with the bound in the base skill's Supported versions table, to the project's dependencies: the design calls its jitxexamples.patterns functions. An ImportError, or a TypeError from a named function, means an older copy: upgrade it, and if that does not bring the function in, list each value it would derive as an open item. Never drop a keyword, and never derive the value by hand instead.
Before writing a rule, read the schematic, the prompt and every document given (requirements, fab sheet, datasheets), and list what the layout must hold electrically. The user may name values, or only the board.
| Need | Why | Rule |
|---|---|---|
| Fab floor | copper under the fab's minimums is not built as drawn | the substrate holds it; board defaults at 0 sit at or above it |
| Current | a narrow trace drops voltage and heats | a class width on the net's tag |
| Working voltage | conductors too close at voltage arc or track | a clearance from the voltage class's tag to AnyObject at a protection rung |
| Isolation | a barrier part is only as good as the copper spacing across it | a clearance between the two domains' tags, each on every net of its domain, grounds included, at a protection rung |
| Impedance | a line off its impedance reflects and loses signal | a routing structure on the net's tag |
| Return path | return current follows the nearest reference; a gap in it radiates | stitching, fencing, a coplanar ground |
| Coupling | a noisy net beside a sensitive one couples into it | a clearance between the two classes' tags |
| Assembly | a pad tied solid into a plane sinks heat and solders poorly; a relieved one carries less current | relief per pad class, direct connect where current needs it |
Every value traces to the prompt, a rule the design already carries, a fab-sheet row by number, a datasheet or standard quoted from a document you were given, or a derivation with its arithmetic shown; for a function's value, the call, its inputs, the dataclass fields it returns (BgaEscape.channel_clearance, Escape.centreline_clearance, Escape.pad_gap) and the relation its docstring checks, with the numbers. Where nothing given settles a value (a 48 V or mains net with no spacing stated, an isolation rating with no barrier distance), name what would (the isolating part's datasheet, IPC-2221B's conductor spacing table, the product's safety standard such as IEC 62368-1, 61010-1 or 60601-1) and list an open item: never pick a number. No chart or formula of your choosing sets a width from a current: ask for the width, or the copper weight, temperature rise and sizing standard. A clearance rule holds distance across a layer's surface (copper to copper, hole or edge), so for copper on one surface with no slot between, where a source gives clearance and creepage, it takes the larger; distance through insulation between layers is an open item. A slot that lengthens a creepage path is a Cutout (jitx-code-layout) or a hole in the board outline (jitx-mechanical), held from copper by an IsHole rule.
In the completion, give each rule one line on what fails on this board without it (an arc, a short, a hot trace, a reflection, a cold joint, a trace that etches open at the fab's limit), not what the rule does.
design_constraint(c) is a one-condition rule; design_constraint(c1, c2) a two-condition rule, matched in either order (Design Constraints).
A condition is a Tag subclass declared at module scope (matching its subclasses too), a builtin (IsTrace, IsPour, IsVia, IsPad, IsCopper; conditions only, Tags(IsTrace) raises TypeError), IsHole (outline holes, cutouts and every via drill), IsBoardEdge, OnLayer(i) (0 top, -1 bottom), AnyObject, or a combination with &, | and ~.
A two-condition rule takes only .clearance(mm); the rest (.trace_width, .thermal_relief(gap_distance, spoke_width, num_spokes), stitching, fencing, routing structures) take one condition.
Higher priority= wins; at equal priority the more specific condition wins, object type tags first, so a PowerTag() width at 0 loses to the IsTrace default at 0. The loser is not applied, and nothing reports it. One ladder, commented beside the rules:
| Priority | Rules |
|---|---|
| 0 | board defaults |
| 1 | a layer's floors; the trace-to-pour rule |
| 2 | net-tag and pour-tag rules |
| 3 | pad, landpattern and component tag rules; a rule that must beat a rung-2 rule (a high-current or sense width, a heavy-layer copy) |
| 4 | escape segments; a direct connect |
| 5 or above | protections (isolation, voltage, keep-away, edge, hole), one rung each, the larger clearance higher |
(IsTrace & EscapeTag(), IsPad & PartPadTag()), not (EscapeTag(), AnyObject), with both tags assigned to the copper they mean.~SomeTag()) must hold on either side; excluding a whole tag withdraws the rule everywhere.Rules are found by walking the design tree: one at module scope, or built and dropped, does not exist. Board-wide rules go in the Design's self.rules = [...]; a circuit's rules still apply board-wide.
A tag on a Net reaches its traces, pours, pads, code-placed vias and Copper; on a Pad, Landpattern or Component, those pads; on a Route, its segments; on a Pour or Via, that object. TopologyNet, Copper, Circuit and ControlPoint also take tags; anything else, or a tag assigned outside a design context, warns and does nothing.
Unruled copper comes out at the fab floor, and a pad no relief rule matches joins its pour solid. Write only the defaults the board needs above the floor, each with its margin's source: design_constraint(IsTrace).trace_width(w), design_constraint(IsCopper, IsCopper).clearance(c), design_constraint(IsPad).thermal_relief(...), which matches every pad, so only a higher-priority direct connect joins one solid (layout_default_rules).
A class is a tag on its nets with its rules written once: PowerTag() width and (PowerTag(), AnyObject) clearance at 2; a subclass (HighCurrentTag(PowerTag)) takes its own width at 3. A Kelvin sense line shares the power net, so its SenseTag goes on the sense Routes, its width at 3. A class-to-class clearance, (RFLineTag(), NoisyTag()) or (PrimaryTag(), SecondaryTag()), keeps one class from another and leaves each one's own ground alone (layout_sensitive_net_clearance).
The coplanar cap: a board-wide clearance wider than a coplanar line's gap widens the gap of any line without a pair rule to its ground, unreported. Keep board clearances at or below the smallest coplanar structure's clearance: lower a fab-sheet value to it, cited as such; a wider prompt value is written as given and listed open, naming the clearance it exceeds. Set each gap with a pair rule (Fencing).
| Intent | Rule |
|---|---|
| Trace to pour | (IsTrace, IsPour) clearance at 1 |
| A net's pads and vias | the net tag's thermal_relief at 2 |
| Some pads | a tag on the pads, landpattern or component, relief at 3 (layout_thermal_classes) |
| Direct connect | no relief rule matching the pad; or DirectConnectTag on the pad, thermal_relief(gap, pad_diagonal, 4) at 4; measure the join, and give a pad that voids no relief rule |
| Sliver removal | pour_feature_size(min_width) on a pour tag |
| Edge; slots, cutouts, drills | (IsBoardEdge, AnyObject); (IsHole, AnyObject), at protection rungs (layout_edge_and_cutout) |
IsHole matches via drills: a hole rule wider than a via's pad pulls pours back from every other-net via. A plated through-hole pad's drill is untested (layout_edge_and_cutout): measure it or list it open.Empty: jitx-code-layout, pours.A heavy copper layer needs wider traces and gaps (layout_heavy_copper_layer). Cite the stackup row whose copper makes it heavy; heavy_layer_index(current.substrate) finds it, OnLayer(i) selects it, OnLayer.internal() matches every inner layer. A floor at 1 loses, unreported, to every rule at 2 or above, so heavy_layer_rules(layer, min_width, min_clearance, trace_to_pour, class_rules, exclude=...) returns the floors plus a copy at 3, at the floor, of each rule passed whose value is below it: every trace_width and two-condition clearance at 2 or 3 whose first condition is one tag. An escape, protection or pad-side rule at 3 or above on that layer meets the floor itself, or is an open item.
design_constraint(StitchedPourTag()).stitch_via(ViaClass, checked_stitch_grid(ViaClass, fab, pitch, inset)), the tag on each Pour (layout_stitched_pour); the vias take the pour's net.
inset runs from the via pad's edge to the computed pour boundary, and a site that fails it is dropped, never moved, unreported.checked_stitch_grid refuses a pitch below min_stitch_pitch. Clearance is not enforced between copper of the same net, so stitch via pads need no copper spacing between them.expected_stitch_sites(pours, via, grid, fab, pads=..., placed_vias=..., leave_out=...) once per group of pours stacked over one area, with captured Pour.shape in board frame, and leave_out for the band a fence displaces. A via outside the set is not a failure; an empty set is.A via fence keeps fields in and gives a line's ground a short return.
| Target | How |
|---|---|
| A pour outline | fence_via(ViaClass, ViaFencePattern(...)) on a tag on the Pour (fenced_pour_outline); offsets from the drawn outline, positive outward |
| A routed line | RoutingStructure.Layer(...).fence(ViaClass, ViaFencePattern(...), reference_layer=i), applied by a routing_structure rule; a copy with the same layer values when the substrate is not yours (layout_cpwg_two_row_fence); offsets from the trace edge |
fence_via rule fences no route, unreported.design_constraint(RFLineTag(), GroundTag(), priority=2).clearance(c_s) at the structure's clearance; with several coplanar structures on a net, at the smallest one's. The gap is coplanar_gap(structure_clearance, winning_rule_clearance); a keep-away from the line to AnyObject above 2, wider than the gap, pushes the ground out. Measure the realized gap.initial_offset + (k-1)·offset out; an unset initial_offset takes offset. JITX puts fence pads inside the gap unreported: checked_fence_pattern(pattern, via, pour_gap) refuses that.KeepOut(via=True) over a fence removes its vias, unreported: space other copper with a tag clearance.min_stitch_pitch the fab cannot drill it: check the pitch.fence_count_range per outline row and straight_run_fence_sites per side per row of a straight run, and assert that count, not that vias exist; identify fence vias by position on the derived row, not a distance band.The substrate defines structures; rules apply them (layout_routing_structure_by_tag): design_constraint(SignalTag(), priority=2).routing_structure(rs, ref_net=self.GND) with the tag on the net, or a tag on one segment's Route at 4. A rule beats a Constrain(...).structure(...) on the same net, unreported: use one.
When a class width does not fit its pads, keep the class rule and give the last segment its own Route and escape tag, width at 4, meeting the trunk at a RoutePoint (layout_qfn_escape, layout_bga_escape, layout_diff_pair_escape). Walk every pad the class reaches: one needs an escape when the width does not fit it or cannot keep the net's clearance to the pads it passes; where pads sit closer than the class clearance, say which, by how much, and what the escape relaxes. The escape clearance s_e is the net's governing clearance, or a lower one at or above min_copper_copper_space stated as relaxed for the escape only, with its reason; where the governing clearance leaves only the fab-minimum width, lower s_e to widen the escape, and say so. Never type the width: layout_qfn_escape.derive_escape or layout_bga_escape.derive_escape(..., escape_clearance=s_e) returns it, or escape_width(pad_width, c, s_e, fab) for other geometry; one tag over several pads takes the smallest. If it raises with s_e at min_copper_copper_space, no legal escape fits: list it open. A floor-valued clearance to AnyObject at 4 loosens every escape's surroundings.
A rule that builds is not a rule that applied. Build, rd.capture(), and read the captured copper (verification): widths, distances between the copper each clearance relates (pads included), relief voids and spokes, generated vias against expected sites and counts, rd.issues(satisfied=True).
Polygon, or with no traces (a width override under a rule it already matches can do this): a width check fails on either, never skips it.Copper placed from code is drawn as written whatever the rules say (routes other than an envelope section keep their clearance to it): check it.status: ok is not proof.min_copper_* floor (not a routing_structure rule, whose width and pair gap override the floors), or keyed on a tag not on the Pour.Tags and rules are structural objects on self, never keyed by an assembled string (jitx-code-review). The completion block (jitx-project-builder references/completion-blocks.md) lists each rule with its value's source and the need it holds, the checks with command and exit code, and open items.
evals/cases/apply-routing-structures.json (opens in a new tab)evals/cases/bga-power-escape.json (opens in a new tab)evals/cases/default-net-classes.json (opens in a new tab)evals/cases/edge-and-isolation-slot.json (opens in a new tab)evals/cases/electrical-needs-from-context.json (opens in a new tab)evals/cases/fence-cpwg-two-rows.json (opens in a new tab)evals/cases/fence-pour-outline.json (opens in a new tab)evals/cases/fine-pitch-high-clearance-escape.json (opens in a new tab)evals/cases/fixtures/apply-routing-structures/fixture_apply_routing_structures.py (opens in a new tab)evals/cases/fixtures/bga-power-escape/fixture_bga_power_escape.py (opens in a new tab)evals/cases/fixtures/common/lc_fixture_util.py (opens in a new tab)evals/cases/fixtures/common/lc_power_board.py (opens in a new tab)evals/cases/fixtures/common/lc_radio_board.py (opens in a new tab)evals/cases/fixtures/common/lc_substrate.py (opens in a new tab)evals/cases/fixtures/common/pellingham_lc_fab_sheet.md (opens in a new tab)evals/cases/fixtures/common/pyproject.toml (opens in a new tab)evals/cases/fixtures/default-net-classes/fixture_default_net_classes.py (opens in a new tab)evals/cases/fixtures/edge-and-isolation-slot/fixture_edge_and_isolation_slot.py (opens in a new tab)evals/cases/fixtures/electrical-needs-from-context/corrow_cpi4833_excerpt.md (opens in a new tab)evals/cases/fixtures/electrical-needs-from-context/fixture_electrical_needs_from_context.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub jitx-inc/jitx-skills --plugin jitx-skills13 skills in this plugin
/jitxBase skill for JITX Python PCB design: install, the jitx CLI, auth and the runtime, building designs, the viewers, exports, code quality (ruff, pyright, type annotations, check.py and grep gates), and design introspection (jitx.inspect, jitx.query, runtime submit). Use to set up JITX, start the runtime, build or find a design, open the viewer, fix a build or environment error, or find things in a design from Python. Route a whole board from requirements to jitx-project-builder, code self-review to jitx-code-review, component modeling to jitx-component-modeler, wiring and passives to jitx-circuit-builder, stackups to jitx-substrate-modeler, layout in code and realized-geometry checks to jitx-code-layout, open-layout place and route to jitx-interactive-layout, design rules, stitching, fencing and routing structures by tag to jitx-layout-constraints, SI constraints to jitx-interconnect-constraints, pin flexibility to jitx-pin-assignment, mechanical CAD to jitx-mechanical, and JLCPCB fab and parts to jitx-jlcpcb./jitx-circuit-builderUse when the user asks to "wire up", "connect", "build a circuit", create an "application circuit", declare a circuit's typed ports or bundles (Power, I2C, RGMII), compose sub-circuits into a hierarchy and connect them port to port, "place components" or sub-circuits (fixed or floating), add passives (resistors, capacitors, inductors) or decoupling, or set up power connections. Covers the Circuit class, nets and the + operator, typed ports, hierarchy, placement, and jitxlib-parts passives. Drawing a pour or copper is jitx-code-layout; pour rules are jitx-layout-constraints; provide/require pin assignment is jitx-pin-assignment.Other plugins' skills for the same job