# CAD Skill for Claude Code
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.
<p align="center">
<img src="docs/magsafe_stand_preview.png" alt="MagSafe stand preview, 4 views" width="480">
<img src="docs/iphone13_pro_case_preview.png" alt="iPhone 13 Pro case preview, 4 views" width="480">
</p>
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)
## More examples
Published on [MakerWorld](https://makerworld.com/en/@sercanto).
<p align="center">
<img src="docs/gridfinity_d110_bin_preview.png" alt="Gridfinity 3x2 bin for Orico D110 label printer" width="640">
</p>
<p align="center">
<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">
</p>
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.
<p align="center">
<img src="docs/cat_flap_cover_preview.png" alt="Cover plate for a removed Cat Mate cat flap" width="640">
</p>
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.
<p align="center">
<img src="docs/desk_cable_tray_preview.png" alt="Under-desk cable tray segment with socket joint" width="640">
</p>
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.
<p align="center">
<img src="docs/magnet_catch_preview.png" alt="Magnetic door catch (frame side)" width="640">
<img src="docs/magnet_strike_preview.png" alt="Magnetic door catch (door side)" width="640">
</p>
## Installation
```bash
mkdir -p ~/.claude/skills
git clone https://github.com/flowful-ai/cad-skill ~/.claude/skills/parametric-3d-printing
```
## Usage
Once installed, the skill activates in two ways inside Claude Code:
- **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).
- **Explicit slash command.** Type `/parametric-3d-printing` to invoke it directly, useful when your request does not contain the obvious keywords.
Claude will then walk you through requirements, build the model in phases (base shape, features, finish), and deliver an STL plus a rendered preview.
## Dependencies
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:
```bash
uv venv --python 3.12 && source .venv/bin/activate
uv pip install -r requirements.txt
```
Without uv, with Python 3.10-3.12 already installed:
```bash
python3.12 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
```
## Files
| File | Purpose |
|------|---------|
| `SKILL.md` | Skill definition and workflow instructions for Claude |
| `gridfinity.py` | Tested Gridfinity bin generator (base profile, stacking lip, magnets, compartments, custom pockets). Vendored next to generated scripts. |
| `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. |
| `outline_from_scan.py` | Extracts a pocket outline from a 3D scan of an object (align, scale, slice, union), ready for `add_polygon_pocket`. |
| `examples/` | Example model scripts: Gridfinity bins (D110 cradle, MX Master 3 diagonal bin), cat flap cover plate, segmented desk cable tray. |
| `preview.py` | Headless STL to 6-view PNG renderer (trimesh + pyrender). Use `--strict` to fail on non-watertight meshes. |
| `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. |
| `mesh_io.py` | STL loading with validation (no pyrender dependency). Used by the wrapper and converter. |
| `stl_to_3mf.py` | Standalone STL to 3MF converter for Bambu Studio / PrusaSlicer. |
| `design-review.md` | Visual inspection checklist and printability analysis |
| `requirements.txt` | Pinned dependency versions |
## License
The skill and scripts are licensed under the [PolyForm Noncommercial License 1.0.0](LICENSE). Free to use, modify, and distribute for noncommercial purposes.
---
Created by [Nicolas Chourrout](https://github.com/nchourrout) from [Flowful.ai](https://flowful.ai)