Skip to content
←Back to Skills

CAD Skill: A Verifiable Loop for Parametric 3D Printing

flowful-ai/cad-skill

A Claude Code skill that turns CadQuery into a measurable loop for printable parts, with structured execution, six-view previews, mesh and bed checks, mating validation, scan-derived pockets, and a tested Gridfinity builder.

Editor's takeA credible noncommercial skill for functional FDM parts: its engineering checks are unusually concrete, while dimensional validation and physical print testing still remain human responsibilities.
mkdir -p ~/.claude/skills && git clone https://github.com/flowful-ai/cad-skill ~/.claude/skills/parametric-3d-printing
Claude Code
CadQueryParametric CAD3D PrintingClaude Code
flowful-ai/cad-skill74753PythonNOASSERTIONflowful-ai8 min read

CAD Skill turns "design me a part I can print" into an executable engineering loop rather than a one-shot geometry prompt. The repository combines Claude Code instructions with runnable Python tools for CadQuery generation, rendering, mesh validation, build-volume checks, mating checks, scan-derived pockets, and a tested Gridfinity builder. Its useful unit is not a pretty model. It is a parametric part that can survive a measurable design, preview, reject, repair, and export cycle.

What the repository actually contains

The skill definition in SKILL.md controls the conversation and modeling process. It asks for the object's purpose, critical dimensions, mounting method, printer, material, and functional requirements before geometry is written. It explicitly rejects the common shortcut of estimating dimensions for a phone, charger, circuit board, connector, or mating part. For functional printed objects, a one-millimeter mistake is not a cosmetic detail.

The supporting code is split by responsibility. run_cadquery_model.py executes generated scripts and returns structured results. mesh_io.py loads and validates meshes without requiring a renderer. preview.py produces technical views. mating.py checks assembled parts. outline_from_scan.py extracts a footprint from a scan. gridfinity.py builds spec-compatible storage bins. Four examples exercise those pieces on a printer cradle, a mouse-shaped bin, a cover plate, and a segmented cable tray.

The execution loop is machine-readable

Generated models are run through a subprocess wrapper instead of leaving failures in an unstructured traceback. The wrapper discovers STL, STEP, and 3MF files created during that run, then emits a JSON object with the generated paths, standard streams, return code, bounding boxes, watertight status, preview paths, and build-volume result. This gives the coding agent a compact state to act on when a boolean fails, a script forgets to export, or a part is too large for the printer.

python3 run_cadquery_model.py model.py --preview --strict --bed a1

Each optional gate catches a different failure class. --preview creates visual evidence. --strict rejects a run with no STL and fails non-watertight meshes. --bed checks every exported part against a named printer or an explicit build volume, allows a ninety-degree planar rotation, and keeps a five-millimeter margin on each side. A model that fails several checks receives all of the available errors in one result, which shortens the repair loop.

The six-view renderer shows isometric, front, right, back-isometric, top, and bottom views in one sheet. Its footer reports extents, volume, triangle count, watertight status, and an estimated PLA mass for two walls and fifteen percent infill. This is intentionally an inspection aid, not proof of printability. It helps expose missing through-holes, disconnected geometry, wrong wall placement, and a bad print orientation; it does not replace slicer preview or an actual printer.

Mating parts get a separate check

A collection of successful one-part previews says nothing about whether a lid or joint works. mating.py asks the model script to construct both parts, place the moving part in its assembled position, and verify two geometric conditions. First, the assembled parts must not intersect. Second, after shifting the moving part by the stated clearance plus a small probe distance along each selected axis, the parts must intersect again. The first condition catches collision; the second catches a joint that is so loose it will rattle or fail to locate.

The axis list is deliberately explicit. In the segmented desk cable tray example, the socket locates the neighboring segment sideways, while screws hold it against the desk and the joint is allowed to slide along the tray after installation. A generic check that demanded capture on every axis would reject a valid design. The opposite is also true: passing this test establishes geometric capture only. It does not establish the strength of a snap, the fatigue life of a clip, or the behavior of plastic under sustained load.

Gridfinity is implemented as a builder with constraints

gridfinity.py is not a decorative example. It encodes the forty-two-millimeter grid pitch, a 41.5-millimeter footprint per cell, seven-millimeter height units, the tapered base profile, stacking lip, 6 by 2 millimeter magnet bores, M3 screw holes, and the standard twenty-six-millimeter hole spacing. On top of that base it supports rounded pockets, polygon pockets, cylinders, compartments, scoops, label shelves, and finger notches.

Validation runs before the expensive boolean construction. The builder rejects walls and dividers below 1.2 millimeters, cavities that exceed the available depth, screw bores without a printable membrane, cylinder tilts above forty-five degrees, round-bottom cuts that are too shallow, and pockets that leave too little outer wall. It also checks compartment dimensions, notch placement, corner-radius conflicts, and tilted cutter clearance. Tests cover both rejection paths and watertight successful geometry, including a dimension and volume regression for a previously printed label-printer bin.

