spice-sim — скилл для Claude Code: симуляция и установка
Создаёт и запускает тестбенчи Zener через ngspice и pcb sim. Нужен для проверки запуска, порогов защиты, ограничений тока и других схемных сценариев.
npx skills add diodeinc/pcb --skill spice-sim -a claude-codeЧто делает spice-sim
Скилл помогает добавить или запустить узкий тестбенч Zener для одного поведения схемы: запуска, сигнала разрешения, порога защиты либо ограничения тока. Он советует переиспользовать готовый тестбенч, если тот уже покрывает проверку, и запускать расчёт через pcb sim -v <file>.zen.
Для компонентов, кроме DNP, нужны SPICE-модели. Пассивы и ряд типовых деталей из stdlib имеют собственные модели, а для листового компонента требуется spice_model=SpiceModel(...) с корректным порядком nets и параметрами PARAMS: в args. Источники, анализ и команды построения графиков задаются в строке setup объекта Simulation.
pcb sim запускает ngspice в пакетном режиме и останавливает его через 5 секунд. Успешное завершение не доказывает, что измерение или график получились, поэтому нужно читать вывод с -v и брать значения из meas либо echo. Это повод проверить результаты вручную, особенно если модель PSpice или LTspice требует .spiceinit. Verilog-A и зашифрованные модели не запускаются.
Какие задачи решает
- проверить запуск схемы в тестбенче Zener
- измерить порог срабатывания защиты
- смоделировать ограничение тока
- запустить переходный, AC или шумовой анализ
- сохранить график через
hardcopy
Примеры запросов агенту
- Добавь тестбенч
<package>/testbench/test_<scenario>.zenдля проверки порога защиты. - Запусти
pcb sim -v <file>.zenи покажи значения изmeas. - Подготовь
Simulationс переходным анализом и графикомoutput/startup.svg.
Как установить spice-sim
1Через Skills CLI (Vercel)
npx skills add diodeinc/pcb --skill spice-sim -a claude-code2Вручную: положить файлы
~/.claude/skills/spice-sim/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/spice-sim/
1Через Skills CLI (Vercel)
npx skills add diodeinc/pcb --skill spice-sim -a codex2Вручную: положить файлы
.agents/skills/spice-sim/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add diodeinc/pcb --skill spice-sim -a cursor2Вручную: положить файлы
.cursor/skills/spice-sim/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install diodeinc/pcb spice-sim2Вручную: положить файлы
.github/skills/spice-sim/SKILL.md1Через Skills CLI (Vercel)
npx skills add diodeinc/pcb --skill spice-sim -a gemini-cli2Командой платформы
gemini skills install https://github.com/diodeinc/pcb --path skills/spice-simВручную: положить файлы
.devin/skills/spice-sim/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add diodeinc/pcb --skill spice-sim -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о spice-sim
Как установить spice-sim в Claude Code?
Выполните npx skills add diodeinc/pcb --skill spice-sim -a claude-code, затем повторите npx skills add diodeinc/pcb --skill spice-sim -a claude-code. Файл скилла находится по пути ~/.claude/skills/spice-sim/SKILL.md.
Что делает spice-sim?
Скилл добавляет или запускает тестбенчи Zener, использующие ngspice через pcb sim. Он описывает модели компонентов, настройку анализа и проверку результатов расчёта.
Почему успешный pcb sim не всегда означает верный результат?
pcb sim считает запуск успешным при нормальном завершении ngspice, даже когда meas не сработал, график не записался или выражение делит на ноль. Для проверки нужен вывод -v.
Исходный текст
SKILL.md · MIT
---
name: spice-sim
description: Add or run an ngspice-backed Zener testbench with `pcb sim`.
---
# Spice Simulation
Use a focused testbench such as `<package>/testbench/test_<scenario>.zen` for one behavior: startup, enable, a protection threshold, or current limit.
Reuse an existing bench when it covers the request.
Run it with `pcb sim -v <file>.zen`; a separate dummy simulation is only useful when diagnosing setup problems.
`pcb sim` runs the `ngspice` executable in batch mode in the testbench's directory and stops it after 5 seconds.
Without `-v`, a successful run prints only that it passed.
## Model and testbench
Every component that is not DNP needs a SPICE model.
The stdlib generics, such as resistors, capacitors, inductors, ferrite beads, crystals, diodes, LEDs, and TVS diodes, have their own.
A leaf component needs `spice_model=SpiceModel(...)`.
Obtain a vendor model or, when appropriate, use a behavioral model with explicit limitations.
Match `nets` to the subcircuit's declared terminal order, and pass every `PARAMS:` entry in `args`, because defaults are not applied:
```zen
Component(
name="MyPart",
symbol=Symbol(library="MyPart.kicad_sym"),
footprint=File("MyPart.kicad_mod"),
part=Part(mpn="MYPART-1", manufacturer="Vendor"),
pins={"VIN": VIN, "VOUT": VOUT, "GND": GND},
spice_model=SpiceModel(
"MyPart.lib",
"MyPart_SUBCKT",
nets=[VIN, VOUT, GND],
args={},
),
)
```
The model text goes into the netlist, so a `.include` in the model file resolves from the testbench's directory.
The `.subckt` line must list all its terminals on one line; terminals on `+` continuation lines are not counted.
For a PSpice model, put `set ngbehavior=psa` in a `.spiceinit` file beside the testbench; for an LTspice model, `set ngbehavior=ltpsa`.
Without it, PSpice expressions such as `VALUE={LIMIT(...)}` give wrong results without an error.
Verilog-A and encrypted models do not run.
Instantiate the module under test and needed loads/passives in Zener.
Put sources, waveforms, analysis, and plot commands in the raw ngspice `setup` string of a top-level `Simulation`:
```zen
load("@stdlib/properties.zen", "Simulation")
Simulation(
name="SIM",
setup="""
V_IN VIN GND DC 12
.control
tran 10u 10m
meas tran vout_final FIND v(VOUT) AT=10m
set hcopydevtype = svg
hardcopy output/startup.svg v(VIN) v(VOUT)
.endc
""",
)
```
Adapt the source and analysis to the behavior; for example, `PULSE(...)` for enable timing or `PWL(...)` for a changing input.
Operating point, DC sweep, AC, transient, and noise analyses all run.
## Results
`pcb sim` reports success whenever ngspice exits normally, including when a `meas` fails, a plot is not written, or an expression divides by zero.
Read the `-v` output: take values from `meas` or `echo` lines, because `print` tables lose their column separators.
`hardcopy` and `wrdata` write only into an existing directory, so create `testbench/output/` first.
Convert an SVG plot to PNG with `rsvg-convert` before viewing it, and inspect only the signals needed to establish the result.
A switching converter at nanosecond steps simulates only about 1 to 3 ms within the 5-second limit.
For a longer run, write the netlist with `pcb sim <file>.zen -o <file>.cir`, then run `ngspice -b <file>.cir` in the testbench's directory with a longer timeout.
Distinguish a model or simulator failure from an electrical finding, and state what the model and analysis actually verify.
© diodeinc · MIT · diodeinc/pcb