agentcad / docs

Docs

Every command, the output contract, and what lands on disk. Written to be read mid-session.

First time here? Start with the ten-minute walkthrough. It goes from an empty folder to a printable part, and explains what each response means along the way.

How it works

You write a Python script that calls show_object() on a shape. agentcad runs it, produces a versioned STEP file, computes geometric metrics, renders a four-view preview, opens a review viewer, and from the second version onward compares the result against the previous one. Every response is structured JSON.

Static validation catches syntax errors, a missing show_object(), and unresolvable imports in under 100 ms, without consuming a version number or writing to disk.

agentcad init writes the operating guide into the project as an AGENTS.md block and a Claude Code skill, so agents pick it up every session without being told. The full reference is agentcad --help and agentcad docs. Those are the source of truth, not this page.

Install

agentcad supports Python 3.10 to 3.12. The OpenCascade bindings it depends on do not exist for 3.13 yet.

python3.12 -m venv .venv
source .venv/bin/activate
pip install 'agentcad[mcp]'
agentcad init --name myproject

init creates the project and installs the agent guide: an AGENTS.md block (or CLAUDE.md, if that is what the project uses) plus a Claude Code skill.

CLI only, without the MCP server: pip install agentcad. With uv: uv tool install --python 3.12 'agentcad[mcp]'.

The default install is build123d only. CadQuery is an optional extra with its own dependency and licensing surface; see CadQuery compatibility. Putting agentcad inside a product or hosted service? Read Incorporating agentcad into your project.

Reading the output

Four conventions hold across every command. Getting these wrong is the most common way an agent misreads a successful run as a failure.

1. stdout is JSON, stderr is not

Progress lines go to stderr. Merging the streams before a JSON parser corrupts the parse.

agentcad run script.py --label first > result.json
# stdout: the JSON response
# stderr: human-readable progress lines

# WRONG. Progress lines corrupt the parse:
agentcad run script.py --label first 2>&1 | jq .

2. Core success and artifact success are separate

core covers the CAD lifecycle: metrics, validity, STEP export, version registration. When it reports success, the STEP exists and the version is registered. artifacts covers optional post processing, each group reporting pending, success, unavailable, timeout, failed, or skipped.

A failed preview does not undo a successful build. Keep the STEP and retry only the artifact you actually need.

3. outputs are 3D, renders are 2D

outputs holds 3D model artifacts, keyed step, script, stl, glb, obj. renders holds PNGs, keyed by view name or custom angle. Do not look for one inside the other.

4. status has five values

success
The command’s primary work completed.
failed
A script raised. Includes error, and for known failure shapes a suggestion. A version directory is created.
error
A CLI-level problem: missing file, bad arguments, no manifest. Includes message. No accepted CAD output is created; initialized runs may retain source and diagnostics.
validation_error
A static check failed before the CAD engine started. No numbered version or accepted STEP is created. The retained change can keep source and diagnostics unless the run is explicitly a dry run.
invalid_geometry
The script ran and metrics computed, but the final shape is not a valid solid. No STEP is exported and current does not advance. Check version_recorded and current_advanced.

Commands that read CAD files can also return empty, malformed, unknown_format, display_format, recognized_deferred, or limited, each with a message or suggestion.

Your first run

Initialize a project, write a two-line script, run it, read the JSON.

1. Initialize

agentcad init --name myproject

2. Write script.py. No imports needed; build123d and show_object are pre-injected.

# script.py
box = Box(10, 20, 5)
show_object(box)

3. Run it

agentcad run script.py --label first

4. Read the JSON, trimmed here

{
  "command": "run",
  "status": "success",
  "core": {"status": "success"},
  "artifacts": {
    "preview": {"status": "success"},
    "viewer": {"status": "success"},
    "renders": {
      "status": "skipped",
      "message": "No explicit renders requested."
    }
  },
  "runtime": "build123d",
  "output_type": "single_part",
  "version": 1,
  "label": "first",
  "outputs": {
    "step": "v1_first/output.step",
    "script": "v1_first/script.py"
  },
  "metrics": {
    "dimensions": {"x": 10.0, "y": 20.0, "z": 5.0},
    "volume": 1000.0,
    "surface_area": 700.0,
    "face_count": 6,
    "edge_count": 12,
    "is_valid": true
  },
  "preview": "v1_first/preview.png",
  "viewer": "v1_first/viewer.html",
  "viewer_glb": "v1_first/output.glb",
  "project_viewer": {
    "url": "http://127.0.0.1:PORT/projects/PRIVATE_PROJECT_TOKEN/",
    "latest_version": 1,
    "opened": true,
    "reused": false
  },
  "artifact_created": true
}

Geometry wrong? Check metrics.dimensions and metrics.volume first. Most problems are visible there before anything is rendered. Use agentcad measure to read feature sizes back off the finished file, and agentcad inspect for topology deep dives.

What lands on disk

Every successful run creates a numbered directory. Nothing overwrites anything.

v1_first/
  output.step       STEP geometry
  output.glb        GLB behind viewer.html
  script.py         copy of the executed script
  meta.json         full run metadata, including runtime and parts
  preview.png       4-view composite: top, bottom, upper iso, lower iso
  viewer.html       immutable version review snapshot
  parts/            one preview per named part
  renders/          requested PNG views

  # from v2 onward, against the previous success:
  diff_side.png     side by side
  diff_overlay.png  centered 2D projection map
  diff_volume.png   shared / reference-only / candidate-only 3D volume
  diff_volume.glb   interactive geometry behind diff_volume.png

