The Problem

Generating parametric 3D-printable models typically means hand-writing CadQuery scripts, iterating on geometry, and managing STL exports and previews manually. This repo packages that workflow as a Claude Code skill so an LLM can design, validate, and refine a part through natural-language requests, with the user inspecting rendered previews between iterations.

What This Does

The repo is a Claude Code skill plus a Python toolchain. gridfinity.py is the core: a tested parametric Gridfinity bin generator supporting stacking lips, magnets, compartments, and custom pockets. outline_from_scan.py extracts a pocket outline from a 3D scan, and preview.py renders headless STL-to-PNG previews. run_cadquery_model.py wraps script execution, captures errors, and emits JSON so Claude can self-correct in a loop.

Supporting files: mesh_io.py handles validated STL loading, stl_to_3mf.py converts to Bambu/Prusa formats, and examples/ contains two complete model scripts (a D110 label-printer cradle and an MX Master 3 mouse bin). SKILL.md defines the skill's trigger keywords and workflow instructions.

How It Is Wired

Execution starts at main in outline_from_scan.py:82, which reaches 22 functions. The typical flow: user describes a part → Claude writes a CadQuery script → run_cadquery_model.py executes it in a subprocess → preview.py renders views → Claude iterates.

The import graph shows 13 modules with 9 edges and no circular dependencies. mesh_io.py is the most-imported module (5 importers) but imports nothing itself—it's a stable leaf. gridfinity.py is the functional hub: 35 functions, 7 classes, called from 1 other file. The call graph confirms its blast radius: GridfinityBin and build are each called from 20 distinct places; _validate calls GridfinityError 17 times. Change those and the most breaks.

File-by-file responsibility: gridfinity.py owns bin geometry, preview.py owns rendering, run_cadquery_model.py owns the subprocess loop, outline_from_scan.py owns scan processing, stl_to_3mf.py owns format conversion. The two example scripts are thin—each defines one function and routes through gridfinity.py.

How To Use It

Setup:

mkdir -p ~/.claude/skills
git clone https://github.com/flowful-ai/cad-skill ~/.claude/skills/parametric-3d-printing
python3.12 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

Running it: Install as a Claude Code skill. Trigger via natural language ("design a wall mount for an Arduino Uno") or the /parametric-3d-printing slash command. Requires Python 3.10-3.12—CadQuery's OCC kernel has no wheels for 3.13+.

Real-World Use

A user asks for a Gridfinity bin for a Logitech MX Master 3. Claude writes a script using gridfinity.py, calls outline_from_scan.py to trace the mouse's footprint from a 3D scan, rotates it to minimize the bounding square, and generates a bin with a tilted thumb scoop. run_cadquery_model.py executes the script, preview.py renders six views, and the user inspects before printing.

Code Health & Issues

Static analysis (deterministic, from the pipeline's code analysis) found 10 issues: 3 high, 7 medium, 4 kinds.

  • High - Deep nesting - gridfinity.py, outline_from_scan.py, tests/test_gridfinity.py. Max indentation depth 11; control flow is hard to follow. Flatten with early returns/guard clauses.
  • Medium - Broad exception handling - preview.py. Bare or Exception-wide except swallows errors. Catch specific exceptions.
  • Medium - File opened without context manager - outline_from_scan.py. Use with open(...) for deterministic close.
  • Medium - Duplicated code blocks - examples/gridfinity_d110_bin.py, examples/mx_master3_bin_3x3.py. 5 repeated 6-line blocks across 2 files.

SDLC observations: no CI/CD pipeline (no .github/ or CI config), dependencies declared without a lockfile (requirements.txt only, non-reproducible builds). Tests exist (5 files) and a license is present. Four of six dependencies are behind current major versions (pillow, lxml, trimesh, numpy).

The Bottom Line

A focused, well-structured toolchain for LLM-driven parametric CAD. gridfinity.py is the workhorse and carries the most risk when changed. The main gaps are reproducibility (no lockfile), CI, and deep-nesting cleanup in the core module. Suitable for anyone using Claude Code for 3D-printable part generation who wants a tested, extensible foundation.