Metadata-Version: 2.5
Name: kicad-skill
Version: 0.1.1
Summary: KiCad 10 boards as code on kicad-cli, without the SWIG bindings: checks, fab and JLCPCB output, routing and guarded writes, as a CLI, an MCP server and a Claude Code skill
Project-URL: Homepage, https://github.com/bitranox/kicad-skill
Project-URL: Repository, https://github.com/bitranox/kicad-skill.git
Project-URL: Issues, https://github.com/bitranox/kicad-skill/issues
Author-email: bitranox <bitranox@gmail.com>
License: MIT
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES.md
Keywords: claude-code,eda,gerber,jlcpcb,kicad,kicad-cli,mcp,pcb,routing
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Programming Language :: Python :: Free Threading :: 2 - Beta
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: click>=8.5.1
Requires-Dist: lib-cli-exit-tools>=2.5.0
Requires-Dist: lib-layered-config>=9.0.3
Requires-Dist: lib-log-rich>=8.2.2
Requires-Dist: mcp>=2.3.0
Requires-Dist: orjson>=3.13.0; python_version < '3.14'
Requires-Dist: platformdirs>=4.12.4
Requires-Dist: pydantic>=2.14.4
Requires-Dist: python-dotenv>=1.2.4
Requires-Dist: rich-click>=1.9.9
Provides-Extra: dev
Requires-Dist: bandit>=1.9.4; extra == 'dev'
Requires-Dist: build>=1.6.1; extra == 'dev'
Requires-Dist: certifi>=2026.11.20; extra == 'dev'
Requires-Dist: click>=8.5.1; extra == 'dev'
Requires-Dist: filelock>=4.3.1; (python_version >= '3.11') and extra == 'dev'
Requires-Dist: hatchling>=1.33.0; extra == 'dev'
Requires-Dist: httpx2>=2.14.0; extra == 'dev'
Requires-Dist: hypothesis>=6.168.5; extra == 'dev'
Requires-Dist: import-linter>=2.15; extra == 'dev'
Requires-Dist: jaraco-context>=6.1.2; extra == 'dev'
Requires-Dist: pip-audit>=2.10.1; extra == 'dev'
Requires-Dist: pyright[nodejs]>=1.1.414; extra == 'dev'
Requires-Dist: pytest-cov>=7.1.0; extra == 'dev'
Requires-Dist: pytest-xdist>=3.8.0; extra == 'dev'
Requires-Dist: pytest>=9.2.0; extra == 'dev'
Requires-Dist: rtoml>=0.14.0; (python_version < '3.14') and extra == 'dev'
Requires-Dist: ruff>=0.17.6; extra == 'dev'
Requires-Dist: textual>=8.2.8; extra == 'dev'
Requires-Dist: twine>=7.0.0; extra == 'dev'
Requires-Dist: urllib3>=2.8.0; extra == 'dev'
Provides-Extra: orjson
Requires-Dist: orjson>=3.13.0; extra == 'orjson'
Description-Content-Type: text/markdown

# kicad-skill