Separate source and generated files

By default, versions and project state live at the project root. To keep generated files elsewhere, create agentcad.toml with:

build_dir = "./build"

Then run agentcad init. Versions, the manifest, generated geometry and metadata, previews, exports, viewers, logs, and feedback bundles now live below that build directory. Scripts, edit.py, and installed agent instructions stay in the source project. Add the build directory to your project's .gitignore. Changing the setting selects an independent history; it does not move or merge existing versions.

# Override project configuration for one command.
agentcad init --build-dir /tmp/cad-build
agentcad run model.py --label first --build-dir /tmp/cad-build
agentcad context --build-dir /tmp/cad-build
agentcad parts --build-dir /tmp/cad-build list current
agentcad recover v1_first --build-dir /tmp/cad-build

A command override does not edit project configuration, so repeat the flag on later commands. Precedence is --build-dir, then agentcad.toml, then the project root. Relative build paths resolve from the nearest project root, identified by agentcad.toml or the legacy manifest, even when invoked from a subdirectory. Without a marker, the invocation directory is the project root; an empty agentcad.toml can anchor a project that uses only overrides. Explicit input filenames still resolve from the caller's directory.

JSON reports project_root, build_root, and build_root_source. Use the returned artifact paths: configured roots return absolute paths, while default projects retain their existing relative paths. Standalone renders, exports, and viewers for outside inputs go into the selected root's derived directory. --label names a version; the deprecated --output alias never selects a destination. See agentcad docs artifacts for the full contract. MCP tools also accept an optional build directory.

Configured builds keep live-viewer service state under .agentcad/viewer inside the build directory, taking precedence over AGENTCAD_VIEWER_HOME. Each build root has its own service and URL; viewer open, status, and stop accept --build-dir. Default projects retain the shared user-level viewer service.

For the core-only fast path, combine --no-preview --no-diff --no-view. That leaves the STEP, the script, and meta.json with its metrics, plus anything you asked for explicitly.

Command reference

24 commands. Every one returns JSON with command and status.

WIP change workflows require --experimental-changes on every call: declared checks, staging, promotion, retained revision history/checks/views, and Python run retries/status. Ordinary CAD builds, imports, import retries and file/spec checks keep their standard behavior. Existing experimental requirements or unpromoted work cannot be bypassed by omitting the flag. Use the same build directory; a separate build history remains independent.

Create and import

Start a project, build geometry, or bring in a file someone else made.

init

agentcad init [--name NAME] [--runtime build123d|cadquery] [--force]

Initialize a project. Writes agentcad.json and records build123d as the CAD engine. Pass --runtime cadquery only for a CadQuery compatibility project; the choice pins docs, the script preamble, and the runner. --force replaces an existing manifest.

agentcad init --name myproject

run

agentcad run SCRIPT --label LABEL [OPTIONS]

Execute a script and produce a versioned STEP file, metrics, a preview, and a review viewer. The response says whether an artifact was created and returns its literal path in outputs.step. Static validation catches syntax errors, a missing show_object(), and unresolvable imports in under 100ms without consuming a version. Handing it a .step, .stp, or .brep path dispatches to import instead. Next package release: run responses and saved meta.json include delivery_readiness. A kernel-profile build remains an intermediate artifact with ready: false, even when status is success. blocking_reasons names each unchecked or incomplete delivery gate; full geometry validation must pass before ready becomes true. artifact_sha256 binds the saved verdict to outputs.step, so changed bytes require new validation. Geometry readiness does not establish task intent or edit preservation.

--label LABEL
Name this version. Read the generated file path from outputs.step.
--output LABEL
Deprecated compatibility alias for --label. It never denotes a destination path.
--render VIEWS
front, back, left, right, top, bottom, iso, 'all', or azimuth:elevation angles such as 45:30. Mix freely.
--export FMT
stl, glb, obj. GLB colors each solid separately.
--preview / --no-preview
4-view composite plus per-part previews. On by default. --no-preview alone still writes viewer.html and the diff images.
--diff / --no-diff
Compare against the previous success. On by default.
--view / --no-view
Open or reuse the live project viewer. On by default. Share project_viewer.url for automatic updates; viewer remains the fixed version snapshot.
--params K=V,...
Override top-level script constants.
--dry-run
Metrics only. No version consumed, nothing on disk.
--experimental-changes
WIP, explicit per-call opt-in. Required for --stage, --checks, --defer-checks and Python run retry/status. Ordinary builds keep standard CAD behavior.
--stage
WIP, requires --experimental-changes: save and check a candidate without replacing the accepted model. Inspect change.geometry or view its revision, then promote the saved bytes.
--idempotency-key KEY
Next package release: save one key per intended Python run. Retry identical source/options to replay its result without another execution or revision. Repairs need a new key.
--status
Next package release: read a Python run using only --idempotency-key and optional --build-dir, even after its source is edited or removed. Omit SCRIPT and --label.
--checks FILE
Declare retained dimension and preservation requirements. See docs check-spec for the declaration schema.
--defer-checks
Next package release: retain pending checks and normal automatic acceptance intent. Complete with check-spec REVISION --complete; staged work remains unaccepted. No background worker starts.
--runtime ENGINE
One-off compatibility override.
--no-daemon
Skip the warm worker. For debugging.

