[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71S113XAE1RPP5B4TZJJCGW":3,"skill-same:01M71S113XAE1RPP5B4TZJJCGW":46},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":6,"updatedAt":31,"install":32,"resources":45},"01M71S113XAE1RPP5B4TZJJCGW","b123d-repair",null,"pzfreo\u002Fbuild123d-mcp","pzfreo","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1773202?v=4","01M71S0HXPCECNMYJD3RJ6QKE5","Paul Fremantle","01M71S0HYR5GR026NQN2V9P3NQ",151,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fpzfreo\u002Fbuild123d-mcp\u002Fblob\u002Fmain\u002Fsrc\u002Fbuild123d_mcp\u002Fskills\u002Fb123d-repair\u002FSKILL.md",[],[18,19],"repair","b123d repair","2026-11-10 13:02:02",false,"# Repair Invalid Geometry with build123d (b123d-repair)\n\nUse this skill when `validate()` or the `export()` gate reports FAIL on a shape —\nan imported STEP that arrives broken, or a solid your own construction damaged —\nand the goal is a watertight, manifold, BRepCheck-valid solid that passes the\nexport gate **without changing the geometry** beyond the defect itself.\n\nEvery recipe here was proven on a real defective part; each entry says when it\napplies, when it fails, and what to try next. Work the ladder in order — the\ncheap fixes first — and verify every attempt with the **export gate**, not\n`validate()` alone (Step 2 explains why).\n\nThis skill is deliberately an agent-authored repair workflow, not an automatic\nhealer. The MCP server should help you write better build123d\u002FOCP code by\nanswering:\n\n- `validate()` \u002F `export()` — is the current or written shape structurally\n  acceptable?\n- `locate_gate_defects()` — where is the failing face, edge, or mesh defect?\n- `find_bored_bosses()` — when a failed edit involved extending a bored boss,\n  which bore\u002Fcap candidates exist, and whether the cap is split across several\n  faces?\n- `repair_advice()` — which field-proven, generic repair\u002Fedit recipe fits this\n  defect and requested goal, with acceptance checks and stop conditions?\n- this repair skill — which generic repair pattern fits that defect class?\n\nThe geometry-changing repair itself should be explicit code in `execute()`,\nwith named variables, printed measurements, `save_snapshot()` \u002F rollback\npoints, and a visible volume\u002Fbbox\u002Fgate audit. Do not delegate the repair to an\nopaque MCP tool that silently manipulates the B-rep and returns a shape; that\nprevents the agent from reasoning about design intent and makes a\nsuccessful repair hard to distinguish from accidental geometry surgery.\n\n---\n\n## Step 0 — Diagnose before cutting\n\nDo not apply repairs blind. First identify the defect class and its location.\n\n1. **Read the gate output precisely.** The FAIL reason names the class, and the\n   class picks the recipe:\n   - `B-rep is not well-formed (BRepCheck failed)` → a malformed face\n     (usually unorientable, zero-area, or reversed) — Step 1, rungs 1-4.\n   - `N open edge(s) — not watertight` → unsewn\u002Fmissing faces — rungs 4-5.\n   - `N non-manifold edge(s)` → an edge shared by 3+ faces — usually a\n     coincident-face construction defect; prefer re-construction (Step 4)\n     over surgery.\n   - `mesh open edge(s)` \u002F `mesh non-manifold` \u002F `face(s) failed to\n     tessellate` **with `brep_valid: true`** → a mesh-only defect (a\n     ~zero-area unmeshable face, or a self-touch) — rung 5.\n   - `face(s) failed to tessellate at a finer mesh deflection`\n     **with `brep_valid: true`** → a tolerance-sensitive mesh-only defect:\n     the face meshes at the default gate deflection but fails when a downstream\n     consumer asks for a finer mesh — rung 5, using the re-patch\u002Fre-sew variant.\n   - `vertex(es) where a tessellated edge endpoint misses its BREP vertex`\n     **with `brep_valid: true`** → a mesh-only defect too, but a different\n     one from the two above: a previously-patched\u002Fhealed face's boundary is\n     topologically closed (so BRepCheck and even `mesh open edge(s)` can both\n     read clean) but geometrically off-vertex by a fraction of a millimetre —\n     rung 5, using its re-patch-at-tighter-tolerance variant, not the\n     drop-and-sew one.\n2. **Get coordinates.** `locate_gate_defects()` returns the failing edge\u002Fface's\n   3D position and B-rep identity — repair that exact spot, never chase the\n   defect blind. Read its top-level `diagnosis` block too: `primary_kind`,\n   `diagnostic_classes`, and `repair_families` tell you which rung to try first,\n   while each defect's `next_step` says what explicit `execute()` repair to\n   write and reminds you to verify the written STEP with `export()`.\n   If the defect belongs to a known hard pattern, call `repair_advice()` with the\n   gate output as `error_text`, the requested edit as `goal`, and the defect\n   coordinates as `context`. Use the returned recipe as a checklist for your own\n   `execute()` code; do not treat it as a geometry-mutating tool.\n3. **Localize the face** when BRepCheck is the failure — build ONE analyzer\n   over the whole solid, not one per face (`locate_gate_defects()` itself\n   runs out-of-process specifically because per-face BRepCheck work \"can run\n   for minutes on a complex part\"; reconstructing an analyzer per face inside\n   `execute()` on a large import risks the same timeout):\n\n   ```python\n   from OCP.BRepCheck import BRepCheck_Analyzer\n   analyzer = BRepCheck_Analyzer(part.wrapped)   # one pass over the whole solid\n   suspects = [\n       (i, f.geom_type, round(f.area, 6), f.center())\n       for i, f in enumerate(part.faces())\n       if not analyzer.IsValid(f.wrapped) or abs(f.area) \u003C 1e-6\n   ]\n   print(suspects)   # match centers against locate_gate_defects() coordinates\n   ```\n\n4. **Decide: inherited or self-introduced?** If the shape was valid before your\n   last operation, the defect is self-introduced — `restore_snapshot()` and\n   rebuild that step using the avoidance rules in Step 4 instead of operating\n   on the damaged result. Surgery is for defects you cannot construct away\n   (imported files, or upstream steps too expensive to redo).\n\n---\n\n## Step 1 — The repair ladder (cheapest first)\n\nTry each rung in order; verify with Step 2 after every attempt; stop at the\nfirst rung whose result passes the export gate.\n\nEvery rung below wraps its raw OCCT result with `as_solid()`, not a bare\n`Part(...)` call — `Part(raw_shape)` has been observed to silently report\n`volume=0` on a genuinely healed shape (`IsDone()` True, geometry fine), and a\nbare `Solid(raw_shape)` throws `Standard_TypeMismatch` whenever the shape is a\n`Compound` rather than a plain `Solid` — which is the normal case for anything\nbuilt with build123d's own operators (even a plain `Box()`), not just imported\nSTEP files. Define this once and reuse it for every rung:\n\n```python\nfrom build123d.topology.shape_core import downcast  # OCP 7 and 8 alike\nfrom OCP.TopAbs import TopAbs_SOLID, TopAbs_SHELL, TopAbs_COMPOUND\nfrom OCP.TopoDS import TopoDS_Iterator\nfrom OCP.ShapeFix import ShapeFix_Solid\n\ndef as_solid(shape):\n    \"\"\"Wrap a raw TopoDS_Shape (Solid, Compound, or sewn Shell) with a correct volume.\"\"\"\n    st = shape.ShapeType()\n    if st == TopAbs_SOLID:\n        return Solid(downcast(shape))\n    if st == TopAbs_SHELL:\n        return Solid(ShapeFix_Solid().SolidFromShell(downcast(shape)))\n    if st != TopAbs_COMPOUND:\n        raise RuntimeError(f\"no solid or shell found in shape of type {st}\")\n\n    # Walk direct children only (TopoDS_Iterator, not a recursive TopExp_Explorer),\n    # recursing into nested compounds — so a solid sitting next to a stray shell\u002F\n    # face is rejected as mixed content instead of silently ignored.\n    solids, shells, mixed = [], [], False\n    stack = [shape]\n    while stack:\n        it = TopoDS_Iterator(stack.pop())\n        while it.More():\n            child = it.Value()\n            cst = child.ShapeType()\n            if cst == TopAbs_SOLID:\n                solids.append(downcast(child))\n            elif cst == TopAbs_COMPOUND:\n                stack.append(child)\n            elif cst == TopAbs_SHELL:\n                shells.append(downcast(child))\n            else:\n                mixed = True\n            it.Next()\n\n    if mixed or (solids and shells):\n        raise RuntimeError(f\"mixed topology in a {st} — expected only solids or only shells\")\n    if len(solids) == 1:\n        return Solid(solids[0])\n    if len(solids) > 1:\n        raise RuntimeError(\n            f\"expected 1 solid, found {len(solids)} in a {st} — \"\n            \"the operation likely didn't fully merge\"\n        )\n    if len(shells) == 1:\n        return Solid(ShapeFix_Solid().SolidFromShell(shells[0]))\n    if len(shells) > 1:\n        raise RuntimeError(\n            f\"expected 1 shell, found {len(shells)} in a {st} — sewing likely split the part\"\n        )\n\n    raise RuntimeError(f\"no solid or shell found in shape of type {st}\")\n```\n\nNever silently pick a solid\u002Fshell out of several, and never ignore other\ntopology sitting alongside one — a compound with more than one solid\u002Fshell, or\na mix of a solid plus a stray shell\u002Fface, almost always means the operation\ndidn't fully merge or a sew split the part, and picking one candidate\narbitrarily reintroduces the exact silent-partial-volume bug this helper\nexists to eliminate. Sanity-check the wrapped result's volume against the\npre-heal volume every time regardless — whichever wrapper you use, a wrapping\nbug or a genuinely bad heal both show up the same way (a wrong or zero\nvolume), so the check is what actually tells them apart.\n\nBecause build123d-mcp's `execute()` namespace persists across calls, a rung\nwhose attempt raises does **not** clear a previous rung's `healed` — reassign\n`healed = None` before each attempt and check `healed is not None` before\ntrusting it, rather than assuming a bare reference reflects the rung you just\ntried.\n\n### Rung 1 — `ShapeFix_Shape` (seconds, non-destructive)\n\nFixes reversed faces (a boolean can flip a distant face — e.g. a hole-bottom\nsphere reporting negative area) and zero-area sliver faces a boolean leaves\nelsewhere on an imported shape.\n\n```python\nfrom OCP.ShapeFix import ShapeFix_Shape\nfix = ShapeFix_Shape(part.wrapped)\nfix.Perform()\nhealed = as_solid(fix.Shape())\n```\n\nFails when: the face is genuinely unorientable (its own wire is inconsistent) —\nShapeFix reports success but the export gate still FAILs. Move to rung 2.\n\nThis rung operates on the whole shape, so it's the one place this ladder's\n\"only touch the defect\" discipline needs a caveat: the standing rule to\n**prefer targeted solid repair over broad shape healing** (global healing\ncan reorient faces or collapse volume) still applies here. Treat `healed`\nas a candidate, not the result — the Step 2 volume\u002Fbbox check is what makes\nthis rung safe to try first; if it moves anything beyond the defect's own\nfaces, discard it and go straight to rung 3 (defeature), which is targeted\nby construction.\n\n### Rung 2 — a clean boolean heals the B-rep\n\nA well-formed OCCT fuse forces a full re-computation of the shell and can heal a\nBRepCheck-invalid import as a side effect. Fuse with a small solid that\ninterpenetrates the part somewhere harmless (or union two halves of the part).\n\nCautions, both observed in the field:\n- **Booleans can silently DROP an invalid solid** — always check\n  `healed.volume` is within a fraction of a percent of the original.\n- On a **self-intersecting** import, build123d `Part` operators can inflate\n  volume; use the raw OCCT API on the bare solid instead:\n\n  ```python\n  from OCP.BRepAlgoAPI import BRepAlgoAPI_Fuse\n  op = BRepAlgoAPI_Fuse(part.solids()[0].wrapped, tool.wrapped)\n  op.Build()\n  healed = as_solid(op.Shape())\n  ```\n\n### Rung 3 — defeature the malformed face\n\n`BRepAlgoAPI_Defeaturing` removes the named face(s) and extends the neighbours\nto close the gap — the right tool when the defect is a discrete face and its\nneighbours are healthy. Also removes a feature's faces cleanly (grooves, bores)\nwithout plugging.\n\n```python\nfrom OCP.BRepAlgoAPI import BRepAlgoAPI_Defeaturing\ndf = BRepAlgoAPI_Defeaturing()\ndf.SetShape(part.wrapped)\ndf.AddFaceToRemove(bad_face.wrapped)\ndf.Build()\nhealed = as_solid(df.Shape())\n```\n\n**Volume check is mandatory**: defeaturing can silently *fill an internal\nbore* whose wall included the removed face (observed: +14% volume — a ruined\npart that passed the gate). Accept the heal only if the volume delta is on the\nscale of the defect itself, not of a feature.\n\nFails when: the sliver's neighbours can't extend to close the gap, the\ndefeature output fails the gate, or the (correctly-wrapped) healed volume\ncomes back zero or wildly different despite `IsDone()` reporting success —\ndefeaturing can silently produce a degenerate shape on a genuinely\nnon-planar\u002Fcomplex face, not just run slowly or need a longer timeout. Don't\nretry with different tolerances; move to rung 4.\n\n**If it's just slow, don't wait it out — kill it and move on.** A stubborn\nface's `Build()` can run past the `execute()` timeout in-session, and running\nit as a standalone script (Step 5) can *also* run for many minutes with no\noutput. Give a standalone attempt one bounded check (a `ps`\u002Ftimeout, not open-\nended watching); a defeature that hasn't finished by then is exactly as\ndiagnostic as one that returned a bad result — kill the process and move to\nrung 4 rather than continuing to wait. Field evidence: on the same class of\ndefect, sessions that killed a hung defeature within seconds and escalated\nhad budget left to reach a working repair; a session that let a standalone\ndefeature run past its timeout window before giving up did not.\n\n### Rung 4 — face surgery for an unorientable sliver\n\nThin sliver faces (a degenerate fillet remnant, a band between near-coincident\narcs) are the classic BRepCheck killer on imported castings. Escalate through\nthese, in order:\n\n1. **Rebuild directly from the face's own wire, if planar.** The cheapest,\n   most literal fix — zero geometry change, since the boundary itself is\n   untouched. Rebuild from the *outer* wire and re-add any inner wires\n   explicitly — a face with a hole has more than one wire, and grabbing only\n   \"a\" wire silently drops the others (verified: doing that on a plate with a\n   drilled hole rebuilds a solid plate, `IsDone()` True, hole gone, no error):\n\n   ```python\n   from OCP.BRepBuilderAPI import BRepBuilderAPI_MakeFace\n   from OCP.BRepTools import BRepTools_ReShape\n   outer = bad_face.outer_wire()\n   inner_wires = [w for w in bad_face.wires() if not w.wrapped.IsSame(outer.wrapped)]\n   mk = BRepBuilderAPI_MakeFace(outer.wrapped, True)\n   if not mk.IsDone():\n       raise RuntimeError(\"MakeFace failed — non-planar wire, move to option 2\")\n   for w in inner_wires:\n       mk.Add(w.wrapped)\n   reshaper = BRepTools_ReShape()\n   reshaper.Replace(bad_face.wrapped, mk.Face())\n   healed = as_solid(reshaper.Apply(part.wrapped))\n   ```\n\n   Check `IsDone()` right after constructing `mk`, **before** adding any inner\n   wires — calling `.Add()` on a builder that already failed doesn't raise a\n   catchable exception, it segfaults the whole process (verified: reproduced\n   directly on a non-planar wire, exit code 139). Only works when the wire is\n   (at least close to) planar — on a genuinely non-planar\u002FBSpline surface\n   `MakeFace` raises `Standard_Failure ... NULL shape`, or `IsDone()` is False\n   and the `raise` above fires before any `.Add()` call is reached. That\n   failure **is** the signal to move to option 2, not a reason to retry this\n   one.\n2. **Fill the boundary with a new surface.** For a non-planar face, build a\n   fresh surface spanning the *same* wire's edges instead of assuming\n   planarity — `BRepFill_Filling`, adding every edge of the wire, handles an\n   arbitrary N-edge boundary (a plain `BRepFill` ruled face only spans exactly\n   2 edges — use that simpler form only when the sliver truly has just 2 long\n   bounding edges). This still needs the wire itself to be intact (its edges\n   form a closed loop) — only the *surface* is assumed garbage; if the wire is\n   also broken, `filling.IsDone()` comes back False here too, and that's the\n   signal to move to option 3, not to retry with different edge-continuity\n   settings:\n\n   ```python\n   from OCP.BRepFill import BRepFill_Filling\n   from OCP.GeomAbs import GeomAbs_C0\n   from OCP.BRepTools import BRepTools_ReShape\n   filling = BRepFill_Filling()\n   for e in bad_face.edges():\n       filling.Add(e.wrapped, GeomAbs_C0, True)\n   filling.Build()\n   if not filling.IsDone():\n       raise RuntimeError(\"BRepFill_Filling failed — wire itself is broken, move to option 3\")\n   reshaper = BRepTools_ReShape()\n   reshaper.Replace(bad_face.wrapped, filling.Face())\n   healed = as_solid(reshaper.Apply(part.wrapped))\n   ```\n\n   `filling.IsDone()` can be True while `BRepCheck_Analyzer` still reports the\n   raw filled face invalid — that's expected here; verify via a full re-sew\n   (below) and the export gate, not the raw face check. A follow-up re-sew of\n   every face at a small tolerance (0.005-0.05 mm) after the patch often\n   closes the residual gap the fill alone leaves — start small and only widen\n   the tolerance if it doesn't close:\n\n   ```python\n   from OCP.BRepBuilderAPI import BRepBuilderAPI_Sewing\n   sew = BRepBuilderAPI_Sewing(0.01)   # small tol — widen toward 0.05mm if needed\n   for f in healed.faces():\n       sew.Add(f.wrapped)\n   sew.Perform()\n   healed = as_solid(sew.SewedShape())\n   ```\n\n3. **Replace with a triangulated micro-face patch.** When option 2 *also*\n   fails to produce a valid filled face (a genuinely uncooperative BSpline\n   that resists reconstruction as one surface), stop trying to rebuild it as\n   a single surface — tessellate the bad face and rebuild it as many small\n   *planar* triangular faces instead. Flat triangles can't be non-planar or\n   unorientable, so this sidesteps the underlying pathology entirely, at the\n   cost of faceting the small patch area (a bounded, tessellation-tolerance-\n   sized shape error, not the near-zero delta the earlier options give — this\n   is the first option in this rung that isn't a geometry-exact repair):\n\n   ```python\n   from OCP.BRepBuilderAPI import BRepBuilderAPI_MakePolygon, BRepBuilderAPI_MakeFace, BRepBuilderAPI_Sewing\n   from OCP.BRepCheck import BRepCheck_Analyzer\n   from OCP.gp import gp_Pnt\n   verts, tris = bad_face.tessellate(0.1)\n   tri_faces = []\n   for a, b, c in tris:\n       pa, pb, pc = verts[a], verts[b], verts[c]\n       poly = BRepBuilderAPI_MakePolygon(gp_Pnt(pa.X, pa.Y, pa.Z), gp_Pnt(pb.X, pb.Y, pb.Z), gp_Pnt(pc.X, pc.Y, pc.Z), True)\n       mk = BRepBuilderAPI_MakeFace(poly.Wire())\n       if mk.IsDone():\n           tri_faces.append(mk.Face())   # skip degenerate triangles silently\n   healed = None\n   for tol in (0.005, 0.05, 0.1, 0.25):   # start small; widen only if it doesn't close\n       sew = BRepBuilderAPI_Sewing(tol)\n       for f in part.faces():\n           if not f.wrapped.IsSame(bad_face.wrapped):\n               sew.Add(f.wrapped)\n       for tf in tri_faces:\n           sew.Add(tf)\n       sew.Perform()\n       candidate = as_solid(sew.SewedShape())\n       if BRepCheck_Analyzer(candidate.wrapped).IsValid():\n           healed = candidate\n           break\n   if healed is None:\n       raise RuntimeError(\"triangulated patch never closed — move to option 4\")\n   ```\n\n   Sweep the sew tolerance rather than committing to one value — which\n   tolerance closes the gap depends on how coarse the tessellation came out,\n   and is not worth predicting up front. Verify with the volume\u002Fbbox check as\n   usual, but hold this option to a looser bar: a delta on the order of the\n   bad face's own area times the tessellation deflection is expected and\n   acceptable here, not a red flag the way it would be for options 1-2.\n\n4. **Drop + tolerant sew.** When the wire itself is broken (options above\n   fail), delete the face entirely and sew the neighbours with **tolerance\n   greater than the sliver's width** (e.g. 0.6 mm for a 0.5 mm sliver), then\n   `ShapeFix_Solid` to orient the shell:\n\n   ```python\n   from OCP.BRepBuilderAPI import BRepBuilderAPI_Sewing\n   sew = BRepBuilderAPI_Sewing(0.6)          # tol > sliver width\n   for f in part.faces():\n       if not f.wrapped.IsSame(bad_face.wrapped):\n           sew.Add(f.wrapped)\n   sew.Perform()\n   healed = as_solid(sew.SewedShape())        # sewn result is a Shell; as_solid orients it\n   ```\n\n5. **Patch + small-tolerance sew.** On a *wide* sliver (~2-3 mm), drop+sew\n   goes non-manifold (the big tolerance welds faces that shouldn't meet).\n   Instead fill the sliver's boundary wire with a filling face and re-sew at\n   small tolerance (option 2's two snippets, in order).\n6. **Cut it out.** When the sliver is intrinsic to the geometry (a curved band\n   between two near-coincident arcs), in-memory fixes only *fake-heal* — the\n   gate fails again after the export round-trip. Remove the region physically:\n   boolean-subtract a thin box enclosing the sliver. This changes geometry by\n   the sliver's own (near-zero) volume, which is the point of last resort.\n\n### Rung 5 — mesh-gate-only failures (B-rep valid, mesh check FAILs)\n\nA BRepCheck-valid import can still fail the gate on a ~zero-area **unmeshable**\nface (often a degenerate BSpline): the tessellated boundary can't close. Drop\nthat face (plus any adjacent unorientable sliver), sew, and `ShapeFix_Solid`\nto orient — rung 4's mechanics, triggered by the mesh reasons instead of\nBRepCheck. A zero-area *torus* remnant that fails only the export gate heals\nthe same way.\n\nA **vertex-deflection** failure is a different mesh-only case: the offending\nface is not unmeshable, it's *mispatched* — a prior repair (a sliver sew, a\ntolerance-fudged patch) left its boundary topologically closed but landing a\nfraction of a millimetre off its own BREP vertex, so it reads as closed to\nBRepCheck and even to the open-edge count, yet a strict mesh sanity\ncheck still rejects it. `locate_gate_defects()` gives the vertex's exact\ncoordinates. Do not drop this face — the mismatch is a patch-quality problem,\nnot an unmeshable one (option 4's drop-and-sew is the wrong tool here): re-patch\n(rung 4 option 2 or 3) or re-sew at small tolerance (option 5) that exact face\nat a tighter tolerance than whatever repair left it in this state, then\nre-verify with the export gate.\n\nA **refined untriangulated face** (`mesh_refined_untriangulated_face` from\n`locate_gate_defects()`) is similarly a tolerance-sensitive face-quality problem:\nthe base mesh can hide it, but a finer downstream tessellation cannot. Treat the\nreported face as a fragile sliver or low-quality patch. Prefer re-patching the\nsame boundary with rung 4 option 2\u002F3 or re-sewing that local face at a tighter,\ncontrolled tolerance before using destructive drop-and-sew. Then verify with the\nexport gate, because the failure may only appear after STEP round-trip and finer\ntessellation.\n\n---\n\n## Step 2 — Verify every heal with the export gate\n\n- **The export gate is authoritative.** An in-memory heal can be fake:\n  `validate()` on the live shape passes, then the written-and-reimported STEP\n  fails. Always `export()` to a throwaway path and read its gate verdict; on a\n  huge shape `validate()`'s own mesh check can come back `mesh_check: \"skipped\"`\n  (too large to stitch even out-of-process) with a \"not verified\" warning, so\n  treat its PASS as a screen, not a verdict.\n- **A heal must not change the geometry — except when it's designed not to.**\n  Compare `volume` and bounding box before\u002Fafter: for most rungs the\n  acceptable delta is the scale of the defect (a sliver's near-zero volume),\n  never a feature's, and a heal that gains or loses real volume replaced your\n  part with a different part. Rung 4 option 1 is the deliberate exception — it\n  rebuilds a face from its own existing wire, so volume\u002Ftopology\u002Fbbox are\n  *supposed* to come back identical; there, `show()`'s \"shape was rebound but\n  volume\u002Ftopology\u002Fbbox unchanged\" warning is expected and does not mean the\n  heal failed, so judge that option by whether the export gate now passes,\n  not by whether anything numeric changed. For every other rung, that same\n  warning does mean the attempt changed nothing at all — a rewrap, not a\n  repair — so the original defect is still there even though no error was\n  raised; move to the next rung rather than trusting it.\n- **Never keep iterating on an invalid solid.** If a rung's attempt fails the\n  gate, `restore_snapshot()` back to the pre-attempt state before trying the\n  next rung — stacked failed repairs compound.\n- `save_snapshot()` before each diagnostic rung. When the candidate is intended\n  to become a durable STEP floor, prefer `bank_candidate()` so a failed gate\n  cannot overwrite that floor or create a misleading snapshot.\n\n---\n\n## Step 3 — Editing an invalid import: heal FIRST, then edit\n\nWhen the task is to *modify* an imported part whose STEP is already invalid,\ndo not interleave healing with editing:\n\n1. Import, `validate()`, and if it FAILs, run this skill's ladder **first**.\n2. Call `bank_candidate()` with `snapshot_name=\"valid_baseline\"`; it promotes the\n   healed import to the real output path and saves the snapshot only when the\n   written-and-reimported gate passes. From this moment a valid artifact exists\n   on disk no matter what happens later.\n3. Then perform the requested edit on the healed baseline, re-validating after\n   each step as usual; re-export only on PASS.\n\nIf a heavy heal (a large ShapeFix or boolean on a big import) exceeds the\n`execute()` timeout, run that one operation as a standalone script via the\nshell, then `import_cad_file()` the result back — same pattern as heavy builds.\n\n---\n\n## Step 4 — Don't introduce the defect in the first place\n\nMost self-made gate failures are one of these constructions; fix the\nconstruction, not the corpse:\n\n- **Exactly-coincident faces don't fuse.** A union whose faces are coplanar\n  with the base's (a box bottom flush with a feature's bottom, a boss butted\n  on a same-radius lobe, a thread root exactly on the bore wall) can pass\n  `validate()` and FAIL the export gate with non-manifold or open edges.\n  Interpenetrate: bury the added feature 1-2 mm into the base, make the\n  footprint 2-3 mm larger, or extend past and trim with one planar cut.\n- **When a feature can be built either as an addition or a removal, prefer the\n  removal.** Raising\u002Frelocating a face by *unioning new material onto an\n  existing boundary* runs straight into the coincident-face trap above — the\n  new material must fuse exactly flush with what's already there. The same\n  visible result reached by *cutting material away* instead (e.g. treating a\n  face move as an internal step\u002Fledge to deepen rather than an external boss\n  to add) only has to remove material cleanly, with no flush-fuse boundary to\n  get wrong. When a spec is genuinely ambiguous between an additive and a\n  subtractive reading, the subtractive one is the safer default.\n- **Tangencies leave open edges.** A hole tangent to a coaxial hub wall, a\n  boss grazing a torus fillet — nudge the position ~0.3 mm or extend the boss\n  coaxial with the adjacent straight cylinder so the intersection is clean.\n- **Patterned features must fuse into one solid.** If fusing a fin\u002Frib field\n  leaves two disjoint solids, bury each feature's base 1-2 mm so it\n  interpenetrates.\n- After every boolean, `measure()` and confirm face counts changed and volume\n  moved in the right direction — a silently-failed boolean is tomorrow's gate\n  failure.\n",{},"main","49023cd809092daa10dea0e9648a87006591d1f1","src\u002Fbuild123d_mcp\u002Fskills\u002Fb123d-repair",21,"https:\u002F\u002Fgithub.com\u002Fpzfreo\u002Fbuild123d-mcp","https:\u002F\u002Fgithub.com\u002Fpzfreo","http:\u002F\u002Fpzf.fremantle.org","2026-11-13 17:07:52",{"source":7,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add pzfreo\u002Fbuild123d-mcp --skill b123d-repair",{"tool":38,"command":39},"bunx","bunx skills add pzfreo\u002Fbuild123d-mcp --skill b123d-repair",{"tool":41,"command":42},"pnpm","pnpm dlx skills add pzfreo\u002Fbuild123d-mcp --skill b123d-repair","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fpzfreo\u002Fbuild123d-mcp\u002Fblob\u002Fmain\u002Fsrc\u002Fbuild123d_mcp\u002Fskills\u002Fb123d-repair\u002FSKILL.md",true,[],[47,55,63,76],{"skillNo":48,"name":49,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":20},"01M71S0XRPYA245TMQSFZ0FQ9V","b123d-modeling","https:\u002F\u002Fgithub.com\u002Fpzfreo\u002Fbuild123d-mcp\u002Fblob\u002Fmain\u002Fsrc\u002Fbuild123d_mcp\u002Fskills\u002Fb123d-modeling\u002FSKILL.md",[],[53,54],"modeling","b123d modeling",{"skillNo":56,"name":57,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":20},"01M71S0T5QS1HV2ZCTWVZZ98KJ","b123d-edit","https:\u002F\u002Fgithub.com\u002Fpzfreo\u002Fbuild123d-mcp\u002Fblob\u002Fmain\u002Fsrc\u002Fbuild123d_mcp\u002Fskills\u002Fb123d-edit\u002FSKILL.md",[],[61,62],"edit","b123d edit",{"skillNo":64,"name":65,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":73,"publishedAt":20},"01M71S0PAQB3ZRZWZBSDF4JXBW","b123d-drawing","https:\u002F\u002Fgithub.com\u002Fpzfreo\u002Fbuild123d-mcp\u002Fblob\u002Fmain\u002Fsrc\u002Fbuild123d_mcp\u002Fskills\u002Fb123d-drawing\u002FSKILL.md",[68],{"categoryNo":69,"categoryName":70,"taxonomyType":71,"taxonomyTypeDesc":72},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[74,75],"drawing","b123d drawing",{"skillNo":77,"name":65,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":20},"01M71S0MW5PWTPJ7MHYYVARWB0","https:\u002F\u002Fgithub.com\u002Fpzfreo\u002Fbuild123d-mcp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fb123d-drawing\u002FSKILL.md",[],[74,75]]