Skip to content
Back to search

parametric-3d-printing

"Use this skill when the user wants to design a 3D-printable physical object they intend to manufacture. Triggers: any mention of '3D print', 'STL', 'parametric model', 'Gridfinity', 'enclosure', 'bracket', 'mount', 'case', 'housing', 'CadQuery', 'OpenSCAD', or a specific FDM printer (Bambu Lab, Prusa, Ender); questions about print-friendly design, snap-fits, tolerances, or wall thickness; and requests for functional parts like Arduino enclosures, cable organizers, wall mounts, adapters, or mechanical components. Also fires when the user describes a real physical object to make, provided the goal is to manufacture it. Do NOT use for: 3D rendering, animation, game assets, digital-only art, photogrammetry, sculpting, editing an existing STL file the user already has, or any 3D work that is not heading toward a printer."

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/flowful-ai-cad-skill/badge.svg)](/listings/flowful-ai-cad-skill)

HTML

<a href="/listings/flowful-ai-cad-skill"><img src="/api/listings/flowful-ai-cad-skill/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

mkdir -p ~/.claude/skills
git clone https://github.com/flowful-ai/cad-skill ~/.claude/skills/parametric-3d-printing

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

SKILL.md · Manifest · 461 lines
  1. ---
  2. name: parametric-3d-printing
  3. description: "Use this skill when the user wants to design a 3D-printable physical object they intend to manufacture. Triggers: any mention of '3D print', 'STL', 'parametric model', 'Gridfinity', 'enclosure', 'bracket', 'mount', 'case', 'housing', 'CadQuery', 'OpenSCAD', or a specific FDM printer (Bambu Lab, Prusa, Ender); questions about print-friendly design, snap-fits, tolerances, or wall thickness; and requests for functional parts like Arduino enclosures, cable organizers, wall mounts, adapters, or mechanical components. Also fires when the user describes a real physical object to make, provided the goal is to manufacture it. Do NOT use for: 3D rendering, animation, game assets, digital-only art, photogrammetry, sculpting, editing an existing STL file the user already has, or any 3D work that is not heading toward a printer."
  4. ---
  5. # Parametric 3D Printing with CadQuery
  6. ## Overview
  7. This skill generates parametric 3D models using **CadQuery** (Python) and exports them as STL files ready for slicing. CadQuery is preferred because it installs via pip, has a Pythonic API, and handles complex geometry (fillets, chamfers, booleans, assemblies) better than alternatives.
  8. ## Setup
  9. CadQuery requires Python 3.10-3.12 (the OCC kernel lacks 3.13+ wheels). Run from this skill's directory. With [uv](https://docs.astral.sh/uv/), which downloads Python 3.12 if the machine lacks it:
  10. ```bash
  11. uv venv --python 3.12 && source .venv/bin/activate
  12. uv pip install -r requirements.txt
  13. ```
  14. Without uv, when Python 3.10-3.12 is already installed:
  15. ```bash
  16. python3.12 -m venv .venv && source .venv/bin/activate
  17. pip install -r requirements.txt
  18. ```
  19. CadQuery uses the OpenCASCADE kernel under the hood. trimesh, pyrender, Pillow, and numpy are used for the preview-analyze-iterate loop; lxml is required by the 3MF writer (`stl_to_3mf.py`). No display server is needed; everything renders headlessly via pyrender's offscreen backend.
  20. **If CadQuery fails to install** (OCC kernel build errors), try:
  21. ```bash
  22. # Option 1: Use conda (CadQuery's officially recommended method)
  23. conda install -c cadquery -c conda-forge cadquery
  24. # Option 2: Use the pre-built wheels
  25. pip install cadquery --find-links https://github.com/CadQuery/CadQuery/releases
  26. ```
  27. ## Real-World Dimension Research
  28. When designing objects that interface with real products (phones, chargers, PCBs, connectors, etc.), **use web search to find accurate dimensions** before writing any geometry code. Don't guess or use approximate values. Even 1-2mm off can make a part unusable.
  29. **What to research:**
  30. - Connector/port dimensions (USB-C: 8.4 x 2.6mm opening, Lightning, barrel jacks)
  31. - Device dimensions (phone width/thickness, PCB footprints, charger puck diameters)
  32. - Mounting hole patterns and screw sizes (M2.5, M3, etc.)
  33. - Standard component specs (MagSafe puck: 56mm diameter, 5.6mm thick)
  34. - Cable bend radii and strain relief requirements
  35. **How to use it:**
  36. 1. Search for "[product] dimensions mm" or "[component] datasheet"
  37. 2. Cross-reference at least 2 sources when precision matters
  38. 3. Add the sourced dimensions as comments in the PARAMETERS section:
  39. ```python
  40. # MagSafe puck dimensions (source: Apple spec + iFixit teardown)
  41. puck_diameter = 56.0 # mm
  42. puck_thickness = 5.6 # mm
  43. ```
  44. 4. When in doubt, add 0.3-0.5mm clearance to external dimensions
  45. This is especially important for: phone cases/stands, charger mounts, PCB enclosures, cable management, adapter fittings, and anything that clips onto or wraps around an existing product.
  46. ### Measuring from photos
  47. When the thing to fit is in the user's home (a hole, a frame, a pipe), ask for a photo with a tape measure laid across it, one per axis. A photo often answers more than the number:
  48. - **Read the tape where the object ends**, not where the hook sits. The hook is zero; check the hook is actually on the object's edge.
  49. - **Read the brand and model off the object** (moulded logos, labels). A product that matches the measured size gives you the spec sheet values for hidden dimensions, like the cut-out behind a frame. Use the measurement to confirm the model, and the spec for what the tape can't reach.
  50. - **Look at the surroundings**: distance to a floor, hinge or wall, paint shadows of an older fitting, existing screw holes. They bound how far the part can extend.
  51. - **Ask for the one measurement only the user can take** (the hole once the old part is off, a door thickness) and keep that dimension a named parameter so it can be corrected before printing.
  52. ## Core Workflow
  53. 1. **Gather requirements** (see Requirements Gathering below)
  54. 2. **Research dimensions** of any real-world products involved (see above)
  55. 3. **Phase 1, Base shape**: Build outer shell, preview, get user feedback
  56. 4. **Phase 2, Features**: Add functional details, preview, get user feedback
  57. 5. **Phase 3, Final delivery**: Fillets, cleanup, final preview + STL + print recommendations
  58. 6. **Offer parameter tweaks** after delivery
  59. This is a **collaborative, show-as-you-go** process. Do NOT disappear and come back with a finished model. Show the user your progress at each phase and incorporate their feedback before moving on.
  60. ## Requirements Gathering
  61. Before writing any code, walk through these topics with the user **conversationally**. Don't dump all questions at once. Ask the most important ones first, then follow up based on answers. Use reasonable defaults when the user doesn't specify.
  62. **What is it?**
  63. Object type, purpose, what it holds/protects/attaches to. Get a clear mental model of the object before anything else.
  64. **Critical dimensions**
  65. Must-fit measurements, like PCB size, phone width, screw spacing, diameter of the thing it wraps around, etc. These are non-negotiable and drive everything else.
  66. **Mounting & attachment**
  67. How does it connect to things? Screws (what size?), snap-fit, adhesive tape, magnets, freestanding on a desk? This affects wall thickness, boss placement, and overall structure.
  68. **Printer & material**
  69. What printer do they have? (Bambu, Prusa, Ender, etc.) Nozzle size? Material (PLA, PETG, TPU)? This directly affects tolerances, minimum feature sizes, and design constraints. Defaults: 0.4mm nozzle, PLA, 0.2mm layer height. The printer also sets the **build volume**: pass it to the run wrapper with `--bed` (see below) as soon as the part is larger than about 150mm, so an oversized part fails in the loop instead of in the slicer.
  70. **Functional needs**
  71. Ventilation/airflow, water resistance, cable routing, access panels, visibility windows, stacking, weight limits. Ask only what's relevant to the object.
  72. **Aesthetic preferences**
  73. Rounded vs sharp edges, minimal vs industrial look, color considerations (affects visibility of layer lines). Ask briefly. Most users care more about function than form.
  74. Start with the first two (what + dimensions), then ask about mounting and material if relevant. Only ask about aesthetics if the user seems to care or if it affects structural choices.
  75. When a question tool is available, ask the questions that change the design in one batch, each with the typical answers as options (common product sizes from your research, the usual mounting methods). Users answer a list of concrete options faster than open questions, and "Other" still lets them type a measurement.
  76. ## Progressive Preview Workflow
  77. Build the model in phases. At each phase, export an STL, render a preview, self-review it, then **show it to the user and ask for feedback** before proceeding. This catches problems early and keeps the user involved.
  78. ### Preview recipe (use at every phase)
  79. **One-shot (run script + render + parse result as JSON):**
  80. ```bash
  81. python3 run_cadquery_model.py model.py --preview --strict --bed a1
  82. ```
  83. This executes `model.py`, finds the STL it wrote, renders the multi-view preview, and emits a JSON result with `success`, `stdout`, `stderr`, `stl`, `preview`, `watertight`, `bboxes` (measured X/Y/Z of each STL, in mm) and `fits_bed`. With `--strict`, a non-watertight mesh is a hard failure. With `--bed`, a part that does not fit the build volume (90° rotation allowed, 5mm kept free per side) is a hard failure; it takes a printer name (`a1`, `a1mini`, `p1s`, `x1c`, `h2d`, `mk4`, `mini`, `core1`, `ender3`, `k1`, full list in `mesh_io.PRINTER_BEDS`) or `WxDxH` in mm. Use this as the default loop: if `success` is false, read the `stderr` field to fix the CadQuery script, then re-run. Compare `bboxes` with the dimensions you meant to build.
  84. **Rendering only (when the STL already exists):**
  85. ```bash
  86. python3 preview.py model.stl preview.png --views multi
  87. ```
  88. Then view the preview image, self-review it against the checklist in `design-review.md`, and fix any issues you spot **before** showing it to the user.
  89. ---
  90. ### Phase 1: Base Shape
  91. Build the basic outer form: overall dimensions, shell/walls, bottom plate. No cutouts, no fillets, no details yet.
  92. 1. Write the script with parameters and basic geometry
  93. 2. Export STL and render preview
  94. 3. Self-review: Does the shape and size look right? Is the bottom flat for printing?
  95. 4. **Show the preview to the user**: "Here's the basic shape. Does this look right before I add details?" Include key dimensions.
  96. 5. Wait for feedback. If the user wants changes, iterate here before moving on.
  97. ### Phase 2: Features
  98. Add functional details: holes, cutouts, mounting bosses, cable slots, ventilation, snap-fits, internal structures.
  99. 1. Add features to the script
  100. 2. Export STL and render preview
  101. 3. Self-review: Are all features visible? Do booleans look clean? Are holes in the right positions?
  102. 4. **Show the preview to the user**: "I've added [list features]. Anything to change before I finalize?"
  103. 5. Wait for feedback. Iterate if needed.
  104. ### Phase 3: Final Delivery
  105. Apply finishing touches: fillets, chamfers, edge cleanup. Do a full printability review.
  106. 1. Add fillets/chamfers (largest radius first, apply after shell)
  107. 2. Export final STL and render preview
  108. 3. **Full self-review** using the complete checklist from `design-review.md`: visual inspection, dimensional verification, printability analysis
  109. 4. Fix any issues found, re-export if needed
  110. 5. **Deliver to the user**: final STL + preview image + print recommendations (orientation, supports, infill, material notes)
  111. ---
  112. **Important:** Do NOT skip phases or combine them unless the model is very simple (e.g., a flat bracket with two holes). For anything with enclosed geometry, multiple features, or tight tolerances, follow all three phases.
  113. Read `design-review.md` for the full visual inspection checklist, dimensional verification code, and printability analysis helpers.
  114. ### Print Recommendations (final delivery)
  115. When you deliver the final STL, always include a one-line slicer recipe plus a short rationale. Bambu Studio, PrusaSlicer, and OrcaSlicer already set sensible defaults from their filament + process presets, so **do not restate every slicer option**. Only tell the user what matters for *this* model: material, layer height, walls, infill, supports, and orientation. Tweak from the baseline below only when the model needs it.
  116. **Baseline recipe (0.4mm nozzle, typical FDM):**
  117. > PLA, 0.2mm layer, 2 walls, 15% gyroid infill, no supports, orientation: flat side on bed.
  118. **When to deviate from the baseline:**
  119. - **Load-bearing brackets / hooks / hinges**: bump infill to 25-40%, 3-4 walls, consider PETG over PLA for toughness.
  120. - **Thin decorative walls or vases**: 0 infill, vase mode or 1 wall.
  121. - **Tall narrow parts**: add a brim for bed adhesion.
  122. - **Large flat parts (plates, panels over ~150mm)**: corners lift as PLA cools. Brim or mouse ears, PETG if the room is cold, and stiffen with ribs instead of a thicker plate (a thick solid plate warps harder and costs more filament).
  123. - **Flexible parts (gaskets, grips)**: TPU 95A, 0.2mm layer, slower speed, no supports.
  124. - **Functional overhangs the geometry can't avoid**: tree supports, or call them out so the user knows.
  125. - **Outdoor / hot environments**: PETG or ASA, not PLA.
  126. - **Food / skin contact**: call out that FDM parts are not food-safe and recommend a food-safe coating.
  127. **Format at delivery time:**
  128. ```
  129. Print settings: PLA, 0.2mm layer, 2 walls, 15% gyroid infill, no supports.
  130. Orientation: place flat back side on the bed (front face up).
  131. Why: the case has no overhangs above 45°, and 15% infill is plenty for a
  132. TPU-adjacent protective shell.
  133. ```
  134. Keep it to ~3 lines. Never dump every slicer setting; the slicer already knows.
  135. ## Script Template
  136. ALWAYS structure scripts like this:
  137. ```python
  138. import cadquery as cq
  139. # ============================================================
  140. # PARAMETERS - Edit these to customize the model
  141. # ============================================================
  142. # Overall dimensions
  143. width = 60.0 # mm - outer width
  144. depth = 40.0 # mm - outer depth
  145. height = 25.0 # mm - outer height
  146. # Wall and structural
  147. wall = 2.0 # mm - wall thickness (min 1.2 for FDM)
  148. corner_r = 2.0 # mm - corner fillet radius
  149. # Tolerances
  150. fit_clearance = 0.3 # mm - clearance for press-fit (adjust per printer)
  151. # ============================================================
  152. # MODEL
  153. # ============================================================
  154. result = (
  155. cq.Workplane("XY")
  156. .box(width, depth, height, centered=(True, True, False))
  157. # ... build geometry using parameters above (bottom at Z=0)
  158. )
  159. # ============================================================
  160. # EXPORT
  161. # ============================================================
  162. # Use tolerance=0.01, angularTolerance=0.1 for consistent tessellation
  163. # across models. Defaults give coarser, wildly variable STL sizes.
  164. cq.exporters.export(result, "output.stl",
  165. tolerance=0.01, angularTolerance=0.1)
  166. print(f"Exported: {width}x{depth}x{height}mm")
  167. ```
  168. ## Key Rules
  169. ### Parameters First
  170. - ALL dimensions go in the PARAMETERS section at the top
  171. - Use descriptive names: `screw_hole_d`, not `d1`
  172. - Add units in comments (always mm)
  173. - Group related parameters with blank lines and section comments
  174. ### Print-Friendly Defaults
  175. Key FDM design defaults:
  176. | Property | Minimum | Recommended |
  177. |----------|---------|-------------|
  178. | Wall thickness | 1.2mm | 2.0mm |
  179. | Layer height | 0.08mm | 0.2mm |
  180. | Hole clearance | 0.2mm | 0.3mm |
  181. | Press-fit interference | 0.1mm | 0.15mm |
  182. | Min feature size | 0.4mm (nozzle) | 0.8mm |
  183. | Fillet radius (bottom) | 0.5mm | 1.0mm |
  184. | Bridge span | - | < 20mm unsupported |
  185. | Overhang angle | - | < 45 degrees from vertical |
  186. **Material-specific adjustments:** TPU needs larger clearances (~0.5mm) due to flex. PETG is stickier, so add +0.1mm to fit clearances. ABS shrinks ~0.5-0.7%, so scale critical dimensions up slightly. When in doubt, print a small test piece first.
  187. ### Orientation Awareness
  188. - Design with print orientation in mind
  189. - Flat bottom surfaces print best
  190. - Avoid supports when possible by designing around overhangs
  191. - Add chamfers to bottom edges instead of fillets (fillets need supports)
  192. - Comment the intended print orientation in the script
  193. ### CadQuery Patterns
  194. Common patterns to know:
  195. **Hollow enclosure (boolean subtraction, preferred):**
  196. ```python
  197. outer = (
  198. cq.Workplane("XY")
  199. .box(width, depth, height, centered=(True, True, False))
  200. .edges("|Z").fillet(corner_r)
  201. )
  202. inner = (
  203. cq.Workplane("XY")
  204. .workplane(offset=floor_t)
  205. .box(width - 2*wall, depth - 2*wall, height, centered=(True, True, False))
  206. .edges("|Z").fillet(max(0.1, corner_r - wall))
  207. )
  208. result = outer.cut(inner)
  209. ```
  210. **Screw boss:**
  211. ```python
  212. .pushPoints([(x, y)])
  213. .circle(boss_od / 2).extrude(boss_h)
  214. .pushPoints([(x, y)])
  215. .hole(screw_d + fit_clearance)
  216. ```
  217. **Snap-fit clip:**
  218. ```python
  219. # Cantilever beam with overhang hook
  220. .workplane(offset=wall)
  221. .moveTo(x, y).rect(clip_w, clip_l).extrude(clip_h)
  222. # Add hook at tip with a small overhang (< 45 deg)
  223. ```
  224. **Ventilation grid:**
  225. ```python
  226. .pushPoints(vent_positions)
  227. .slot2D(slot_l, slot_w).cutThruAll()
  228. ```
  229. **Adhesive-mounted cover or panel (VHB tape):**
  230. - Leave a flat, unbroken contact band at least 20mm wide where the tape goes; VHB rolls are 12, 19 or 25mm wide. No ribs, text or chamfers inside that band.
  231. - Tape holds well in peel and tension but creeps under a constant sideways load. When the part covers a hole, add a hollow **locating plug** on the back that drops into the hole with 1-1.5mm clearance per side: it centres the part while the tape is applied and takes any knock sideways. Keep its depth under half the substrate thickness if a twin part goes on the other side.
  232. - Print the visible face down on the bed for the smoothest finish, with a small chamfer on that edge (fillets on the bed edge need supports).
  233. - See `examples/cat_flap_cover.py`.
  234. Other patterns: mounting brackets, cable routing channels, text/labels (`.text()`), multi-part assemblies with alignment pins.
  235. ### Common Pitfalls
  236. - **Hollowing: prefer boolean subtraction over `.shell()`**. `.shell()` is fragile. It fails on tapered bodies, lofted shapes, unions of multiple primitives, and anything with many fillets. The reliable pattern is:
  237. ```python
  238. outer = cq.Workplane("XY").box(w, d, h, centered=(True, True, False)).edges("|Z").fillet(corner_r)
  239. inner = (
  240. cq.Workplane("XY")
  241. .workplane(offset=floor_t)
  242. .box(w - 2*wall, d - 2*wall, h, centered=(True, True, False))
  243. .edges("|Z").fillet(max(0.1, corner_r - wall))
  244. )
  245. result = outer.cut(inner)
  246. ```
  247. Only reach for `.shell()` when the body is a single simple primitive (one `.box()` or `.cylinder()`) with a uniform wall thickness on all sides. If in doubt, use boolean subtraction.
  248. - **Build order: fillet → cut, not cut → fillet**. Apply fillets while the geometry is still a clean primitive. Once you have cut holes/slots/pockets into a body, filleting the resulting edges often fails or produces bad geometry. Same rule for chamfers.
  249. - **Fillet failures**: Apply fillets from largest to smallest radius. **Do not wrap fillets in `try/except` to silently shrink the radius.** A fillet failure means the geometry or the radius is wrong; find the root cause (too-large radius, wall thinner than radius, adjacent faces that the fillet would degenerate) and fix that.
  250. - **Zero-thickness geometry**: Ensure boolean operations don't create infinitely thin walls. Add a small epsilon (0.01mm) when cutting bodies that are meant to pass just through a surface.
  251. - **Coordinate system**: CadQuery centers geometry at origin by default. Use `centered=(True, True, False)` on `.box()` to place the bottom at Z=0 so `.faces("<Z")` is always the print bed.
  252. - **Hole direction**: `.hole()` cuts through the entire part by default. Use `.cboreHole()` or `.cskHole()` for counterbore/countersink.
  253. - **Taper direction**: In `.extrude(taper=angle)`, a **positive** taper angle narrows the shape (draft inward), **negative** flares it outward. This is opposite to what many people expect.
  254. - **Loft is fragile**: `.loft()` fails on many cross-section combinations. Prefer `.extrude(taper=angle)` when transitioning between a shape and a scaled version of itself. Only use `.loft()` when you need to transition between genuinely different profiles (e.g., circle to rectangle).
  255. - **Export errors / non-watertight STL**: If export fails or the preview reports a non-watertight mesh, the geometry is invalid (usually self-intersecting booleans or zero-thickness faces). Fix the cause, don't paper over it. Run `python3 preview.py model.stl --strict` to fail loudly on non-watertight output.
  256. ## Export
  257. ```python
  258. # STL (for slicing) - always set tolerance + angularTolerance for
  259. # consistent tessellation. Defaults produce variable file sizes and
  260. # over-tessellated glyphs on text features.
  261. cq.exporters.export(result, "model.stl",
  262. tolerance=0.01, angularTolerance=0.1)
  263. # STEP (for further CAD editing)
  264. cq.exporters.export(result, "model.step")
  265. ```
  266. Always export STL for printing. Optionally export STEP if the user might want to edit in Fusion 360 or similar.
  267. ## Multi-Part Models
  268. For models with multiple parts (e.g., enclosure + lid):
  269. ```python
  270. # Export each part separately
  271. cq.exporters.export(body, "enclosure_body.stl")
  272. cq.exporters.export(lid, "enclosure_lid.stl")
  273. ```
  274. Name files descriptively so the user knows which part is which.
  275. **Check how the parts mate before printing them.** A preview shows each part alone, so it can't catch a lid that collides with its box or a joint too loose to hold. Copy the bundled `mating.py` next to the script, place the parts in their assembled position (don't export that) and call `check_mating`:
  276. ```python
  277. from mating import check_mating
  278. # Raises MatingError if the lid collides with the box, or if a shift of
  279. # clearance + 0.1mm along X or Y doesn't hit anything (the lid rattles).
  280. check_mating(box, lid.translate((0, 0, box_h)), clearance=fit_clearance,
  281. axes=("x", "y"))
  282. ```
  283. List only the axes the joint itself must hold. Leave out an axis that screws, glue or gravity take care of.
  284. ### Parts larger than the bed
  285. When `--bed` rejects a part, try in this order:
  286. 1. **Rotate it** in the script (stand it on end, or turn it diagonally with `.rotate()`): the wrapper only tries the part as exported and turned 90°.
  287. 2. **Split it into identical segments** where the shape repeats (trays, rails, shelves): one script, one STL, print it N times. Each segment should mount on its own so the joint only aligns; joints that carry load need screws or a dovetail.
  288. 3. **Split at a natural seam** otherwise, and join with alignment pins (pin + hole with 0.2mm clearance) plus glue or screws.
  289. Put the joint where it prints without supports (vertical cheeks, butt ends), and run the mating check above on it. See `examples/desk_cable_tray.py`.
  290. ## Gridfinity Bins
  291. For any Gridfinity request (bins, inserts, cradles for the 42mm modular grid system), **use the bundled `gridfinity.py` module; never hand-roll the base profile**. The module is tested, spec-compatible (base profile, stacking lip, 6x2mm magnet bores, M3 screw holes on the 26mm square), and validates parameters with actionable errors.
  292. **Workflow:**
  293. 1. Copy `gridfinity.py` from this skill's directory next to the model script (it is a vendored module; generated scripts must stay runnable standalone).
  294. 2. Build with the `GridfinityBin` API:
  295. ```python
  296. import cadquery as cq
  297. from gridfinity import GridfinityBin
  298. bin = GridfinityBin(grid_x=3, grid_y=2, height_units=3,
  299. stacking_lip=True, magnets=False)
  300. bin.add_pocket(length=88.6, width=72.6, corner_r=(12.0, 1.0)) # cradle
  301. # or: bin.add_compartments(cols=3, rows=2, scoop_r=6, label_tab=True)
  302. # or: bin.add_polygon_pocket(points, depth=15, clearance=0.3)
  303. # or: bin.add_cylinder_pocket(diameter=22, center=(42, 27), # finger well; overlapping pockets merge
  304. # tilt=35, tilt_dir=(-1, 0), round_bottom=True) # smooth angled thumb scoop
  305. # or: bin.add_finger_notch(side="+Y", width=20, offset=40) # offset slides it along the wall
  306. result = bin.build()
  307. cq.exporters.export(result, "my_bin.stl", tolerance=0.01, angularTolerance=0.1)
  308. print(bin.summary())
  309. ```
  310. **Cheat sheet:**
  311. - Spec constants: grid pitch 42mm, height unit 7mm. Every derived number (footprint, lip height, floor Z, usable cavity depth) is exposed on the builder: `bin.outer_w`, `bin.outer_d`, `bin.total_h`, `bin.floor_z`, `bin.max_depth`, and `bin.summary()` prints them all. Read those instead of recomputing.
  312. - Sizing an object pocket: add 0.3mm per side fit clearance, plus ~1mm per side if the object must drop in and out easily.
  313. - Pocket matching a real object's shape: `outline_from_scan.py` extracts the max cross-section outline from an STL scan of the object (align, scale to spec dims, slice, union), ready for `add_polygon_pocket`.
  314. - Height choice: whatever holds the contents; the contents may protrude above the rim (see `examples/gridfinity_d110_bin.py`).
  315. - `magnets=True` needs a magnetic baseplate; skip it for drawer bins.
  316. The builder raises `GridfinityError` with a specific message when a pocket is too big, a wall too thin, or the floor too shallow for screws (a few checks fire in the `add_*` calls, the rest in `build()`). Fix the parameters; do not bypass the validation.
  317. If the user asks for something the module does not cover (baseplates, odd lips), fall back to custom geometry but keep the spec constants from `gridfinity.py` as the source of truth. When delivering a release, ship `gridfinity.py` alongside the model script.
  318. ## Parameter Adjustment Offer
  319. After delivering the final model, **always present the key parameters as a summary table** and offer to tweak them. This lets the user fine-tune without re-explaining the whole design.
  320. Example:
  321. ```
  322. Here's your final model! Current parameters:
  323. | Parameter | Value |
  324. |----------------|--------|
  325. | Width | 90 mm |
  326. | Depth | 65 mm |
  327. | Height | 30 mm |
  328. | Wall thickness | 4 mm |
  329. | Cable slot | 18 mm |
  330. | Corner radius | 3 mm |
  331. | Fit clearance | 0.3 mm |
  332. Want me to adjust anything? Just say e.g. "make it 5mm taller" or "wider cable slot."
  333. ```
  334. Only include parameters the user would plausibly want to change. Skip internal constants like `eps` or `nozzle_d`. Group them logically (dimensions first, then structural, then tolerances).
  335. ## Output Checklist
  336. Before delivering a model, verify:
  337. - [ ] All dimensions are parameterized (no magic numbers in geometry code)
  338. - [ ] Wall thickness >= 1.2mm
  339. - [ ] Designed for printability (minimal overhangs/supports)
  340. - [ ] Print orientation noted in comments
  341. - [ ] STL exported and file size is reasonable (not 0 bytes)
  342. - [ ] Clear parameter names with units
  343. - [ ] Script runs without errors
  344. - [ ] **Multi-view preview generated and visually inspected**
  345. - [ ] **Preview shows correct shape, features, and proportions**
  346. - [ ] **Bounding box dimensions match requirements** (`bboxes` in the wrapper JSON)
  347. - [ ] Every part fits the user's printer (`--bed` passed)
  348. - [ ] Mating parts checked for collision and capture (multi-part only)
  349. - [ ] Both STL and preview PNG delivered to user