Prepared for the next package release: local imports search the script directory, then the source project root. Nested packages work, and helpers are read fresh per run without sharing modules between projects. Local helper code runs during execution, not preflight; failures include the helper traceback. Saved script.py contains only the entry script, so retain its helper files and use a new retry key after editing a dependency. For the core-only fast path, combine --no-preview --no-diff --no-view. Retry/status returns the original version, artifacts, and checks, which may differ from current work; current_advanced is false. Keyed Python runs execute locally under an OS lock. Concurrent callers wait up to 10 seconds before in_progress; stopped work is recovered without reexecution, or reports run_interrupted if no terminal result/version exists. Retry identity binds source bytes/path, caller directory, build options and checks content; dependencies are not frozen. Keep the saved retry records. Keys require a real run, not --dry-run. STEP dispatch uses import keys instead. See agentcad docs run-retries.

agentcad run script.py --label first --render iso --export stl

import

agentcad import FILE [--label LABEL] [--init] [--stage] [--idempotency-key KEY]

Bring an existing STEP or BREP file in as a versioned baseline with full provenance. Once imported it behaves like any other version: run, diff, render, view, and the edit helpers all work on it. --init bootstraps a manifest when the folder is not a project yet.

--experimental-changes
WIP, explicit per-call opt-in for --stage, --checks and --defer-checks. Ordinary import retry keys remain available without it.
--stage
WIP, requires --experimental-changes: retain source, normalized STEP, and checks without accepting the candidate. Prepare diagnostic views separately.
--checks FILE / --defer-checks
Next package release: pin requirements and optionally defer them. check-spec REVISION --complete accepts still-current normal import intent; stages remain explicit.
--idempotency-key KEY
Repeat the same source/options/key to recover an import without another version. Staged and automatic imports are different requests.
agentcad import bracket.step --init --label vendor_part

Look at it

Turn geometry into something you or a human can see.

render

agentcad render FILE --view SPEC [--zoom N] [--size WxH] [--msaa N] [--focus x,y,z] [--no-fit] [--name LABEL]

Render PNG views of an existing STEP file. Same view spec as run --render. --size defaults to 800x600 and --msaa defaults to 0; raise both for a render meant for a human. --no-fit requires --focus.

agentcad render v1_first/output.step --view front,top,iso --size 1600x1200 --msaa 4

export

agentcad export FILE --format stl,glb,obj

Export to mesh formats. STL for slicers, GLB for web viewers, OBJ for general 3D tools. GLB colors individual solids automatically. Files write alongside the source.

agentcad export v1_first/output.step --format stl,glb

view

agentcad view FILE [FILE_B] [--overlay] [--measure] [--spec SPEC_FILE]

Open the bundled three.js viewer in a browser. One file gives a single-model viewer; two files give a comparison, side by side by default or tinted overlay with --overlay. --measure embeds measurement data in the viewer's Spec check mode, and --spec runs check-spec first and opens on the result.

agentcad view v1_first/output.step v2_second/output.step

viewer

agentcad viewer [open|status|stop] [--build-dir PATH]

Keep one local project page open while your agent iterates. Successful runs and imports update the model automatically, preserving the camera and compatible review settings. Failed builds leave the last successful model visible. The URL survives builds and service restarts; moving the project folder changes its identity. These private loopback URLs work only on your machine. Use this page for spatial comments; file URLs and temporary view, diff, and parts viewers are read-only. An unfinished comment or reply holds the current model until it is saved, sent, or cancelled.

open
Open or reuse the current project's live page. Starts the service if needed. This is the default action.
status
Inspect the lightweight viewer service, separately from the CAD execution daemon.
stop
Stop the viewer service while retaining its port and project URLs. The next viewed build or viewer open restarts it.
--build-dir PATH
Select a configured artifact/history root and its viewer service.

--no-view never launches a browser or starts this service. An existing page still receives builds that generate viewer artifacts. The core-only --no-preview --no-diff --no-view path leaves the old model visible and reports preview unavailable. Default projects keep state at ~/.cache/agentcad/viewer; AGENTCAD_VIEWER_HOME overrides it for isolated automation. Configured build roots instead keep state in build_root/.agentcad/viewer, which takes precedence over that environment variable. Preserve the selected state directory to keep bookmarks stable. If another process occupies the saved port, free it and retry. Incompatible service protocols require stopping the service with the installation that started it before reopening.

agentcad viewer open

review

agentcad review list|show|comment|reply|resolve|reopen|submit|mark-addressed

Shared spatial threads for humans and agents, stored as local JSON under the selected build root's .agentcad/reviews directory. No database or account is required. In the live viewer, choose a part and Current, Previous, or Both, then Send comment. Save draft keeps it unsent. Either participant can reply, resolve with an optional closing reply, and reopen. Scope follows the displayed revision sides on later builds using the named part; missing parts stay listed as unplaced. Comments do not automatically wake an agent.

