Skip to main content

Claude Code skill and diagnostics-first Build123d wrapper for LLM-driven CAD iteration.

Project description

cad-khana

A CLI tool and agent skill for designing 3D-printable mechanisms in Build123d, built for LLM-driven iteration.

khana (ख़ाना) is a Hindustani suffix meaning "house" or "workshop" — as in kar-khana (factory) or dawa-khana (pharmacy). cad-khana is a place for CAD.

Status: early. API may still churn.

What it does

cad-khana wraps Build123d with a diagnostics-first workflow. You (or an LLM agent) write Python scripts that declare parts and assemblies; the khana CLI runs them, exports STL/STEP, and writes a structured diagnostics.json reporting interferences, clearances, wall thickness, and overhangs. Assertions in the script become build failures when violated, so geometric constraints are enforced, not hoped for.

The tool is designed to close a specific gap: LLMs can reason about CAD geometry from code but need explicit feedback on the things a human would catch visually. Computed diagnostics cover the scalar questions; khana render produces PNGs a multimodal agent can read for shape-level questions that numbers don't express well.

Why it exists

Existing code-CAD tools (OpenSCAD, CadQuery, Build123d) assume a human with a render window. For agent-driven design, a different feedback loop works better:

  1. Agent writes a Build123d script.
  2. khana build runs it, exports geometry, writes diagnostics.
  3. Agent reads diagnostics, edits the script, repeats.
  4. When a shape-level question arises that diagnostics can't answer, the agent runs khana render and reads the PNGs directly.
  5. When the design is clean, a human reviews it in the OCP viewer.

Humans stay in the loop for taste and physical-world validation; correctness iteration happens in code.

CLI

khana build <path>      # run script, export, write diagnostics.json
khana check <path>      # diagnostics only, no export
khana view <path>       # build + push to OCP viewer
khana render <path>     # orthographic/iso PNGs for the agent to read
khana diff <old> <new>  # diff two diagnostics.json files

Install

Claude Code skill (recommended for agent use)

Copy both skills into your project (loads only in this project's context):

git clone --depth=1 https://github.com/cyberchitta/cad-khana /tmp/cad-khana
cp -r /tmp/cad-khana/skills/cad-khana .claude/skills/
cp -r /tmp/cad-khana/skills/cad-khana-setup .claude/skills/
rm -rf /tmp/cad-khana

Or for all projects (loads everywhere):

git clone --depth=1 https://github.com/cyberchitta/cad-khana /tmp/cad-khana
cp -r /tmp/cad-khana/skills/cad-khana ~/.claude/skills/
cp -r /tmp/cad-khana/skills/cad-khana-setup ~/.claude/skills/
rm -rf /tmp/cad-khana

Then ask Claude to run /cad-khana-setup — it installs the khana CLI via uv tool install and removes itself. After that, the cad-khana skill is loaded automatically when you ask Claude for CAD work.

Manual install

From a local checkout (for development):

uv sync
uv run khana build assembly.py

As a global tool from GitHub:

uv tool install git+https://github.com/cyberchitta/cad-khana

Viewer setup (for humans)

khana view pushes geometry to the OCP CAD Viewer, a standalone web server. The easiest host is the VS Code extension, which embeds the viewer in an editor pane.

Any editor that can launch a task and open a browser tab also works: run python -m ocp_vscode (from the cad-khana environment) to start the viewer, then bind khana view to a task (e.g. a Zed tasks.json).

The viewer is only needed for khana view; khana build, khana check, and khana render work without it.

Example

from build123d import *

from cad_khana.core.assembly import Assembly
from cad_khana.core.build import build


def housing(width: float = 40, depth: float = 30, height: float = 20):
    with BuildPart() as p:
        Box(width, depth, height)
    return p.part


def lever(length: float = 25):
    with BuildPart() as p:
        Box(length, 5, 3)
    return p.part


assembly = (
    Assembly()
    .add("housing", housing(), location=Location((0, 0, 0)))
    .add("lever",   lever(),   location=Location((0, 0, 12)))
    .assert_no_interference("lever", "housing")
    .assert_clearance("lever", "housing", min_mm=0.2)
    .assert_min_wall("housing", min_mm=1.5)
)

build(assembly, out="outputs/")

Project documents

  • CLAUDE.md — operational instructions for agents working on this repo.
  • NOTES.md — design rationale, key decisions, open questions.
  • skills/cad-khana/SKILL.md — agent-facing guide to using the tool.
  • skills/cad-khana-setup/SKILL.md — one-shot installer skill that self-deletes after running uv tool install.

License

Apache-2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cad_khana-0.0.1.tar.gz (111.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cad_khana-0.0.1-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file cad_khana-0.0.1.tar.gz.

File metadata

  • Download URL: cad_khana-0.0.1.tar.gz
  • Upload date:
  • Size: 111.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for cad_khana-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7f130565c06a9b966c04fc99d41d26048277bea1432581f35b4c2111a45b1b12
MD5 a4419cab8c02a8653e75554569ccbf81
BLAKE2b-256 8d05970cdb33eb4a42714c42f77d27d95179c9e4c0390d25ca5db43d1fa6f734

See more details on using hashes here.

File details

Details for the file cad_khana-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: cad_khana-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for cad_khana-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5d3d41ffb11d3723467966b52c8552d27a0d3b441a41b184b986f9c054e8c125
MD5 aced44ebf8876e83315200c2a58b88ae
BLAKE2b-256 611964a9ad4daadf3f8818f926c70266eb7f162987f97daab7e8e9d0f07fe991

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page