README.md · README · 97 lines
  1. # CAD Skill for Claude Code
  2. A [Claude Code](https://docs.anthropic.com/en/docs/claude-code) skill for generating parametric 3D-printable models using [CadQuery](https://cadquery.readthedocs.io/). Describe a physical object, and Claude will write a parametric script, export STL, render previews, and iterate with you until it's right.
  3. <p align="center">
  4. <img src="docs/magsafe_stand_preview.png" alt="MagSafe stand preview, 4 views" width="480">
  5. <img src="docs/iphone13_pro_case_preview.png" alt="iPhone 13 Pro case preview, 4 views" width="480">
  6. </p>
  7. Read the full write-up: [I Taught Claude to Design 3D-Printable Parts. Here's How](https://medium.com/@nchourrout/i-taught-claude-to-design-3d-printable-parts-heres-how-675f644af78a)
  8. ## More examples
  9. Published on [MakerWorld](https://makerworld.com/en/@sercanto).
  10. <p align="center">
  11. <img src="docs/gridfinity_d110_bin_preview.png" alt="Gridfinity 3x2 bin for Orico D110 label printer" width="640">
  12. </p>
  13. <p align="center">
  14. <img src="docs/mx_master3_bin_3x3_preview.png" alt="Gridfinity 3x3 bin for Logitech MX Master 3, pocket traced from a 3D scan" width="640">
  15. </p>
  16. The MX Master 3 bin above ([examples/mx_master3_bin_3x3.py](examples/mx_master3_bin_3x3.py), [printed and published on MakerWorld](https://makerworld.com/en/models/3049470-gridfinity-bin-for-logitech-mx-master-3-3x3)) shows the scan-to-pocket pipeline: `outline_from_scan.py` traces the mouse's real footprint from a 3D scan, the outline is rotated to the angle that minimizes its bounding square so the bin fits a 3x3 grid instead of 4x3, and a tilted thumb scoop ramps under the thumb rest to lift the mouse out.
  17. <p align="center">
  18. <img src="docs/cat_flap_cover_preview.png" alt="Cover plate for a removed Cat Mate cat flap" width="640">
  19. </p>
  20. The cat flap cover ([examples/cat_flap_cover.py](examples/cat_flap_cover.py)) was sized from two phone photos with a tape measure: the moulded logo identified the Cat Mate 4-way, the tape confirmed its 192 x 200mm frame, and the spec sheet gave the 165 x 174mm cut-out hidden behind it. It sticks on with VHB tape, and a hollow ribbed plug drops into the hole to centre it and take sideways knocks.
  21. <p align="center">
  22. <img src="docs/desk_cable_tray_preview.png" alt="Under-desk cable tray segment with socket joint" width="640">
  23. </p>
  24. The under-desk cable tray ([examples/desk_cable_tray.py](examples/desk_cable_tray.py)) is 400mm long, too long for a 256mm bed, so it prints as identical segments that slide into each other. The script places two segments together and asserts they neither collide nor rattle before exporting.
  25. <p align="center">
  26. <img src="docs/magnet_catch_preview.png" alt="Magnetic door catch (frame side)" width="640">
  27. <img src="docs/magnet_strike_preview.png" alt="Magnetic door catch (door side)" width="640">
  28. </p>
  29. ## Installation
  30. ```bash
  31. mkdir -p ~/.claude/skills
  32. git clone https://github.com/flowful-ai/cad-skill ~/.claude/skills/parametric-3d-printing
  33. ```
  34. ## Usage
  35. Once installed, the skill activates in two ways inside Claude Code:
  36. - **Auto-trigger.** Describe a part you want to print ("design a wall mount for an Arduino Uno", "I need a snap-fit lid for this box") and Claude picks up the skill from its trigger keywords (3D print, STL, CadQuery, enclosure, bracket, and so on).
  37. - **Explicit slash command.** Type `/parametric-3d-printing` to invoke it directly, useful when your request does not contain the obvious keywords.
  38. Claude will then walk you through requirements, build the model in phases (base shape, features, finish), and deliver an STL plus a rendered preview.
  39. ## Dependencies
  40. Requires **Python 3.10-3.12** (CadQuery's OCC kernel does not have wheels for 3.13+). [uv](https://docs.astral.sh/uv/) fetches Python 3.12 for you if it is missing:
  41. ```bash
  42. uv venv --python 3.12 && source .venv/bin/activate
  43. uv pip install -r requirements.txt
  44. ```
  45. Without uv, with Python 3.10-3.12 already installed:
  46. ```bash
  47. python3.12 -m venv .venv && source .venv/bin/activate
  48. pip install -r requirements.txt
  49. ```
  50. ## Files
  51. | File | Purpose |
  52. |------|---------|
  53. | `SKILL.md` | Skill definition and workflow instructions for Claude |
  54. | `gridfinity.py` | Tested Gridfinity bin generator (base profile, stacking lip, magnets, compartments, custom pockets). Vendored next to generated scripts. |
  55. | `mating.py` | Fit check for parts that go together: no collision when assembled, and the joint locates instead of rattling. Vendored next to generated scripts. |
  56. | `outline_from_scan.py` | Extracts a pocket outline from a 3D scan of an object (align, scale, slice, union), ready for `add_polygon_pocket`. |
  57. | `examples/` | Example model scripts: Gridfinity bins (D110 cradle, MX Master 3 diagonal bin), cat flap cover plate, segmented desk cable tray. |
  58. | `preview.py` | Headless STL to 6-view PNG renderer (trimesh + pyrender). Use `--strict` to fail on non-watertight meshes. |
  59. | `run_cadquery_model.py` | Subprocess wrapper that runs a CadQuery script, captures errors, optionally renders the preview, checks each part against the printer's build volume (`--bed a1`), and emits a JSON result so Claude can self-correct in a loop. |
  60. | `mesh_io.py` | STL loading with validation (no pyrender dependency). Used by the wrapper and converter. |
  61. | `stl_to_3mf.py` | Standalone STL to 3MF converter for Bambu Studio / PrusaSlicer. |
  62. | `design-review.md` | Visual inspection checklist and printability analysis |
  63. | `requirements.txt` | Pinned dependency versions |
  64. ## License
  65. The skill and scripts are licensed under the [PolyForm Noncommercial License 1.0.0](LICENSE). Free to use, modify, and distribute for noncommercial purposes.
  66. ---
  67. Created by [Nicolas Chourrout](https://github.com/nchourrout) from [Flowful.ai](https://flowful.ai)

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.