list [--status STATUS]
Read sent threads; --status draft explicitly includes unsent drafts. Run context before editing to discover pending feedback.
comment --part ID --message TEXT
Start an agent-authored thread. Optional --scope current|previous|both, --version REF, and --point-mm X,Y,Z. Previous and Both require a saved comparison viewer.
reply ID --message TEXT
Add an agent reply; optionally associate --version REF.
resolve ID [--message TEXT]
Close the thread, optionally with a reply and --version REF.
reopen ID [--message TEXT]
Reopen a resolved thread.
submit [ID ...]
Send selected drafts, or all drafts when no IDs are given.
mark-addressed ID --version REF
Compatibility workflow: record an addressing revision without resolving.

Use agentcad review --build-dir PATH list when selecting a separate build root explicitly.

agentcad review comment --part plate --message 'Should this edge be rounded?'

parts

agentcad parts list|show|view REF [OPTIONS]

Work with the named parts captured by show_object() calls. REF is a version number, vN, a label, a version directory, current, or latest.

list REF
Every part with its id, group, and metrics.
show REF PART_ID
One part by its stable string id.
view REF
A throwaway review viewer with parts isolated, hidden, ghosted, or focused, plus an optional note for the human reading it.

parts view takes --isolate, --hide, --ghost-rest, --focus, --isolate-group, --hide-group, --focus-group, --label, and --note.

agentcad parts view 2 --isolate-group gear --ghost-rest --note 'check tooth spacing'

Verify it

Read the geometry back rather than trusting the script that produced it.

measure

agentcad measure FILE [OPTIONS]

Dimensional report from a STEP or BREP file: overall metrics plus cylindrical feature buckets grouped by diameter and axis. This is the command to reach for when checking whether a hole, boss, or bore came out at the size you asked for.

--features
Full per-solid, per-face, and per-edge lists.
--cylinders-only
Core metrics plus cylinder buckets only.
--diameter N
Filter buckets to one diameter.
--tolerance N
Tolerance used with --diameter. Default 0.5.
--axis AXIS
+x, -x, +y, -y, +z, -z, or other.
--limit N
Cap records per list. Default 100.
--no-limit
Return everything, which can be very large.
agentcad measure v2_second/output.step --diameter 6

inspect

agentcad inspect FILE [--validate-only] [--validation-timeout SECONDS] [--ids] [--summary] [--limit N] [--no-limit]

Bounded topology report for debugging: solid_count, shell_count, face_count, face_orientations, edge_count, free_edge_count, and is_valid. Native loading, structural validation, topology extraction, and feature extraction report separate timings. If the validation budget expires, the command returns a structured, retryable timeout rather than calling the file malformed. --validate-only skips deep topology extraction for a faster structural check. --validation-timeout sets the budget in seconds; it defaults to 90, and 0 disables it. --ids returns per-feature ID lists for pick_face and pick_edge in edit scripts. --summary clusters faces and edges into semantic groups, which is the compact option when a full ID payload would blow the context budget.

agentcad inspect vendor_part.step --summary

check-spec

agentcad check-spec FILE SPEC_FILE | REVISION [--complete]

Check a file against a JSON feature spec and report passed, matched_features, missing_features, and total_abs_count_error. Writing the spec first turns “done” into something the agent can test against instead of eyeball. A failing spec is still a successful command: status stays "success" and the verdict is in passed. Next package release: a retained revision reads its pinned check results and live automatic promotion decision. --complete evaluates deferred checks, then automatically accepts a normal run/import only if its original candidate, policy, selection generation, and accepted predecessor still match. It copies the exact saved STEP/source and never executes edited source. Explicitly staged work still needs promote. No background worker starts. passed/validation_state describe the checks; promotion.outcome describes acceptance; current_advanced is true only for the call that accepts. Selecting a newer revision permanently cancels older automatic intent, including selection away and back. Passing old checks cannot revive it. Failed or unavailable required checks and changed accepted predecessors leave durable refusals; repair or make a deliberate new promotion attempt. Reads are read-only. Retry --complete after interruption to resume the same reservation without accepting twice. Older attempts without saved intent still need explicit promotion.

--complete
Complete pinned deferred checks and settle still-active automatic acceptance. A stage remains unaccepted. Use the same --build-dir as the revision.
agentcad check-spec v2_second/output.step spec.json

diff

agentcad diff REF1 REF2 [--visual] [--overlay]

Compare two versions or two CAD files. Reports metric deltas, parameter changes, per-part adds and removes, and for closed solids the exact shared and directional occupied volumes. --visual opens the comparison in a browser. Exact comparison runs under a 30 second budget. If it times out, a bounded voxel approximation runs instead and reports its resolution and error estimate, keeping the exact diagnostics under comparison_3d.exact_attempt. Raise AGENTCAD_DIFF_TIMEOUT_S and re-run the diff rather than rebuilding the model.

agentcad diff 1 2 --visual

Project state

Find out where you are, and pick up after an interruption.

context

agentcad context

Project state: name, tool_version, current version, version count, the full version list, and any interrupted directories that are candidates for recovery. Run it first when you join a project you did not start. The next package release also returns working_change: the selected retained revision, staging mode, and validation state, separately from the accepted version.

promote

agentcad promote --experimental-changes [REVISION] --idempotency-key KEY [--status]

Next package release: explicitly accept the exact selected saved CAD revision, without executing its source again. Use run/import --stage, inspect the candidate with view REVISION, then promote it when ready. Passing checks alone never accept an explicit stage. Save a key before sending. Repeat the same revision/key to resume an interrupted copy in the same reserved version or replay the original decision. --status reads it without changing any selection. Required failed, pending, or unavailable checks and a changed selection refuse explicit acceptance; after repair or new evidence, use a new key. Legacy recover cannot accept an unfinished promotion reservation. The response includes the original receipt and before/after version descriptors, plus the currently accepted revision. Status and replay report current_advanced=false. Promotion returns accepted STEP/source paths and a view action; it does not rebuild or render CAD. Normal deferred runs/imports instead retain automatic intent. Complete with check-spec REVISION --complete: passing checks accept only still-current intent, while explicit stages remain unaccepted. The pending response returns promotion.request_key (auto:REVISION), jobs, and no terminal outcome. Read that operation with promote --idempotency-key auto:REVISION --status. A newer selection permanently cancels it. Run/import retry results remain historical even after acceptance; check-spec and promotion status read the separate live decision.

--idempotency-key KEY
Required. One caller-known key per intended promotion attempt; keep it for retries.
--status
Omit REVISION to read the original operation only. No acceptance or selection change.
--target cad
This adapter accepts the CAD target. It cannot accept a robot package.
--build-dir PATH
Use the same artifact/history root used when staging the revision.
agentcad run bracket.py --experimental-changes --label thinner --stage
agentcad view r_RETURNED_ID --experimental-changes
agentcad promote r_RETURNED_ID --experimental-changes --idempotency-key approve-thinner
agentcad promote --experimental-changes --idempotency-key approve-thinner --status

changes

agentcad changes --experimental-changes list|show|compare|restore|repair

Next package release: browse retained attempts, including failed and interrupted work, then compare saved measurements and check evidence against an exact baseline. Reads never execute CAD, complete checks, select, promote, render, write history/logs, or change the viewer. Use immutable r_ revision IDs. working and accepted resolve the current retained selections once; repeated labels never identify or merge attempts. Older accepted numbered versions may have no retained ID: use context and diff their saved CAD files instead. show returns verified immutable source/geometry paths, saved model metadata, latest checks, original promotion decisions, and diagnostics. No-output failures report geometry=null and keep their own source/logs. Diagnostic text is capped at 2000 characters per field, artifacts at 50, promotions at 20, with omission counts and full record paths. Damaged list rows report integrity=unavailable while other history stays readable; show/compare refuse unverifiable evidence. compare reports stored metric deltas, source/model/parameter changes, check results and policy/definition changes. Equal dimensions, volume, IDs, or part labels do not prove equal geometry. Geometry status=not_run means no occupied-space analysis ran; same_bytes compares exact hashes only. When both saved STEPs exist, the next diff action uses those exact snapshots. A requirement change that turns fail into pass remains explicit. Use the same --build-dir as the original attempt; it is accepted before or after the changes subcommand. Local MCP tools: changes_list, changes_show, changes_compare. Hosted API parity and default working-viewer changes remain separate implementation slices. Under development: restore and repair create NEW staged working revisions, preserving accepted CAD and intervening attempts. The new parent is today’s working revision; recovery.source_revision_id records the historical input. Current intended requirements govern recovery; if none are selected, the saved requirements apply. Older geometry may therefore restore successfully while failing today’s checks. A recovery success does not prove promotion_ready. restore copies verified source, STEP, model settings, named parts/groups/parameters and all saved artifact bytes without executing source. Source-only failures retain their own failure evidence and geometry=null. Written geometry and declared requirements are checked now; source execution evidence remains historical. Copied viewers and catalogues are historical and may embed original paths/IDs: use view NEW_REVISION for a fresh fixed review. repair executes an edited Python CAD script through the existing run engine, inheriting the saved runtime and explicit parameter overrides. --params key=value,key2=value2 replaces the overrides; use an empty string to clear them. Imported CAD supports restore only. Passing repairs return staged; blocked repairs retain the failed candidate. Neither accepts a model: compare, review, then explicitly promote. Save a unique idempotency key before the call. Identical retries replay the original result; changed inputs conflict. Source-free --status accepts only the key and optional build directory, even after edited source is removed. Interrupted requests never automatically rerun. Concurrent newer work refuses recovery rather than silently changing pinned requirements. Both operations require the explicit WIP flag on every call; local MCP exposes changes_restore and changes_repair with experimental_changes=true.

--limit N
list only: 1..100 rows, default 20. Newest first; unavailable rows with missing/unreadable request records follow attempts with known ordering.
--before REVISION
list only: continue with the previous response's next_before cursor. Newer attempts do not shift older pages.
--build-dir PATH
Use the same artifact/history root as the saved revision; accepted before or after the subcommand.
--label LABEL
restore/repair: label for new staged work. No accepted version is replaced.
--idempotency-key KEY
restore/repair: one durable key per intended operation; identical retries replay, changed inputs conflict.
--status
restore/repair: read the original result using only key/build-dir, without source or side effects.
--params key=value,...
repair only: replace saved explicit parameter overrides; use an empty string to clear them.
agentcad changes list --experimental-changes --limit 20
agentcad changes show working --experimental-changes
agentcad changes compare accepted working --experimental-changes
agentcad changes show r_RETURNED_ID --experimental-changes
agentcad changes restore r_SAVED_ID --label restored --idempotency-key restore-1 --experimental-changes
agentcad changes repair r_FAILED_ID edited.py --label repaired --idempotency-key repair-1 --experimental-changes
agentcad changes repair --idempotency-key repair-1 --status --experimental-changes

