text-to-cad-harness
Open source harness for generating 3D CAD models from text using AI coding agents with build123d/OpenCascade, exporting STEP/STL/URDF, and previewing in a local CAD Explorer viewer.
What this skill does
# ⚙ Text-to-CAD Harness
> Skill by [ara.so](https://ara.so) — Daily 2026 Skills collection.
An open source harness that lets AI coding agents (Claude Code, Codex, Cursor, etc.) generate, export, and preview 3D CAD models from natural language descriptions. Models are written in Python using [build123d](https://github.com/gumyr/build123d) on top of OpenCascade (OCP), exported to STEP/STL/DXF/GLB/URDF, and inspected in a local React/Vite CAD Explorer viewer.
---
## How It Works
```
User prompt → Agent edits models/*.py → Python skill regenerates artifacts → Viewer previews geometry
```
- **`models/`** — Source-controlled Python CAD files (build123d scripts)
- **`skills/cad/`** — Bundled CAD skill (STEP, STL, DXF, GLB, snapshots, `@cad[...]` references)
- **`skills/urdf/`** — Bundled URDF skill (robot links, joints, validation)
- **`viewer/`** — Local React/Vite CAD Explorer (no backend required)
---
## Installation
### 1. Clone the repo
```bash
git clone https://github.com/earthtojake/text-to-cad.git
cd text-to-cad
```
### 2. Set up Python CAD environment
```bash
python3.11 -m venv .venv
./.venv/bin/python -m pip install --upgrade pip
./.venv/bin/pip install -r requirements-cad.txt
```
> Requires Python 3.11+. The `requirements-cad.txt` pins build123d, OCP, and all geometry dependencies.
### 3. Install viewer dependencies
```bash
cd viewer
npm install
```
### 4. Start the CAD Explorer
```bash
npm run dev
```
Open [http://localhost:4178](http://localhost:4178) to browse generated models.
---
## Project Structure
```
text-to-cad/
├── models/ # Your CAD source files live here
│ └── my_part/
│ ├── part.py # build123d Python source
│ ├── part.step # Generated STEP export
│ ├── part.stl # Generated STL export
│ └── part.glb # Generated GLB for viewer
├── skills/
│ ├── cad/
│ │ ├── SKILL.md # CAD skill documentation
│ │ └── ...
│ └── urdf/
│ ├── SKILL.md # URDF skill documentation
│ └── ...
├── viewer/ # React/Vite local viewer
│ ├── package.json
│ └── src/
├── requirements-cad.txt # Python dependencies
└── assets/
```
---
## Writing CAD Models (build123d)
All models live under `models/` as Python scripts using [build123d](https://github.com/gumyr/build123d).
### Basic Part Example
```python
# models/bracket/bracket.py
from build123d import *
with BuildPart() as bracket:
# Base plate
with BuildSketch(Plane.XY):
Rectangle(80, 60)
extrude(amount=5)
# Vertical wall
with BuildSketch(Plane.XZ.offset(30)):
Rectangle(80, 40)
extrude(amount=5)
# Fillets on all edges
fillet(bracket.edges(), radius=2)
# Mounting holes
with BuildSketch(bracket.faces().filter_by(Axis.Z).sort_by(Axis.Z)[-1]):
with Locations((-25, -15), (25, -15), (-25, 15), (25, 15)):
Circle(3.5)
extrude(amount=-5, mode=Mode.SUBTRACT)
# Export
export_step(bracket.part, "models/bracket/bracket.step")
export_stl(bracket.part, "models/bracket/bracket.stl")
```
### Running a Model to Generate Artifacts
```bash
./.venv/bin/python models/bracket/bracket.py
```
### Parametric Part with Variables
```python
# models/hex_spacer/hex_spacer.py
from build123d import *
# Parameters — agent edits these values
OUTER_DIAMETER = 12.0 # mm, across-flats
HEIGHT = 10.0 # mm
HOLE_DIAMETER = 5.0 # mm (M5 clearance)
WALL_THICKNESS = 2.0 # mm
with BuildPart() as spacer:
with BuildSketch(Plane.XY):
RegularPolygon(radius=OUTER_DIAMETER / 2, side_count=6)
extrude(amount=HEIGHT)
with BuildSketch(Plane.XY):
Circle(HOLE_DIAMETER / 2)
extrude(amount=HEIGHT, mode=Mode.SUBTRACT)
fillet(spacer.edges().filter_by(Axis.Z), radius=0.5)
export_step(spacer.part, "models/hex_spacer/hex_spacer.step")
export_stl(spacer.part, "models/hex_spacer/hex_spacer.stl")
```
### Assembly Example
```python
# models/assembly/assembly.py
from build123d import *
# Base
with BuildPart() as base:
with BuildSketch(Plane.XY):
Rectangle(100, 80)
extrude(amount=10)
# Post
with BuildPart() as post:
with BuildSketch(Plane.XY):
Circle(8)
extrude(amount=50)
# Combine into assembly
assembly = Compound(
children=[
base.part,
post.part.move(Location((0, 0, 10))),
]
)
export_step(assembly, "models/assembly/assembly.step")
export_stl(assembly, "models/assembly/assembly.stl")
```
---
## Exporting Formats
From within any `models/*.py` script, use build123d export functions:
```python
from build123d import *
# STEP — full geometry, use for CAD interchange
export_step(part, "models/my_part/my_part.step")
# STL — mesh for 3D printing / simulation
export_stl(part, "models/my_part/my_part.stl")
# DXF — 2D drawing / laser cutting
section = part.section(Plane.XY)
export_dxf(section, "models/my_part/my_part.dxf")
# GLB — viewer-compatible 3D web format
export_gltf(part, "models/my_part/my_part.glb")
```
---
## URDF Robot Descriptions
The bundled URDF skill generates robot description files. See `skills/urdf/SKILL.md` for full docs.
### URDF Example Structure
```
models/my_robot/
├── robot.py # build123d geometry for each link
├── robot.urdf # Generated URDF XML
└── meshes/
├── base.stl
├── arm.stl
└── gripper.stl
```
### Minimal URDF Output Pattern
```xml
<!-- models/my_robot/robot.urdf (generated) -->
<?xml version="1.0"?>
<robot name="my_robot">
<link name="base_link">
<visual>
<geometry>
<mesh filename="meshes/base.stl"/>
</geometry>
</visual>
</link>
<link name="arm_link">
<visual>
<geometry>
<mesh filename="meshes/arm.stl"/>
</geometry>
</visual>
</link>
<joint name="base_to_arm" type="revolute">
<parent link="base_link"/>
<child link="arm_link"/>
<origin xyz="0 0 0.1" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<limit lower="-1.57" upper="1.57" effort="10" velocity="1"/>
</joint>
</robot>
```
---
## CAD Explorer Viewer
The local viewer reads exported files from `models/` and renders them in browser using WebAssembly (WASM).
### Viewer Commands
```bash
cd viewer
# Start dev server
npm run dev # → http://localhost:4178
# Build for static hosting
npm run build
# Preview production build
npm run preview
```
### Viewer Features
- Browse all models in `models/` directory
- Inspect STEP/GLB geometry in 3D
- Copy `@cad[...]` geometry references for agent follow-up edits
- Quick snapshot renders for iteration review
---
## `@cad[...]` Geometry References
After generating a model, the viewer provides stable `@cad[...]` handles. Paste these into your agent prompt to give it geometry-aware context for precise edits.
```
# Example agent follow-up using a reference
@cad[models/bracket/bracket.step#face:top] — add a countersunk hole at center
```
---
## Agent Workflow (Step-by-Step)
### Typical session with Claude Code or Codex
```
1. User: "Create a parametric L-bracket with 4 mounting holes, 5mm thick"
2. Agent: creates models/l_bracket/l_bracket.py using build123d
3. Agent runs: ./.venv/bin/python models/l_bracket/l_bracket.py
→ generates l_bracket.step, l_bracket.stl, l_bracket.glb
4. User: opens http://localhost:4178, inspects the model
5. User copies @cad[...] reference from viewer
6. User: "Make the wall taller — @cad[models/l_bracket/l_bracket.step#face:wall]"
7. Agent edits WALL_HEIGHT parameter in l_bracket.py, reruns script
8. User commits models/l_bracket/ (source + artifacts together)
```
---
## Common Patterns
### Pattern: Slot / Cutout
```python
with BuildPart() as panel:
with BuildSketch(Plane.XY):
Rectangle(100, 60)
extrude(amount=3)
# Horizontal slot
with BuildSketch(Plane.XY):
SlottedHole(length=30, radius=3, rotation=0, align=Align.CENTER)
extrude(amount=-3, mode=Mode.SUBTRACT)
```
### Pattern: Mirrored GeomRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.