This distinction matters. A generic model generator can produce a cavity of any size until the kernel throws an error. A manufacturing-oriented builder should state why a configuration is unacceptable before the user wastes time and filament on it.

From a 3D scan to a usable pocket

outline_from_scan.py handles objects whose real footprint is more useful than a rounded rectangle. It principal-component-aligns the scan in the horizontal plane, centers it, moves its minimum Z to zero, optionally scales it to known dimensions, slices the bottom region every millimeter, and unions the cross-sections into one simplified outline. The output can be passed directly to the Gridfinity polygon-pocket API.

An optional search rotates the outline in tenth-degree increments to minimize its bounding square. The MX Master 3 example uses this to place the rotated mouse profile within a 3 by 3 Gridfinity footprint instead of a larger 4 by 3 layout. It also unions a tilted, round-bottom thumb well into the pocket so the user can lift the mouse out.

The scan pipeline still depends on a trustworthy scale. A distorted scan, a region with thin floating geometry, or a pocket depth that does not represent the useful lower body will create a correspondingly bad result. The tool reduces manual tracing work; it does not infer the real dimensions of the object.

The examples reveal the intended scope

ExampleManufacturing problemImplemented response
Orico D110 cradleAn asymmetric product with rounded and square ends must sit in a drawerA 3 by 2 Gridfinity bin with different corner radii and 1.3 millimeters of fit-and-grab clearance per side
MX Master 3 binA diagonal object wastes grid cellsA scan-derived polygon pocket, 43.9-degree rotation, and a 35-degree round-bottom thumb scoop
Cat flap coverA removed flap leaves a hole and an existing frame footprintA photographed measurement plus a published cut-out spec, VHB tape band, ribbed hollow locating plug, and door-thickness assertions
Under-desk cable trayA 400-millimeter tray exceeds the printer bedTwo printable segments, a socket that locates sideways, screw-mounted tabs, and an in-script mating check

The cat-flap example is a good test of the skill's dimension discipline. The visible frame was measured from a phone photo with a tape, while the hidden opening came from the manufacturer's specification. The resulting model combines a smooth bed-facing plate with a locating plug that carries side impacts instead of relying entirely on adhesive peel strength. The cable-tray example similarly treats print-bed size as a design input and checks the resulting assembly before export.

Installation and runtime requirements

The project is packaged as a Claude Code skill. A direct installation clones it into the user-level skill directory, creates a virtual environment, and installs the pinned dependencies:

mkdir -p ~/.claude/skills
git clone https://github.com/flowful-ai/cad-skill ~/.claude/skills/parametric-3d-printing
cd ~/.claude/skills/parametric-3d-printing
uv venv --python 3.12
source .venv/bin/activate
uv pip install -r requirements.txt

Python 3.10 through 3.12 is required because the OpenCASCADE bindings used by CadQuery do not provide wheels for 3.13 and later. Preview rendering also needs a working headless OpenGL backend. The code defaults to EGL on Linux and documents OSMesa as the fallback when no usable EGL context exists.

The export guidance is appropriately conservative. STL is enough for many slicers, STEP preserves editable boundary-representation geometry, and CadQuery can write 3MF natively. The repository warns that its standalone STL-to-3MF converter can mangle enclosed cavities because the triangle conversion may reverse inner normals. For a part with internal voids, exporting 3MF directly from CadQuery is safer than treating the converter as a lossless format adapter.

Where the skill stops

The intended use is functional manufacturing: enclosures, brackets, mounts, adapters, mechanical components, storage inserts, and parts that interface with real hardware. It explicitly excludes rendering, animation, game assets, digital-only art, photogrammetry, sculpting, and editing an arbitrary mesh the user already owns. That narrow trigger is a strength because CadQuery is a poor substitute for a mesh sculpting or rendering application.

The license is PolyForm Noncommercial 1.0.0. Personal research, experimentation, study, and hobby use are permitted, while commercial use requires a separate license. GitHub reports the license as NOASSERTION, but the repository's LICENSE file is explicit and should govern the decision. This is not a permissively licensed toolkit for a commercial product.

Assessment

CAD Skill is strongest where ordinary prompt-to-3D demos are weakest: it keeps dimensions editable, turns execution into a parseable state, renders the model from enough angles to inspect it, rejects bad mesh and bed-fit states, checks the geometry of mating parts, and packages known manufacturing patterns into reusable builders. It still relies on the operator to verify measurements and test prints, and its geometric checks are not structural analysis. Those boundaries are documented rather than hidden. For work that must end as a physical FDM part, this is a credible and unusually disciplined agent skill.

As an Amazon Associate, we earn from qualifying purchases.