[![CI](https://github.com/bitranox/kicad-skill/actions/workflows/default_cicd_public.yml/badge.svg)](https://github.com/bitranox/kicad-skill/actions/workflows/default_cicd_public.yml)
[![CodeQL](https://github.com/bitranox/kicad-skill/actions/workflows/codeql.yml/badge.svg)](https://github.com/bitranox/kicad-skill/actions/workflows/codeql.yml)
[![PyPI](https://img.shields.io/pypi/v/kicad-skill.svg)](https://pypi.org/project/kicad-skill/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

kicad-skill lets you design KiCad 10 boards as code: check them, export them for manufacturing,
route them, and change parts of them, without `pcbnew`. That matters because KiCad 11 removes the
`pcbnew` Python module. kicad-skill runs on KiCad's own command-line tool, `kicad-cli`, and on
plain file access.

You can use it in three ways:

- a CLI, `kicad-skill`, for shells and scripts;
- an MCP server (`kicad-skill mcp`) that gives Claude Code or any other MCP client the same
  operations as tools;
- a Claude Code skill, shipped in this repository as a plugin, that tells Claude when and how to
  use the two above.

## What it does

- KiCad runs every check itself: ERC, DRC with schematic parity, and a comparison that tells you
  whether a schematic, a board and a `.net` file connect the same pins (net names are ignored).
- For manufacturing it writes Gerbers for every copper layer, drill files with maps, the zip for
  the board house, the BOM, a schematic PDF, pick-and-place, 3D renders, and JLCPCB's assembly BOM
  and CPL.
- It routes with [KiCadRoutingTools](https://github.com/drandyhaas/KiCadRoutingTools): a whole
  board, named nets, or the nets of chosen parts. You can also delete the tracks of chosen
  nets, or re-route them with other rules after you move or turn a part. A run never rips up nets
  outside the request unless you allow it.
- It never writes a file that KiCad has open. A tracked file with uncommitted
  changes is written only with `--force`, and a `.bak` keeps the old content. Each write reports
  what it changed.
- From Python you can draw a readable schematic sheet from a netlist (`kicad_skill.schematic`),
  derive footprints from KiCad's stock library (`kicad_skill.footprint`), and run the checks and
  exports above from your own build script.

## Install

You need:

- Python 3.10 or newer and [uv](https://docs.astral.sh/uv/). The free-threaded builds (3.14t,
  3.15t) work on Linux but not on Windows: there kicad-skill cannot be installed until pywin32,
  which the `mcp` package requires on Windows, publishes free-threaded wheels.
- KiCad 10 with `kicad-cli` on `PATH`. To use a different `kicad-cli`, set
  `KICAD_CLI=/path/to/kicad-cli`.
- For routing only: git and a Rust toolchain (`cargo`, from [rustup](https://rustup.rs/)).
  `kicad-skill route setup` downloads KiCadRoutingTools at a pinned commit and compiles its Rust
  core once, which takes about a minute. Later runs reuse that build. The source, commit and local
  patches are settings, so you can build your own fork (see [CONFIG.md](CONFIG.md), section
  `[krt]`).

```bash
uv tool install kicad-skill        # or run it without installing: uvx kicad-skill --help
kicad-skill version --json         # which kicad-cli runs, and its KiCad version
```

### Claude Code

The repository is also a Claude Code plugin marketplace. In Claude Code, run:

```text
/plugin marketplace add bitranox/kicad-skill
/plugin install kicad-skill@kicad-skill
```

This installs the skill and registers the MCP server, pinned to the released version
(`uvx kicad-skill==<version> mcp`). If you only want the MCP server:

```bash
claude mcp add kicad-skill -- uvx kicad-skill mcp
```

## CLI quick start

Every command takes `--json` and prints `{ok, command, answer, data, skipped}`. The exit code is
0 for yes (clean, same, written), 1 for no (violations, differences, a refused write) and 2 when
the command could not run. `skipped` lists checks that applied but could not run. A skipped check
is not a pass.

```bash
kicad-skill erc board.kicad_sch --json
kicad-skill drc board.kicad_pcb --json
kicad-skill netlist same board.kicad_sch board.kicad_pcb --json
kicad-skill schematic check board.kicad_sch --json
kicad-skill fab export board.kicad_pcb --positions --json
kicad-skill jlc board.kicad_pcb --json
```

`kicad-skill <command> --help` lists every option.

## Move a part, then re-route only its nets

```bash
kicad-skill route setup                                         # once: build the router
kicad-skill board move board.kicad_pcb R2 --rotate 90 --json   # turn R2 about its courtyard centre
git commit -m "Turn R2" board.kicad_pcb
kicad-skill route component board.kicad_pcb R2 --reroute --track-width 0.5 --json
```

`route component ... --reroute` deletes the copper of R2's nets and routes them again at 0.5 mm.
The router leaves power nets such as GND out of a part's nets; add `--power-net 'GND=0.6'` to
re-route a matching one too, as a whole net. Nothing else changes. On a small test board the result looks like this (shortened):

```json
{
  "ok": true,
  "command": "route reroute",
  "answer": "yes",
  "data": {
    "changed_nets": [{"net": "A", "widths_after": [0.5]}, {"net": "B", "widths_after": [0.5]}],
    "unchanged_nets": 2,
    "drc": {"unconnected": 0, "errors": 0, "warnings": 0, "errors_by_type": {}}
  },
  "skipped": []
}
```

Trust `answer` and `data.drc`, not the router. KiCadRoutingTools exits 0 even when it leaves nets
unrouted, so kicad-skill runs KiCad's DRC on the result and answers `yes` only when nothing is
unconnected and there are no errors. Only such a result is written; otherwise the board stays as
it was and `data.not_written` says why (`--keep-partial` writes it anyway). Commit between steps.
Each write leaves the board with uncommitted changes, and the next write refuses such a board
unless you pass `--force`.

## MCP quick start

`kicad-skill mcp` serves these tools over stdin and stdout: `version`, `erc`, `drc`,
`netlist_same`, `schematic_check`, `netlist_export`, `bom`, `fab_export`, `jlc`, `jobset_run`,
`drc_refill`, `route_setup`, `route`, `route_undo` and `footprint_move`. Each one runs the same
operation as its CLI command and returns the same envelope. Writes go through the same guard. The
read-only tools say so in their annotations.

## Python API

```python
from pathlib import Path

from kicad_skill.check import drc
from kicad_skill.schematic import Sheet, read_netlist

report = drc(Path("board.kicad_pcb"))
sheet = Sheet(read_netlist(Path("board.net")), project="board", title="Power supply")
```

Each public module (`kicad_skill.schematic`, `kicad_skill.footprint`, `kicad_skill.check`,
`kicad_skill.fab`, `kicad_skill.guard`) opens with a runnable example in its docstring:
`python -c "import kicad_skill.footprint as m; help(m)"`.

## Documentation

- [skills/kicad-skill/SKILL.md](skills/kicad-skill/SKILL.md): the skill, and the shortest
  complete guide to the CLI, the MCP tools and the write rules.
- [skills/kicad-skill/references/](skills/kicad-skill/references/): KiCad versions and
  automation backends, schematic readability, JLCPCB rules, design review, measured gotchas.
- [CONFIG.md](CONFIG.md): configuration layers and settings. [INSTALL.md](INSTALL.md),
  [DEVELOPMENT.md](DEVELOPMENT.md), [CONTRIBUTING.md](CONTRIBUTING.md), [CHANGELOG.md](CHANGELOG.md).

## Licence

MIT, see [LICENSE](LICENSE). Parts are adapted from other open-source projects. Their notices
and licences are in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
