Skip to content

Authoring CAD with AI ​

Ask for a part in plain English. The agent writes it, runs it on a CAD kernel, and checks the result before handing it back.

   "a 40×20×10 mm bracket with two M4 holes"
                  │  agent writes bracket.brep.ts and runs
                  ▼  it on an OpenCascade kernel
   ────────────────────────────────────────────────────
   ✓ valid solid       ✓ volume ≈ 7,750 mm³ (within 1%)
   ✓ snapshots rendered    →  bracket.step ready to hand off
A real run: an agent turns the official Raspberry Pi 5 drawing into a case, brep verify catches a failed build, and the STEP opens in FreeCAD. Watch the narrated version.

An LLM can't see geometry. Code that reads correctly can still produce a solid that is broken, empty, or the wrong size, and the model has no way to notice. brepjs-cad closes that gap: the agent writes the part, runs it against the kernel, and reads back what the kernel measured instead of judging the code by eye.

What it checks ​

Every part gets three independent verdicts:

  • Validity: is it a manifold solid with positive volume? (the kernel's validSolid brand)
  • Intent: does it match the dimensions you asked for? (measureVolume / measureArea / bounds vs an expected block)
  • Shape: does it look like the request? (multi-view PNG snapshots, for the agent or you to review)

STEP is the validated deliverable; GLB, STL, and snapshots are derived previews.

What you install ​

brepjs-cad has a runtime any agent can use and an optional skill for Claude Code:

  • The runtime is the brep CLI. It loads your part on a kernel, checks validity, measures volume / area / bounds, renders snapshots, and exports STEP. Parts are plain TypeScript files, so any agent that can run a command can use it, and MCP clients can call the same checks through the bundled brep-mcp server.
  • The skill (Claude Code) teaches the agent the workflow (brief → author → verify → repair) and carries the API references and examples it draws on.

Install the runtime (npm) ​

Add the CLI to the project where you want parts verified:

bash
npm i -D brepjs-cad

That's the whole install. brepjs-cad bundles its own brepjs + occt-wasm, so it runs in an empty directory with nothing else set up. In an existing brepjs project it automatically prefers your locally installed brepjs and kernel (via a Node module-resolution hook), so your verified parts bind to the exact version you ship. There is no drift between what you verify and what you build.

It runs occt-wasm as its only kernel, rather than the auto-detect fallback chain, so verification results are reproducible on one known engine.

Prefer not to install anything? Run it straight from npm:

bash
npx -y -p brepjs-cad brep part.brep.ts

Connect an MCP client ​

brep-mcp exposes the same build-and-verify step to any MCP client as a stdio server:

bash
npx -y --package brepjs-cad brep-mcp

In Claude Code, for example: claude mcp add brep -- npx -y --package brepjs-cad brep-mcp. See brep-mcp for its tools.

Add the skill (Claude Code plugin) ​

The skill ships through the brepjs plugin marketplace, which is this git repo. Add the marketplace once, then install the plugin. In a Claude Code session, use the slash commands:

/plugin marketplace add andymai/brepjs
/plugin install brepjs@brepjs

Or do the same non-interactively from a terminal, handy for scripts and dotfiles:

bash
claude plugin marketplace add andymai/brepjs
claude plugin install brepjs@brepjs

The skill and the runtime install separately because Claude Code loads skills from plugins (a git marketplace), while the runtime has to live wherever your project's brepjs resolves. There is no npm step for the skill; plugins aren't loaded from node_modules.

Ask for a part ​

With any agent, ask for the part and have it run npx brep verify part.brep.ts after each edit until the report is ok. Point it at node_modules/brepjs-cad/reference/llms-full.txt, the full API reference the package bundles.

With the Claude Code skill installed, just ask in plain English and Claude reaches for the brepjs pipeline on its own:

a 40×20×10 mm bracket with two M4 holes 30 mm apart

It scopes the spec, designs the build sequence, authors the .brep.ts, verifies it on the kernel, and hands back a STEP file. To drive the pipeline explicitly, use the slash commands the plugin installs:

/brepjs:cad a wall bracket for a 40 mm pipe with two M4 holes

/brepjs:cad runs the whole pipeline and pauses for your confirmation between phases. To run a single phase, invoke it directly: /brepjs:brepjs-brainstorm, /brepjs:brepjs-design, /brepjs:brepjs-implement, /brepjs:brepjs-verify, or /brepjs:brepjs-polish.

The .brep.ts contract ​

A model is a TypeScript module whose default export is a zero-argument function returning a shape (or a Result<shape>):

ts
// bracket.brep.ts
import { box } from 'brepjs';

export default () => box(40, 20, 10, { centered: true });

Declare intent with an expected block and the CLI asserts it, so you confirm the part is the right part, not only a valid one:

ts
// bracket.brep.ts
import { box } from 'brepjs';

export const expected = { volume: 8000, tolerancePct: 1 };
export default () => box(40, 20, 10, { centered: true });

Author parts in an ESM context (the CLI's default). A CommonJS project needs "type": "module" in package.json, or name the file .mts.

Quickstart ​

bash
# scaffold a parameterized part
npx -y -p brepjs-cad brep init bracket

# author bracket/bracket.brep.ts, then verify (type-check + geometry) and write the report
npx -y -p brepjs-cad brep verify bracket/bracket.brep.ts --check --json report.json

# review it visually, then export the validated STEP
npx -y -p brepjs-cad brep verify bracket/bracket.brep.ts --snapshot shots/
npx -y -p brepjs-cad brep verify bracket/bracket.brep.ts --step bracket.step

The command exits non-zero whenever the report is not ok, so it drops straight into CI or an agent loop.

Next steps ​

Released under the Apache 2.0 License.