recover

agentcad recover VERSION_DIR [--make-current]

Validate an interrupted version directory and register it in the manifest without deleting anything. Use it when a run was killed partway and context reports a recovery candidate.

agentcad recover v4_bracket

docs

agentcad docs [SECTION] [--runtime ENGINE]

The full documentation as JSON, offline, inside the CLI. With no SECTION it returns every section plus its content.

agentcad docs examples

Teach your agent

init runs both of these for you. Use them to refresh the guide after an upgrade, or to add it to a project that predates it.

skill

agentcad skill install | show [--runtime ENGINE]

install writes the agent skill to .claude/skills/agentcad/SKILL.md, where Claude Code discovers it without prompting. show prints the same content as JSON for agents that load skills a different way.

agentcad skill install

instructions

agentcad instructions install [--target auto|agents|claude|all] | show

install appends the agentcad snippet to AGENTS.md and CLAUDE.md so any agent reading project instructions picks up the workflow. auto updates whichever files exist, and creates AGENTS.md when neither does.

agentcad instructions install

Everything else

account

agentcad account connect|status|disconnect

Prepared for the next package release and available on enabled preview hosts. Connect a CLI installation through browser signup or sign-in and explicit approval. Run status afterward to finish connecting, then use the existing cloud commands. Manage or revoke installations from your website account page. Credentials live in a private file outside CAD projects. Local work needs no account. Requires a host with account connections enabled; see agentcad docs account.

# Requires the matching unreleased CLI checkout
agentcad account connect --name Laptop
agentcad account status
agentcad cloud projects list
agentcad account disconnect

cloud

agentcad cloud projects|activity|run|import|measure|inspect|check-spec|render|diff|export|job|download

Cloud adapter available from v0.7.1. Activity and personal-key environment configuration require the next matching client release or Preview checkout and an enabled host. Use cloud activity or the remote MCP cloud_activity tool to read account-owned recent jobs with pagination. Self-service keys use AGENTCAD_API_URL and AGENTCAD_API_KEY; approved CLI connections and existing pilot credentials remain supported. Upload explicit scripts, STEP files, or JSON specs; use returned project/version/job references for later calls. Submissions return immediately with a retry key. Poll the same job, then download private artifacts to explicit local files. See agentcad docs cloud for limits and arguments.

agentcad cloud projects create --name Bracket
agentcad cloud run PROJECT model.py --label first --export glb
agentcad cloud job PROJECT JOB --wait
agentcad cloud download PROJECT part.step --job JOB

feedback

agentcad feedback [MESSAGE] [--file FILE | --template [--output FILE] | --diagnostics | --send-diagnostics FILE] [--send] [--local-only] [--max-entries N]

Feedback is local by default. A human can enable or revoke automatic brief observations in the live viewer for this build root and recipient. Automatic sharing sends only up to 2,000 characters of MESSAGE and the AgentCAD version. Agents must never change that choice. Reports and long messages stay local unless the human requests --send for one submission. Diagnostics require review/redaction of the complete local payload before --send-diagnostics FILE --send. No context is added to that reviewed object. Local copies are saved before upload. Check storage and notification delivery separately.

agentcad feedback "the inspect output is hard to read"
agentcad feedback --template --output feedback.md
# Fill in the report, then record it locally:
agentcad feedback --file feedback.md

subscribe

agentcad subscribe EMAIL

Sign an address up for agentcad updates. Double opt-in, so a confirmation link goes to the inbox first.

Writing a spec

A spec file turns “done” into something your agent can test against. Write it before the geometry, then check the finished file:

{"features": [
  {"name": "bolt_holes", "type": "cylinder", "diameter_mm": 6, "count": 4}
]}
agentcad check-spec v2_bracket/output.step spec.json

In v0.8.1, positioned_cylinders matches declared 2D positions one-to-one against cylinder axes of a chosen diameter and axis. For Z cylinders use (x,y), X uses (y,z), and Y uses (x,z). This checks cylinder evidence; it does not establish hole depth or which side contains material. At most 200 positions are accepted. Read agentcad docs check-spec for the tolerances and standalone spec schema.

The keepout and material checks measure material volume inside a box in the assembly frame. Keepouts set a maximum volume, defaulting to zero; material checks require a positive minimum. Signed coordinates are allowed. Overlapping solids count once. These are volume checks, not minimum wall-thickness or clearance measurements. Failed probes report their own box and reason while other evidence remains usable.

A failing spec is still a successful command. Read passed, matched_features, and missing_features for the verdict. Run agentcad docs check-spec for the full schema.

Copyable recipes

In v0.8.1, agentcad docs recipes points your agent to complete source examples. Recipes live in the repository, outside the installed package. Download the entire PCB enclosure directory and copy it into your project. It uses the default build123d runtime; its helpers are local to the example, outside the public Python API.

The example builds a tray with board supports and connector openings, plus a screw-on lid. Adapt board.json and enclosure.py, then run these commands from the copied directory:

