cadcode

CAD for people who write code

You have a 3D printer and you know how to program. You shouldn't have to learn a CAD program to make a bracket. With cadcode you describe the part in JavaScript, watch it update in the browser on every save, and send the STL to your slicer.

npm install cadcode
A red and grey toy rocket with portholes and three fins, rendered by cadcode

A box in a dozen lines

No sketches, constraints or toolbars. Sizes are numbers, so changing the box means changing a number, not redrawing it.

npx cadcode dev box.js

Keep the preview open next to your editor. Save the file and the model updates in place, at the same camera angle.

import { cube } from 'cadcode';

export const params = {
  width: 60,
  depth: 40,
  height: 25,
  wall: 2,
};

export default (p) =>
  cube([p.width, p.depth, p.height]).subtract(
    cube([
      p.width - 2 * p.wall,
      p.depth - 2 * p.wall,
      p.height,
    ]).translate([p.wall, p.wall, p.wall]),
  );

Nothing new to learn

Variables, loops and functions instead of menus and modes. If you can write JavaScript, you can model a part tonight.

Your models live in git

A model is a text file. Diff it, branch it, revert the change that broke the fit, and share it as a repo instead of a binary project file.

Tweak, don't redraw

Put the sizes in params and reprint a variant with --set width=80. Wall too thin for your nozzle? Change one number.

Ready for the slicer

Solids come out watertight, built on manifold, the engine recent OpenSCAD uses. cadcode stl writes the file, one per part.

Teach your AI agent cadcode

A skill for Claude and Codex: the API, the program format, the differences from OpenSCAD, and a render-and-look loop, so the agent checks the part it built before handing it to you.

Claude Code

Unzip into your skills folder, or into .claude/skills of a project.

unzip cadcode-skill.zip -d ~/.claude/skills

Claude app

Upload the zip as it is in Settings → Capabilities → Skills.

Codex

Unzip into your skills folder, or into .codex/skills of a project.

unzip cadcode-skill.zip -d ~/.agents/skills