cad-viewer
earthtojake/text-to-cad
Start a local CAD Viewer and generate review links for STEP, STL, implicit CAD, G-code, URDF, and other model files.
What is cad-viewer?
CAD Viewer opens explicit CAD files (STEP, STL, GLB, 3MF), implicit CAD (JS/MJS), G-code, DXF, and robot descriptions (URDF, SRDF, SDF) in a local web viewer. Use it to visually review generated models and hand back shareable review links, especially when chaining with CAD or G-code generation skills.
- .step, .stp, .stl, .glb, .3mf, .gcode, .dxf, .urdf, .srdf, .sdf file viewing
- Dynamic port selection and server reuse per directory
- Lightweight directory activation without manual port probing
- JSON output mode for Claude Preview integration
- Live review links with file-relative paths
How to install cad-viewer
npx skills add https://github.com/earthtojake/text-to-cad --skill cad-viewer- Node.js and npm installed
- Absolute path to model artifact directory (e.g., /repo/models)
- Generated model files in that directory (not source files)
How to use cad-viewer
- 1.Run `npm --prefix scripts/viewer run agent:start -- --host 127.0.0.1 --dir <absolute-model-root>` from the skill directory
- 2.Copy the printed Viewer URL
- 3.Append `file=<relative-path>` to the URL for each model file to review (e.g., `?dir=/path/models&file=design.step`)
- 4.Verify the artifact file exists before returning the link
- 5.For JSON output (Claude Preview), add `--json` flag and parse the last JSON line from stdout
Use cases
- Review STEP files generated by CAD generation skills before handoff
- Inspect G-code output from slicing or CAM workflows
- Visualize implicit CAD models (JS/MJS) for design validation
- Review robot descriptions (URDF/SRDF) with optional MoveIt2 IK planning
- Share review links with team members for design feedback
- CAD engineers and designers
- Roboticists working with URDF/SRDF
- G-code and manufacturing engineers
- Teams collaborating on 3D model review
cad-viewer FAQ
STEP (.step, .stp), STL, GLB, 3MF, implicit CAD (JS/MJS), G-code, DXF, URDF, SRDF, and SDF files.
No. The launcher automatically selects an available port and reuses existing servers for the same directory. Do not manually probe or rewrite ports.
No. Start/reuse one Viewer per absolute directory. Use `--dir` to specify the model root, then append `file=` for each artifact relative to that directory.
Report the failure and continue with the owning skill's non-GUI validation or artifacts. Do not stop the server unless the user asks.
Add `--json` to the `agent:start` command, parse the last JSON line from stdout, and probe `GET /__cad/server` until it returns HTTP 200 before passing the URL to Claude Preview.
Full instructions (SKILL.md)
Source of truth, from earthtojake/text-to-cad.
name: cad-viewer
description: Start or reuse CAD Viewer and return review links for explicit CAD, implicit CAD, robot-description, and G-code files. Use when visually reviewing .step, .stp, .implicit.js, .implicit.mjs, .glb, .stl, .3mf, .gcode, .dxf, .urdf, .srdf, or .sdf files, especially when handed off from CAD, implicit-cad, G-code, URDF, SRDF, or SDF generation skills.
CAD Viewer
Provenance: maintained in earthtojake/text-to-cad. Use the installed local skill files as the runtime source of truth; the repository link is only for provenance and release review.
Use this skill to open existing or newly generated CAD, implicit CAD, robot-description, DXF, or plain FDM G-code files in CAD Viewer and hand back live review links. The expected input is one or more explicit file paths.
Start Viewer
Start or reuse one local CAD Viewer with npm run agent:start, passing the
absolute artifact directory as --dir. The agent:start launcher owns port
selection, compatible-server reuse, directory activation, and the ?dir= query
parameter. Dev-mode viewers are reused only for matching git identities; dist
bundle viewers can be reused across git branches when their viewer versions
match. It activates reused servers through the Viewer's lightweight directory
activation API, without requiring agents to probe ports or trigger catalog
scans manually. Use the Viewer URL printed by agent:start as-is, then add only
a file= query value for the artifact you want to review.
Choose --dir as the absolute directory that contains the model
artifacts and sidecars, commonly <repo>/models or the consuming project's
equivalent model directory. The file= value must be relative to that --dir.
Do not manually choose ports, probe servers, rewrite ?dir=, or start a
separate Viewer just to change directories.
Run from this skill directory:
npm --prefix scripts/viewer run agent:start -- --host 127.0.0.1 --dir <absolute-model-root>
Use the printed Viewer URL and append file=:
http://127.0.0.1:<printed-port>/?dir=/absolute/project/models&file=path/to/model.step
If a non-Viewer process or another worktree's Viewer occupies the candidate
port, the launcher will continue automatically. In sandboxed agent environments,
local binding or probe failures such as EPERM or EACCES can be expected;
rerun the same command with the needed permission/escalation.
Links
- Before returning any
file=link, resolve<dir>/<file>and confirm the artifact exists. Pass the generated artifact (e.g..step), not its generator source (e.g..py). If the resolved path is missing, do not return the link, and instead report the problem and point to the correct generated artifact path. - Return one Viewer URL per requested file.
- Start/reuse the Viewer once per absolute directory
--dir, then appendfile=<path>for each requested file. The file path must be relative to--dir. - For directory-only review links, return the URL printed by
agent:startwithout addingfile=. - Do not stop an existing Viewer server unless the user asks.
- If Viewer startup fails, report the failure and continue with the owning skill's non-GUI validation or artifacts.
Claude Preview
The viewer port is dynamic — it is chosen at startup and may differ across
worktrees. To integrate with the Claude Preview tool, add --json to the
agent:start command:
npm --prefix scripts/viewer run agent:start -- --host 127.0.0.1 --dir <absolute-model-root> --json
The launcher writes a JSON result line to stdout after the human-readable lines.
Parse it by taking the last line of stdout that begins with {:
{"url":"http://127.0.0.1:<port>/?dir=<absolute-model-root>","port":<port>,"action":"reuse"}
action is "reuse" when an existing server was reused and is immediately
ready, or "start" when a new server process was spawned and may still be
initializing. For a "start" result, probe GET /__cad/server on the base
URL (e.g. http://127.0.0.1:<port>/__cad/server) until it returns HTTP 200
before passing the url value to the Claude Preview tool.
References
- Read
references/development.mdwhen the user asks to modify, debug, or iterate on CAD Viewer source. - Read
references/viewer-features.mdwhen you need supported file types, Viewer controls, or file-specific feature details. - Read
references/moveit2-server.mdonly when the user specifically needs optional SRDF MoveIt2 IK or path-planning controls.
Related skills
More from earthtojake/text-to-cad and the wider catalog.
cad
Create, modify, and validate parametric CAD parts and assemblies from natural language, technical drawings, or STEP files.
step-parts
Search and download off-the-shelf CAD parts from step.parts catalog—actuators, motors, connectors, fasteners, and more.
sdf
Generate, validate, and hand off SDFormat models and worlds for Gazebo and other simulators.
urdf
Generate and validate URDF robot descriptions from Python sources with frame-aware kinematic modeling.
srdf
MoveIt2 SRDF generation, validation, and planning-semantics workflow for robot manipulation.
sendcutsend
Preflight validation for SendCutSend.com DXF and STEP/STP orders against official specs and ordering rules.