agentcad init --name pcb-enclosure --runtime build123d
agentcad run example.py --label pcb_v1 --render iso
# Use outputs.step from the run response:
agentcad check-spec <outputs.step> checks.json

Verify the sample board measurements and hardware assumptions. Geometry checks do not establish physical board fit, screw selection, manufacturing tolerances, or antenna performance.

Script preamble

On the default build123d runtime, every script run by agentcad run has the entire build123d public API available without imports, plus the agentcad helpers:

Box / Cylinder / Sphere / Cone / Torus / Wedge
primitives
Wire / Edge / Face / Solid / Compound / Part
topology types
extrude / revolve / sweep / loft / offset
operations
fillet / chamfer / mirror / scale
modifiers
Plane / Axis / Vector / Location / Locations
positioning
Mode / Align / Kind / Until / Select
enums
BuildPart / BuildSketch / BuildLine
builder contexts
show_object
surface one shape as a named part
show_assembly
surface an intentional multi-body result
load_step / pick_face / pick_edge
editing helpers for imported geometry
naca_wire / spline_wire / polygon_wire / ellipse_wire
wire helpers, return raw OCP shapes
loft_sections / tapered_sweep / elliptical_sweep
sweep helpers

Helpers return raw OCP shapes, so wrap them for build123d: extrude(Face(Wire(naca_wire(...))), amount=5). Explicit imports stay harmless and help editor completion. Run agentcad docs preamble for the authoritative list and agentcad docs examples for worked scripts.

Metrics

Returned on every successful run, saved in meta.json, and compared by agentcad diff.

bounding_box   {x: [min, max], y: [min, max], z: [min, max]}
dimensions     {x, y, z}     bbox extents
volume         float
surface_area   float
center_of_mass {x, y, z}
face_count     int
edge_count     int
is_valid       bool or null  deliverable verdict
reliable       bool          whether physical metrics can be trusted

agentcad is unit-agnostic. Scripts default to millimetres, the OpenCascade convention, so volume is mm³ and area is mm² unless your script chose otherwise.

Volume measures material, while face and edge counts are advisory: boolean operations routinely merge coplanar faces, so a feature that adds material can lower face_count.

Prepared for the next package release: overlapping solid members count once in volume and center of mass, while saved parts stay separate. Multi-solid metrics include volume_measurement. If occupied volume cannot be measured, its status is fallback and the original members are summed with a warning and reliable=false. That estimate can double-count overlaps. Surface area and topology counts still describe the original members.

CadQuery compatibility

CadQuery remains supported for existing projects and scripts. Make the choice explicit so the project, the docs, and the runner stay on one API.

Install the extra first

pip install 'agentcad[cadquery]'
agentcad daemon restart

CadQuery is not part of the default install. The extra adds CadQuery and its own dependency chain (CasADi and the COIN-OR solver libraries it bundles), a larger third-party license surface than the build123d default. Selecting the CadQuery runtime without the extra returns a structured error naming this command. Details in Incorporating agentcad into your project.

Start a CadQuery project

agentcad init --name legacy-model --runtime cadquery
agentcad docs quickstart --runtime cadquery

Run one legacy script inside a build123d project

agentcad docs preamble --runtime cadquery
agentcad run legacy.py --label legacy --runtime cadquery

Keep each script on one CAD API. A clear mismatch fails before consuming a version and reports the exact override to use. See agentcad docs runtimes.

MCP integration

For native tool integration with Claude Code, Cursor, Windsurf, or any MCP-compatible agent:

pip install 'agentcad[mcp]'

Add to .mcp.json:

{"agentcad": {"command": "python", "args": ["-m", "agentcad.mcp"]}}

When agentcad lives in a project virtual environment, point at that interpreter instead so the server does not launch under the wrong Python:

{"agentcad": {
  "command": ".venv/bin/python",
  "args": ["-m", "agentcad.mcp"]
}}

Exposed as tools: run, render, export, measure, inspect, check_spec, diff, view, docs, context, recover. Same JSON as the CLI, same fields. Local CAD tools take a cwd pointing at the project directory. The CAD runtime stays warm between calls, so later runs skip the cold import.

WIP change workflows require the explicit boolean experimental_changes: true on each MCP call. Omitting it or passing false keeps the ordinary workflow; there is no session or configuration opt-in. Revision check_spec/view, promote, changes tools and run_status also require it. Opted-in responses identify work_in_progress and current recovery commands retain the CLI flag.

Next package release: run accepts an idempotency_key for safe retries. Use run_status(idempotency_key, cwd, build_dir) to read the original result after its working source is changed or removed. Keyed Python runs execute locally under an OS lock. See agentcad docs run-retries for stopped-run recovery and historical result semantics.

Next package release: changes_list(cwd, build_dir, limit, before), changes_show(revision, cwd, build_dir), and changes_compare(baseline, revision, cwd, build_dir) browse verified saved attempts without selecting, accepting, checking, or running CAD. Use r_ IDs or working/accepted aliases; compare reports stored evidence and policy changes, with a separate action for a geometry diff.

