Close
0%
0%

typeCAD

programmatically create hardware

Public Chat
Similar projects worth following
TypeScript + KiCAD = typeCAD

- Write TypeScript code and build it into a KiCAD project
- Use all the normal software tools, but now for hardware
- Package your code into small packages
- Quickly combine known-working packages into larger projects

Instead of using the KiCAD schematic editor, you write code and build it into a KiCAD schematic.

typeCAD uses TypeScript. You don't need extensive knowledge of TypeScript to get started.
If you're familiar with any programming language, you can pick up the basics of TypeScript pretty quickly.

KiCAD

The normal flow in KiCAD is:
1. Create a project and schematic
2. Add components
3. Make connections
4. Lay out the board

typeCAD

typeCAD replaces steps 1-3. Instead of clicking and dragging to place components and make connections, TypeScript code is used.
This is how a schematic is created.

import { Schematic } from '@typecad/typecad';

let typecad = new Schematic('typecad');
typecad.create(); 

That code will create a KiCAD netlist named `typecad.net`, which you can then import into a KiCAD PCB file. No schematic file is created because it's not needed.

Build
typeCAD projects have a build process. It takes the TypeScript code and turns it into a KiCAD project. The code you write and the typeCAD API simply runs itself, resulting in the KiCAD project.

 
Workflow
The new layout becomes:
1. Create a typeCAD project
2. Edit the code to add components and make connections
3. Build it
4. Import the KiCAD netlist into KiCAD to lay out the board

  • typeCAD Stack

    typecad08/16/2025 at 23:28 0 comments

    We've recently completed and refined several tools that people will find useful when developing hardware with typeCAD:

    @typecad/typecad-docgen - convert markdown files and KiCAD PCBs into documentation with support for layer exports and renders

    @typecad/typecad-gitdiff - See the differences between KiCAD PCB files

    @typecad/schematic - Generate KiCAD schematics from your typeCAD project

    @typecad/kicad2typecad - Parse KiCad PCB board files and generate typeCAD code

    @typecad/kicad-symbols - Fuzzy search for KiCad schematic symbols


    They are all installed by default now with a new typeCAD project.

  • Search for JLCPCB parts easier

    typecad07/21/2025 at 21:45 0 comments

    @typecad/jlcpcb-parts

    Intelligent fuzzy search for JLCPCB basic and preferred electrical components with CLI interface. This TypeScript-based npm package provides smart component search capabilities by automatically managing a local database of JLCPCB parts and offering natural language search with intelligent parameter matching.

    Dependencies

    This package uses CDFER/jlcpcb-parts-database which provides a daily CSV download of all basic and preferred parts. That project depends on yaqwsx/jlcparts. Please consider supporting them.

    Features

    • 🔍 Intelligent Fuzzy Search: Find components using natural language descriptions
    • 📦 Automatic Database Management: Downloads and caches JLCPCB components database
    • ⚡ Fast CLI Interface: Quick command-line searches with formatted output
    • 🎯 Smart Parameter Parsing: Recognizes electrical values, packages, tolerances, and more
    • 📊 Scored Results: Get ranked results with match explanations
    • 🔄 Auto-Updates: Keeps component database fresh (24-hour cache)
    • 🎨 Multiple Output Formats: Detailed, compact, table, or JSON display options
    • 🔧 Programmatic Integration: JSON output for scripting and automation

    Installation

    Global Installation (Recommended)

    npm install -g @typecad/jlcpcb-parts

    After global installation, you can use the jlcpcb-search command from anywhere:

    jlcpcb-search "10k resistor 0603"

    Local Installation

    npm install @typecad/jlcpcb-parts

    Quick Start

    Basic Search

    # Search for a 10kΩ resistor in 0603 package
    jlcpcb-search "10k resistor 0603"
    
    # Search for a 100µF capacitor rated for 16V
    jlcpcb-search "100uF capacitor 16V"
    
    # Search for buttons
    jlcpcb-search "SPST button"

    Advanced Usage

    # Use table format for compact display
    jlcpcb-search "LM358 op amp" --format table
    
    # Sort by manufacturer and show 1 result
    jlcpcb-search "ceramic capacitor 0402" --sort manufacturer --limit 1
    
    # Compact format for quick overview
    jlcpcb-search "LED red 0603" --format compact
    
    # JSON format for programmatic use
    jlcpcb-search "10k resistor" --format json

    Usage

    Command Line Interface

    jlcpcb-search [options] <search query>
    
    Options:  -h, --help                Display help message  -v, --version             Display version information  -f, --format <format>     Output format: detailed, compact, table, or json (default: detailed)  -s, --sort <field>        Sort by: score, lcsc, manufacturer, or package (default: score)  -l, --limit <number>      Limit number of results (default: 5)
    

    Search Query Examples

    The tool understands natural language descriptions and can parse various electrical parameters:

    Resistors

    jlcpcb-search "10k resistor 0603"           # 10kΩ resistor in 0603 package
    jlcpcb-search "1M ohm 1% 0805"              # 1MΩ resistor with 1% tolerance
    jlcpcb-search "220 ohm thick film"          # 220Ω thick film resistor

    Capacitors

    jlcpcb-search "100nF 50V X7R 0603"          # 100nF ceramic capacitor
    jlcpcb-search "10uF 16V tantalum"           # 10µF tantalum capacitor
    jlcpcb-search "1mF electrolytic 25V"        # 1mF electrolytic capacitor

    Inductors

    jlcpcb-search "10uH inductor 0805"          # 10µH inductor
    jlcpcb-search "100nH ferrite bead"          # 100nH ferrite bead

    ICs and Active Components

    jlcpcb-search "LM358 op amp"                # LM358 operational amplifier
    jlcpcb-search "STM32F103 microcontroller"   # STM32F103 microcontroller
    jlcpcb-search "AMS1117 voltage regulator"   # AMS1117 voltage regulator

    Connectors and Mechanical

    jlcpcb-search "USB"                         # IC
    jlcpcb-search "2.54mm header male"          # 2.54mm pin headers
    jlcpcb-search "tactile switch 6x6"          # Tactile switches

    Output Formats

    Detailed Format (Default)

    Shows complete component information with match explanations:

    Found 3 matching components:
    
    1. C25804 - 10kΩ ±1% 0603 Thick Film Resistor Manufacturer: UNI-ROYAL(Uniroyal Elec) Part Number: 0603WAF1002T5E Package: 0603 Match Score: 95.0 Match Details: Exact resistance match (100 pts), Package...
    Read more »

  • An MCP Server for AI

    typecad07/17/2025 at 15:43 0 comments

    typeCAD MCP Server

    An MCP (Model Context Protocol) server that provides AI assistants with direct access to typeCAD tools and workflows. This enables seamless integration between AI coding assistants and typeCAD’s electronic design automation capabilities.

    What is MCP?

    MCP (Model Context Protocol) is a standard that allows AI assistants to connect to external tools and data sources. This server exposes typeCAD’s functionality as MCP tools, letting AI assistants create projects, add components, validate designs, and more.

    Features

    The server provides these typeCAD tools to AI assistants:

    • 🏗️ Create Project - Initialize new typeCAD projects with optional PlatformIO support
    • 🧩 Add Component - Add components from KiCAD libraries or JLCPCB catalog
    • 📄 PDF to Text - Convert component datasheets from PDF to text format
    • 📚 Download Docs - Fetch the latest typeCAD documentation
    • ✅ Validate Component - Verify component definitions against datasheets
    • 📦 Create Package - Generate complete IC packages from datasheets and schematics

    Passive Components

    Quick access to common passive components using the @typecad/passives package:

    • 💈 Add Resistor - Create resistors with value, wattage, voltage rating options
    • 🪫 Add Capacitor - Create capacitors with value, voltage rating options
    • 💡 Add LED - Create LEDs with voltage and brightness specifications
    • 🔌 Add Diode - Create diodes with voltage and efficiency specifications
    • 🌀 Add Inductor - Create inductors with inductance value specifications
    • 🔒 Add Fuse - Create fuses with current and voltage ratings
    • 🔗 Add Connector - Create connectors with pin count and footprint options
    • 🎯 Add Testpoint - Create testpoints with custom footprint options

    Power Management

    Tools for defining and managing power in your designs:

    • 🔋 Add Power Source - Define power sources like batteries and regulators with voltage specs
    • ⚡ Add Power Input - Define power input requirements for components and modules

    PCB Layout & Routing

    Advanced PCB design tools for layout and routing:

    • 🔗 Add Via - Create vias for layer transitions with size, drill, and power specifications
    • 🛤️ Add Track - Create PCB tracks with power-aware routing and layer management

    Connections & Networking

    Tools for managing electrical connections between components:

    • 🏷️ Create Named Net - Create named connections between pins for better organization
    • 🔌 Connect Pins - Connect multiple pins together in electrical networks

    Component Management

    Advanced component creation and modification tools:

    • 🧩 Create Custom Component - Create custom components with named pins and power specs
    • ⚙️ Set Component Properties - Modify component properties like DNP, reference, value, etc.

    Design Validation

    Comprehensive design checking and validation tools:

    • ✅ Validate Design - Run comprehensive design validation including power and ERC checks
    • 🔍 Run ERC - Run Electrical Rules Check to validate pin connections and compatibility

    Installation

    Install globally via npm:

    npm install -g @typecad/typecad-mcp

    Configuration

    Add this to your MCP configuration file:

    {  "mcpServers": {
        "typecad-mcp": {
          "command": "npx",
          "args": ["-y",
            "@typecad/typecad-mcp"
          ],
          "env": {}
        }
      }
    }

    Usage

    Once configured, AI assistants can use typeCAD tools directly in conversation:

    • “Create a new typeCAD project called ‘sensor-board’”
    • “Add the ESP32-S3 microcontroller to my project”
    • “Validate this component against its datasheet”
    • “Create a package for this voltage regulator IC”
    • “Add a resistor/capacitor/inductor/diode/LED/fuse/testpoint/connector”
    • “Add a power source”

    The AI assistant will automatically call the appropriate MCP tools...

    Read more »

  • Code and KiCAD

    typecad06/06/2025 at 02:56 0 comments

    typeCAD is meant to work closely with KiCAD, essentially replacing the schematic editor. But typeCAD can do a lot more than the schematic editor, so the best way to go about things was getting a bit hazy.

    The Problem

    The vast majority of PCB design and layout can be done with typeCAD now. But there are still some things that KiCAD is better at, and the best way to sync changes between moving parts in the editor versus what’s generated by code wasn’t clear.

    The Solution

    Nearly everything can have its state saved, and typeCAD is smart enough to figure out what needs to be updated and what should be left as you manually edited it.

    Some Improvements

    Saving over KiCAD changes

    typeCAD used to check for a lock file to see if the PCB file was open in KiCAD. It worked, but it wasn’t great. Now, it does some fancy window title checking, finds the open KiCAD window, and checks for unsaved changes. The build process will stop and let you know, and let you save (or not) before proceeding. If you’re on a system that doesn’t support this (Mac?), it will just check for the lock file.

    Tracks

    Tracks can have their widths changed in KiCAD, but not deleted. typeCAD will recreate deleted tracks, so if you want to modify a track, if it it created in code, it needs to be deleted in code (delete the line).

    Preserved track changes are displayed during the build process, so you are made aware of any deviations from what the code as supposed to make.

    Components

    Components can be moved and rotated in KiCAD. typeCAD will preserve those changes. Nearly anything you can do with components in KiCAD will be preserved.

    Vias

    Vias can be created in typeCAD, so if you make any in KiCAD, the build process will let you know about them and give the coordinates so you can add them to your code.

    The End Result

    The goal is to have a smooth workflow between KiCAD and typeCAD. You should be able to make changes in either if you choose, while nudging in the direction of typeCAD for declaratively creating a PCB. Update your project to see the new features. 

  • Simplification

    typecad05/31/2025 at 05:54 0 comments

    typeCAD was growing in features at the expense of simplicity. The entire API has been simplified and the interaction between KiCAD and typeCAD has been improved while also maintaining backwards compatibility.

    Schematic and PCB

    The Schematic and PCB classes have been merged into a single PCB class. The PCB class now has a schematic property that contains the schematic data. The PCB class also has a create method that takes a list of components and adds them to the schematic and board. This change was made because the schematic and board are always created together and there was no need to have two separate classes. Also, typeCAD was the schematic, so why put any mental effort into another ‘Schematic’?

    Now the bare minimum code to create a board is:

    import { PCB } from '@typecad/typecad';
    let typecad = new PCB('typecad');
    typecad.create();

    There’s no need to think about Schematic anymore. All the functionality is still there, but it’s stubbed out in the PCB class. ::net and ::named are called from PCB now. So is ::bom and ::erc.

    KiCAD

    The interaction between typeCAD and KiCAD was getting unintuitive. Wondering if you needed to Revert to see component location changes or reimport the netlist to see other updates was confusing.

    Now, typeCAD will automatically import the netlist after running PCB::create(). That means you never have to interact with the netlist file again.

    Any changes made to the board will be reflected in their entirety when you run PCB::create() and use the Revert function (or just reopen) the board in KiCAD.

    More KiCAD integration to come

    Soon, we’ll be releasing a new version that will check for a dirty .kicad_pcb file and prompt you to revert before running PCB::create(). This will prevent any changes you’ve made in KiCAD from being lost. It will be more robust and useful that the current method which just checks for the existence of a lock file.

    Package improvement

    We’ve tweaked things to make packages easier to create and use. They are now created similarly to other components, and also used the same as well. Before, our example packages had add and place methods. Now, they have a property that holds everything in a components array. That array is passed to PCB::create() as a spread operator. The result is a much simpler and more intuitive package creation and use.

    npm update

    Update your projects and packages to the latest version to get the latest features and improvements.

  • Create tracks with typeCAD

    typecad05/25/2025 at 16:57 0 comments

    One of the last parts of board design was routing and that is largely accomplished now with the newest release.

    The TrackBuilder object lets you create tracks with a fluent API.

    import { PCB, TrackBuilder } from '@typecad/typecad';
    
    let pcb = new PCB('typecad_docs');
    
    let power_track: TrackBuilder = this.pcb.track()
        .from({x: 100, y: 100}, "F.Cu", 0.2)    // Start on F.Cu, 0.2mm wide (these are the defaults and can be omitted)
        .to({x: 110, y: 100})                   // go to 110, 100
        .via({size: 0.8, drill: 0.4})           // create a via at the 110, 100
        .to({x: 110, y: 120, layer: "B.Cu"});   // Continues on B.Cu
    
    pcb.group('typecad_docs', power_track);     // add the TrackBuilder to the group
    
    pcb.create();

    This method fits in nicely with the rest of the typeCAD API.

    Connections

    TrackBuilder objects don’t take any connection information. This is because KiCAD will connect any track that touches an element with a net, ie. a track that touches a pad connected to the ‘gnd’ net will make the entire track also connected to the ‘gnd’ net. Since there's no use of an unconnected track, this works nicely and simplifies the process.

    typecad/kicad2typecad

    @typecad/kicad2typecad is a package to simplify making tracks. This is particularly useful for making packages. You can lay out the entire package in KiCAD; components placed, tracks drawn, and vias added. Then use kicad2typecad to generate the code snippets to create them programmatically in the package.

    Making a package

    The workflow for creating a reusable package is:

    1. Create a package, add components and connections
    2. Layout the board in KiCAD using tracks and vias
    3. Use kicad2typecad to generate the code snippets
    4. Add the code snippets to the package

    An example output for a small package looks like this:

    Reading from File: .\typecad_docs.kicad_pcb
    Found 6 segments. Generating TrackBuilder chains from File: .Reading from File: .\typecad_docs.kicad_pcb.
    
    --- Generated typeCAD TrackBuilder Code from File: .\typecad_docs.kicad_pcb ---
    this.pcb.track().from({ x: 152.05, y: 96.87 }, "F.Cu", 0.2)  .to({ x: 152.4, y: 96.52, layer: "F.Cu", width: 0.2 });
    this.pcb.track().from({ x: 151.1, y: 99.665 }, "F.Cu", 0.2)  .to({ x: 151.765, y: 100.33, layer: "F.Cu", width: 0.2 })  .to({ x: 152.273, y: 99.822, layer: "F.Cu", width: 0.2 })  .to({ x: 153.67, y: 99.822, layer: "F.Cu", width: 0.2 }); this.pcb.track().from({ x: 150.6, y: 99.175 }, "F.Cu", 0.2)  .to({ x: 151.1, y: 99.175, layer: "F.Cu", width: 0.2 })  .to({ x: 151.1, y: 99.665, layer: "F.Cu", width: 0.2 });
    
    ---------------------------------------------------------
    Found 4 footprints. Generating placement code from File: .\typecad_docs.kicad_pcb.
    
    --- Generated Component Placement Code from File: .\typecad_docs.kicad_pcb ---
    this.C1.pcb = { x: 153.67, y: 99.047, rotation: -90 };
    this.C2.pcb = { x: 153.67, y: 95.986, rotation: -90 };
    this.VR1.pcb = { x: 150.6, y: 97.725, rotation: 0 };
    this.L1.pcb = { x: 147.32, y: 97.828, rotation: 90 };
    -------------------------------------------------------------
    Found 3 vias. Generating typeCAD code from File: .\typecad_docs.kicad_pcb.
    
    --- Generated typeCAD Via Code from File: .\typecad_docs.kicad_pcb ---
    this.v1 = this.pcb.via({ at: { x: 110, y: 100 }, size: 0.8, drill: 0.4 });
    this.v2 = this.pcb.via({ at: { x: 152.4, y: 96.52 }, size: 0.6, drill: 0.3 });
    this.v3 = this.pcb.via({ at: { x: 151.765, y: 100.33 }, size: 0.6, drill: 0.3 });
    -----------------------------------------------------

    Using the code

    The TrackBuilder objects can be used within a package directly. That’s why they are prefixed with this. One modification would be to place the return value of each this.pcb.track into a TrackBuilder object which can then be used to place in a package group.

    The vias can also be used directly, or you can just take their location data.

    For Component objects, the package doesn’t read your code so it doesn’t know what the variable names for your...

    Read more »

  • Automate via creation and board outlines

    typecad05/21/2025 at 23:00 0 comments

    The newest release of typeCAD included intial suport for adding vias. 

    Vias

    In the code, they are created and used the same as any other component. 

    • let via = pcb.via({ at: {x: 10, y: 10}, size: 0.6, drill: 0.3 } );
    • specify location, size and drill
    • connect to any other net with Schematic::net(via.pin(1), ...);

    Outlines

    Outlines can be created as well. 

    // create an outline x=100, y=100, width=50, height=50, with a corner fillet of 1mm
    pcb.outline(100, 100, 50, 50, 1);

    With the addition of vias and outlines, all that is left is the tracks, and an entire board could be made programmatically. 

  • Multiboards

    typecad05/17/2025 at 05:16 0 comments

    Test jig/multi-board creation

    Making a test jig is a common activity when developing a PCB. Using typeCAD, you can create a test jig and the board you’re developing in a single codebase. This is also a demonstration of how multiple PCBs can be created from code as well.

    Testing jigs

    For this example, our board and jig will be:

    1. a board with test points on the bottom
    2. another board with pogo pins that connect to the test points
    3. the boards will connect with standoffs and mounting holes

    There’s obviously a lot of options here and this is just a simple example of one way it could be done.

    Make a typeCAD project

    From a terminal, run:

    npx @typecad/create-typecad

    Call this project jig. No need to make a PlatformIO project or initialize a git repo unless you want to. No extra packages are needed either, but feel free to add them later if you want.

    Code

    Add some code which will:

    • create a board with two test points and two mounting holes
    • create a jig board with two pogo pins and two mounting holes
    • add a resistor to pretend to be testing something
    import { Schematic, PCB } from "@typecad/typecad"
    import { Resistor } from '@typecad/passives/0603';
    import { MountingHole } from '@typecad/passives/mounting_hole';
    import { Testpoint } from '@typecad/passives/testpoint';
    import { P70_5000045R } from './P70_5000045R';
    
    let typecad = new Schematic('main');
    let pcb = new PCB('main');
    let jig = new PCB('jig');
    
    let r1 = new Resistor({ value: '1kohm', pcb: {x: 166.815, y: 86.36, rotation: 0} });
    let mh1 = new MountingHole({ size: 'M2.5', pcb: {x: 152.4, y: 76.2, rotation: 0} });
    let mh2 = new MountingHole({ size: 'M2.5',  pcb: {x: 177.8, y: 101.6, rotation: 0} });
    
    let tp1 = new Testpoint({  pcb: {x: 165.1, y: 81.28, rotation: 0} });
    let tp2 = new Testpoint({  pcb: {x: 168.04, y: 93.98, rotation: 0} });
    
    typecad.create(r1, mh1, mh2, tp1, tp2);
    pcb.create(r1, mh1, mh2, tp1, tp2);
    
    let pogo1 = new P70_5000045R({  pcb: {x: 165.1, y: 81.28, rotation: 0} });
    let pogo2 = new P70_5000045R({  pcb: {x: 168.04, y: 93.98, rotation: 0} });
    
    jig.create(mh1, mh2, pogo1, pogo2);

    Code walkthrough

    import

    import { Schematic, PCB } from "@typecad/typecad"
    import { Resistor } from '@typecad/passives/0603';
    import { MountingHole } from '@typecad/passives/mounting_hole';
    import { Testpoint } from '@typecad/passives/testpoint';
    import { P70_5000045R } from './P70_5000045R';

    We import the usual classes, plus a pogo pin from a custom package (there’s a downlink link at the bottom for this whole project). MountingHoleTestpoint and Resistor are all from the @typecad/passives package which should already be installed.

    Schematic and PCB

    Now create the main schematic and two PCBs.

    let typecad = new Schematic('main');
    let pcb = new PCB('main');
    let jig = new PCB('jig');

    Here, we create the main schematic and board, and also the jig board.

    Components

    Then all the components are created. mh1mh2 are mounting holes. tp1tp2 are test points and will go on the main PCB. pogo1pogo2 are pogo pins and will go on the jig board.

    One important point to see is that the locations are being specified. This will come in handy when we reuse the mounting holes on the jig board.

    Now create the components on the main board.

    typecad.create(r1, mh1, mh2, tp1, tp2);
    pcb.create(r1, mh1, mh2, tp1, tp2);

    Jig board components

    The last thing to do will be to add the mounting holes and pogo pins to the jig board. Notice that we’ve copied the xy locations of the test points to the pogo pins. This will ensure that the pogo pins line up with the test points.

    let pogo1 = new P70_5000045R({  pcb: {x: 165.1, y: 81.28, rotation: 0} });
    let pogo2 = new P70_5000045R({  pcb: {x: 168.04, y: 93.98, rotation: 0} });
    
    jig.create(mh1, mh2, pogo1, pogo2);

    Build

    Build the code and there will be two PCB files created; main.kicad_pcb and jig.kicad_pcb. You’ll see that the...

    Read more »

  • Schematics in typeCAD

    typecad05/13/2025 at 15:31 0 comments

    Make a schematic file in typeCAD

    A schematic file isn’t needed since typeCAD code takes the place of it, but it can be useful to have one available. People will likely still want to look at a schematic rather than code.

    To provide a starting point for that, we’ve developed a package to do that.

    Read more about using it here.

  • Hardware Design with AI

    typecad05/13/2025 at 15:30 0 comments

    Hardware will eventually be designed with AI. 

    AI understands TypeScript very well and when you tell it very specifically what you want it to make, it can do it quite well. 

    To facilitate the 'telling', we've created typeCAD-prompt package. 

    typeCAD-prompt is a specialized tool designed to integrate typeCAD with AI coding models, enabling users to generate detailed prompts for transforming IC reference designs into typeCAD packages. Leverage AI capabilities, such as those provided by Gemini 2.5, to help with the hardware design process.

    Key Features

    • Automated Component Analysis: The tool identifies components from schematics and cross-references datasheets to ensure accurate selection.
    • Interactive Refinement: Users can interact with the AI to confirm component details, adjust configurations, and resolve ambiguities during the design process.

    Workflow Overview

    1. Input Preparation: Provide an IC datasheet (PDF or plaintext) and a schematic image. The tool generates a structured prompt for the AI model.
    2. Prompt Execution: Use an AI platform like Cursor to execute the prompt. The AI analyzes the schematic, references the datasheet, and creates a typeCAD package.

    Installation and Usage

    Install typeCAD-prompt globally using the following command:

    npm i -g @typecad/typecad-prompt

    Read more about using it here.

View all 16 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates