punkfab/circuit-skills/tree/main/claude/circuit-viewer
circuit-viewer:Claude Code mod
來自 punkfab/circuit-skills 的 Claude Code 外掛,加入即時面板來顯示帶有 DRC 標記的已佈線 KiCad PCB 專案、/board 命令,以及 open_board、check_board 與 get_netlist 工具。
關於這個 mod
Claude Code 中的電路檢視器:對話旁的面板會顯示 circuit-skills 流程建構 PCB 專案的方式,並在電路板變更時保持即時更新,同時提供模型呼叫的工具。它提供一個面板,以自身幾何資料繪製已佈線的 KiCad 電路板(正面/背面銅層、焊墊、導通孔、孔洞、外框、DRC 標記),也顯示閘門判定、佈線指標、路由器進度與快速鍵(n 下一個問題、z 縮放、s 正面/背面/雙面、c 執行閘門、r 重新載入)。它每 2 秒透過檢查電路板、規則、設計與路由器進度的檔案狀態保持即時。命令與工具包括 /board <path>、/board check、open_board、check_board、get_netlist。可透過外掛 marketplace(punkfab/circuit-skills)安裝,或載入外掛目錄;netlist 需要 Node.js 18+、KiCad 9+、Python 3 與 tscircuit。
安裝
請先查看作者 README,確認 marketplace 與外掛名稱;指令可能隨儲存庫結構而變動。
claude plugin marketplace add punkfab/circuit-skills claude plugin install circuit-viewer
原文 / README
circuit-viewer: the Claude Code mod
The circuit viewer inside Claude Code: a pane beside the conversation that shows a PCB project the way
the circuit-skills pipeline builds it, kept live while the board changes, plus tools the model calls.
It is the Claude counterpart of the Codex plugin in ../../plugin/circuit-skills,
built on the same backend (../../mcp).
What you get
- A pane with the routed KiCad board drawn from its own geometry: front and back copper, pads, vias,
holes, the outline, and every blocking DRC marker (open nets in orange with a line between the two ends,
shorts in red). In the terminal it is a colour picture made of half-block cells (any terminal); in the
desktop app and the editor, an SVG.
- The gates' verdict, routing metrics (track, vias, and how much plane/pour-net copper is travelling as
track), and the router's progress when a
route_dsn.pyrun is writing it. - Buttons (hotkeys while the pane has focus): n next issue (selects it in white and names it), z zoom to it, s front / back / both, c run the gates, r reload.
- Live: it stats the board, its rules, the design and the router's progress file every two seconds and redraws on a save (re-running the gates if they had run). A toast says so.
- The gates' verdict, routing metrics (track, vias, and how much plane/pour-net copper is travelling as
track), and the router's progress when a
/board <path>opens a project (folder,.kicad_pcbor.circuit.tsx);/board checkruns the gates;/boardreopens the pane.- Tools for the model:
open_board,check_board,get_netlist(asmcp__circuit-viewer__<name>), the same verdicts the Codex plugin and the pipeline use.
Install
Needs Node.js 18+, KiCad 9+ (kicad-cli on PATH), Python 3 (the gates), and the netlist needs tscircuit
installed in the project (npm install there). Nothing to build.
From the plugin marketplace (terminal or the desktop app's Code tab):
/plugin marketplace add punkfab/circuit-skills
/plugin install circuit-viewer@circuit-skills
In the desktop app's plugin browser, add punkfab/circuit-skills as a marketplace, then install
circuit-viewer from it. A local checkout works as a marketplace too: add its folder path instead.
Or load it straight from a checkout:
# one session
claude --plugin-dir /path/to/circuit-skills/claude/circuit-viewer
# every session: in ~/.claude/settings.json
# "env": { "CLAUDE_CODE_PLUGIN_DIRS": "/path/to/circuit-skills/claude/circuit-viewer" }
Then /board ~/my-project/pcb, or ask Claude to open a board.
The skills themselves (pcb-layout and the rest) are separate: link them into ~/.claude/skills/ as before.
How it works
The mod runs in Claude Code's plugin environment (no Node, no files of its own), so the work is done by the
viewer's CLI (../../mcp/src/cli.ts): one 31 kB bundle, embedded here as
hooks/cli-source.ts and run with node --input-type=module - with the source on stdin, so the mod needs
no install path. It carries pcb-layout's gate scripts and unpacks them to the temp folder when no checkout
is nearby.
| File | |
|---|---|
| hooks/register.tsx | the hooks: pane, /board, tools, live refresh |
| hooks/picture.ts | the board as Raster cells and as SVG, from the geometry |
| hooks/cli-source.ts | generated by mcp/build.mjs; do not edit |
| types/index.d.ts | the mod's $.state contract |
After changing anything in mcp/src, run npm run build in mcp/ to regenerate cli-source.ts
(npm test fails if it is stale). claude plugin validate claude/circuit-viewer checks the mod.