Under development: changes_restore(idempotency_key, cwd, revision, label, build_dir) restores saved work; changes_repair adds source and optional params for an edited Python script. Both require experimental_changes=true and create staged successors under current intended requirements. Neither accepts CAD. Set status=true with only key/cwd/build_dir to read the original result without source or side effects. Identical retries replay; changed inputs conflict; interrupted requests never automatically rerun. Use view on the returned revision for a fresh review before explicit promotion.

Next package release: check_spec(file=REVISION, complete=True) completes deferred checks and accepts a still-current normal run/import intent. Staged or superseded work stays unaccepted. Read promotion.outcome separately from passed; current_advanced identifies a fresh acceptance. Normal reads never change current.

Cloud tools (v0.7.1+)

With an API address and issued credentials, the same local MCP server offers cloud_run, cloud_import, cloud_measure, cloud_inspect, cloud_check_spec, cloud_render, and cloud_diff. With matching client and host export support, cloud_export creates whole-model STL, OBJ, and GLB files from a saved version. Project, job, and download tools complete the workflow. Set AGENTCAD_API_URL, AGENTCAD_KEY_ID, and AGENTCAD_KEY_SECRET in the server process environment; keep credentials outside project files and agent prompts.

Only explicitly named files are uploaded. No local project is needed. Poll cloud_job with the returned IDs; keep idempotency_key for an identical lost-response retry. cloud_download saves a private STEP, PNG, JSON report, or exported mesh to an explicit destination and preserves existing files by default. See agentcad docs cloud for the command and tool reference.

The cloud export extension requires matching client and service builds; an older published client may not include it. Poll its export job and read each mesh validation result before delivery. Mesh downloads are capped at 32 MiB each and 64 MiB total. The engine retains numeric millimeters, including in Y-up GLB; consumers using meters must apply the reported scale of 0.001. Whole-model exports do not preserve source part names or groups.

With matching build-time GLB support, use cloud_run with export_glb=true, or agentcad cloud run with --export glb. This generates the GLB while part geometry is available, retaining authored part IDs and colors. Check mesh_exports.glb.status and its validation verdict, then download kind glb using the build job. GLB is opt-in; a missing or invalid GLB reports failure while a successful STEP remains saved. Full group hierarchy and separate display names are not preserved.

Job completion, geometry validity, spec verdicts, and human approval remain separate. This adapter runs locally and calls HTTPS. The CLI adapter uses the cloud extra, which is included with the MCP extra.

Follow the cloud workflow guide for the published v0.7.1 install, agent setup, and a complete build, import, edit, and verification loop. Each operation has its own job; keep the returned version numbers and poll that job before using its output.

Hosted MCP

If your host supplies an MCP URL, a supported agent can connect directly without installing AgentCAD locally. The client needs Streamable HTTP and the issued key ID and secret in custom HTTP headers. The workflow guide above includes a Codex URL configuration using environment variable names rather than secret values.

Ask the connected agent to call cloud_help. Hosted tools accept script_text, STEP content or an explicit cloud artifact reference, and a spec JSON object. cloud_artifact can return a private reference or bounded PNG, STEP, and JSON content through MCP. The hosted connection uses the same projects, jobs, and verdicts as the API; its availability comes from your host and is independent of a local package release.

Built-in docs

agentcad ships its full documentation inside the CLI as JSON, so an agent never needs this website. Run agentcad docs for everything, or name a section:

agentcad docs quickstart     # first-script walkthrough
agentcad docs examples       # worked scripts
agentcad docs patterns       # idioms and footguns
agentcad docs editing        # editing imported geometry
agentcad docs measure        # dimensional verification
agentcad docs parts          # named parts and groups
agentcad docs schema         # full response contract
agentcad docs recovery       # picking up after an interruption

All 35 sections: artifacts, build123d, cadquery, changes, check-spec, account, cloud, commands, daemon, editing, examples, export, feedback, helpers, inspect, install, mcp, measure, metrics, parametric, parts, patterns, preamble, promote, quickstart, recipes, recovery, render, review, run-retries, runtimes, schema, validation, viewer, workflow.

Choose what feedback leaves your machine

Feedback is local by default. In the live viewer, a human can enable or revoke automatic brief observations for this build root and recipient. Agents must never toggle that choice. Automatic sharing sends only the message (up to 2,000 characters) and AgentCAD version, without command logs, source, or environment details.

agentcad feedback "the inspect output is hard to read"
agentcad feedback --template --output feedback.md
# Fill in the report, then record it locally:
agentcad feedback --file feedback.md

Templates send nothing and never overwrite existing files. Long messages and file reports stay local unless the human requests a one-off upload with --send. This does not enable future sharing. Use --local-only to keep an observation local even when automatic sharing is enabled.

Review diagnostics separately

agentcad feedback --diagnostics
# Review the complete local payload and redact the saved JSON.
# Only after the human authorizes that reviewed payload:
agentcad feedback --send-diagnostics reviewed.json --send

Preparation sends nothing. Diagnostics can contain command arguments, results, and environment details: review the full object before sending. The upload uses exactly the reviewed JSON, without added context. The local MCP feedback tool follows the same rules and cannot enable automatic sharing.

A local copy is saved before upload. Read remote storage separately from notification delivery; a failed notification after confirmed storage does not require resubmitting. If the recipient changes, stop and reopen the viewer and make a fresh human sharing choice.

Get release updates

Optional. New releases and agent-facing features. We’ll send a confirmation link before adding you.