From ltspice-mcp
Guides writing and editing LTspice netlists (.cir/.net/.sp), schematics (.asc), and interpreting simulation results. Covers SPICE syntax, behavioral sources, .MEAS directives, parameters, convergence issues, and common pitfalls.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ltspice-mcp:ltspiceThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
```spice
* Title line (first line, always a comment)
<components>
<directives>
.END
.END must be last line. No statements after it.+ at start of line continues previous statement.* (full line) or ; (inline).<ref> <node+> <node-> <value>
R1 in out 10k
C1 out 0 100n
V1 in 0 AC 1 PULSE(0 5 0 1n 1n 0.5m 1m)
| Suffix | Meaning | Value |
|---|---|---|
| f | femto | 1e-15 |
| p | pico | 1e-12 |
| n | nano | 1e-9 |
| u | micro | 1e-6 |
| m | milli | 1e-3 |
| k | kilo | 1e3 |
| MEG | mega | 1e6 |
| G | giga | 1e9 |
| T | tera | 1e12 |
M means MILLI, not mega. Use MEG for 1e6.
This is the #1 SPICE mistake. 1M = 0.001, not 1000000.
Unrecognized suffix letters are silently ignored — no error, just wrong value.
PULSE(Vinitial Vpulse Tdelay Trise Tfall Ton Tperiod Ncycles)
SINE(Voffset Vamp Freq Td Theta Phi Ncycles)
EXP(V1 V2 Td1 Tau1 Td2 Tau2)
SFFM(Voff Vamp Fcar MDI Fsig)
PWL(t1 v1 t2 v2 ...)
PWL file=<filename>
PWL extras (LTspice-specific):
PWL(0 1 +1 2 +1 3) — times become 0, 1, 2REPEAT FOR n (...) ENDREPEAT or REPEAT FOREVER (...) ENDREPEATVALUE_SCALE_FACTOR=x, TIME_SCALE_FACTOR=xTRIGGER <expression> — output stuck at first value when expression is false.tran 5m ; transient, 5ms stop
.tran 0 5m 0 10u ; tstep, tstop, tstart, tmaxstep
.tran 0 5m 0 10u startup ; LTspice-only: ramp sources from zero
.ac dec 200 10 100k ; AC sweep, 200pts/decade, 10Hz-100kHz
.dc V1 0 5 0.01 ; DC sweep V1, 0-5V, 10mV step
.op ; DC operating point
.noise V(out) V1 dec 200 10 100k ; noise analysis
.tf V(out) V1 ; DC transfer function
.include /path/to/model.lib ; include library
.ic V(node)=1.5 ; initial conditions (used with UIC)
.nodeset V(node)=1.5 ; hint for DC operating point solver
.ic forces node voltages at t=0 (use with .tran ... UIC). .nodeset is a suggestion to help the OP solver converge — the solver can override it. Mixing them up causes wrong initial states or convergence failures.
.meas TRAN vmax MAX V(out)
.meas TRAN vpp PP V(out)
.meas TRAN trise TRIG V(out) VAL=0.1 RISE=1 TARG V(out) VAL=0.9 RISE=1
.meas AC fc WHEN mag(V(out)/V(in))=0.707
.meas AC gain_1k FIND mag(V(out)) AT=1k
.meas TRAN avg_out AVG V(out) FROM=1m TO=5m
.meas TRAN energy INTEG V(out)*I(R1)
Gotchas:
TD= parameter, TARG matches from t=0 — can hit wrong edge.at field; the headline values scalar is the constant target LEVEL, not the crossing point.0 (or GND)..step param <name> <start> <stop> <increment>.step param <name> list <v1> <v2> ....param Rval=10k
.param fc={1/(2*pi*R1*C1)}
.func myfn(x) {x*2}
R1 in out {Rval}.param using other params MUST use braces: .param x={y*2}.func body uses braces: .func myfn(x) {x*2}B1 out 0 V=V(in)*{Rval}Four types:
B1 out 0 V=<expression> ; voltage source
B2 out 0 I=<expression> [Rpar=x] [Cpar=x] ; current source
B3 out 0 R=<expression> ; resistor (undocumented)
B4 out 0 P=<expression> [VprXover=x] ; power sink (undocumented)
Conditional: IF(cond, true, false) — NOT ternary ?: (that's ngspice).
B source expressions must be single-line in schematics (netlists can use + continuation).
Operator precedence:
~, ! (boolean NOT)** (exponentiation) — ^ is XOR except in Laplace expressions*, /+, -==, >=, <=, >, < (comparisons → boolean)^ (XOR), | (OR), & (AND)Boolean: >0.5 is True, ≤0.5 is False.
Math functions:
sin, cos, tan, asin, acos, atan, atan2(y,x), hypot(y,x)sinh, cosh, tanh, asinh, acosh, atanhexp, ln, log (base e), log10sqrt, pow(x,y), pwr(x,y) (sign-preserving), pwrs(x,y), squareround, int, floor, ceilmin, max, limit(x,lo,hi), uplim(x,pos,z), dnlim(x,neg,z)buf, invtable(x,x1,y1,x2,y2,...) — monotonic x requiredTime-domain functions:
ddt(x) — time derivativeidt(x[,ic[,assert]]) — integral; assert≠0 resetssdt(x) — alternate integraldelay(x,y) — delay by y secondsuramp(x) — ramp: x if x>0, else 0u(x), stp(x) — unit step (undocumented)Random: rand(x) (sharp), random(x) (smooth), white(x) (noise ±0.5)
Special variables: time, pi, boltz (1.38e-23), planck (6.63e-34), echarge (1.60e-19), kelvin (-273.15), Gmin (1e-12)
Laplace filter:
B1 out 0 V=V(in) Laplace=1/(1+s/{2*pi*fc})
In Laplace expressions, ^ means exponentiation (not XOR). Response must roll off at high frequencies.
Gotchas:
^ is XOR in normal expressions, exponentiation only in Laplace. Use ** for power.R=<expr> behavioral resistor: value must never reach zero (causes convergence failure).NoJacob flag exists but "greatly increases risk of convergence problems" — avoid.LTspice has no built-in .mc directive — use .step + mc():
.step param run 1 100 1
R1 in out {mc(10k, 0.1)} ; uniform dist, 10k +/-10%
mc(nominal, tolerance) — uniform between nom*(1-tol) and nom*(1+tol).
.options gmin=1e-10 ; min conductance on diode/transistor junctions
.options abstol=1e-10 ; absolute current tolerance (default 1e-12)
.options reltol=0.003 ; relative tolerance (never exceed 0.003)
.options cshunt=1e-15 ; capacitance from every node to ground
.options method=gear ; alternate integration method
Circuit design tips:
cshunt — may indicate unrealistic models.Hidden defaults (LTspice-specific):
Gfarad — default parallel conductance on capacitors (1e-12). Disable: .options Gfarad=0DampInductors — default parallel resistance on inductors (ON). Disable: .options DampInductors=0Gfloat — shunt conductance on floating nodes (1e-12 default)1-1n| Flag | Effect |
|---|---|
List | Dump flattened netlist to error log |
DampInductors=0|1 | Toggle parallel inductor damping |
Thev_Induc=0|1 | Toggle 1mOhm series inductor resistance |
Gfarad=<value> | Capacitor default parallel conductance |
Gfloat=<value> | Floating-node shunt conductance |
TopologyCheck=2 | Beta circuit matrix optimizations |
baudrate=<rate> | Enable eye diagram plotting |
.subckt myfilter in out params: R=10k C=100n
R1 in out {R}
C1 out 0 {C}
.ends myfilter
.include <path> — include file contents verbatim..lib <path> — same as .include in LTspice (no section argument needed)..model 3904 ako: 2N3904 — inherit and override parameters..step param STM list 3904 2222 with Q1: {STM}.Design and iterate over .cir netlists — plain text, no placement overhead, fast to edit and simulate. Only build .asc schematics after the circuit design is finalized or when the user needs a visual schematic for review. The .asc tools are for presentation, not design iteration.
.asc files are structured text representing the schematic graphically. While technically readable, hand-editing is error-prone — use the server's schematic tools (create_schematic, add_component, connect, apply_schematic_ops, ...) or LTspice's GUI. These are available in both the full and agentic profiles — geometry-aware editing (orthogonal routing, pin-collision and junction checks) that hand-writing the file can't match. Ack-only mutations (move/remove a component, set an attribute, add or remove a net label, remove a wire) are apply_schematic_ops ops rather than standalone tools, so batch them in one transaction.
Data[0:7] creates 8 nets (cosmetic — netlister flattens to individual nets).| Symbol | Pins (name: x,y) | Size (WxH) |
|---|---|---|
| nmos | D:(48,0) G:(0,80) S:(48,96) | 48x96 |
| pmos | D:(48,0) G:(0,80) S:(48,96) | 48x96 |
| voltage | +:(0,16) -:(0,96) | 64x80 |
| current | +:(0,0) -:(0,80) | 64x80 |
| res | A:(16,16) B:(16,96) | 32x80 |
| cap | A:(16,0) B:(16,64) | 32x64 |
Rotations transform pin (x,y) as: R90→(-y,x), R180→(-x,-y), R270→(y,-x), M0→(-x,y), M180→(x,-y). Use symbol_info for exact positions.
| Rotation | Gate side | D/S vertical | Typical use |
|---|---|---|---|
| R0 | Left | D top, S bottom | NMOS (drain up) |
| M0 | Right | D top, S bottom | NMOS mirrored (symmetric diff pair) |
| M180 | Left | D bottom, S top | PMOS (source to VDD at top) |
| R180 | Right | D bottom, S top | PMOS mirrored (gate faces right) |
Choose orientation based on where the gate connects:
symbol_info with the intended rotation to verify pin directions before placing.Component placement:
+ pin y-coordinate equals the VDD rail y-coordinate. Use symbol_info to compute the exact placement origin from the desired pin position (e.g., for voltage + at y=128, place origin at y=128-16=112).symbol_info to check bbox extents at the intended rotation.Wiring:
connect for L-shaped or multi-segment routes.symbol_info to check bbox extents. For PMOS M180 with bbox top at y=160, a gate bus at y=176 is INSIDE the bbox — route at y=144 (between VDD rail and bbox top) instead. Plan bus y-coordinates BEFORE placing components.connect warnings and errors: the tool refuses diagonal wires, pin collisions, and wire junction overlaps. Non-blocking warnings (long runs, bbox crossings) should still be addressed.Ground and net labels:
0) label directly at each grounded pin via an apply_schematic_ops add_net_label op. Never route wires to a distant ground flag.add_net_label op at the pin's coordinates — do not share ground flags between components.connect with net:0 when multiple ground labels exist — the tool errors on ambiguous net references. Place ground flags directly at pin coordinates with an add_net_label op (net="0", pin="M3.S") — no wire needed when the flag is on the pin.connect with net:NAME or waypoints.Sources:
+ pin is at the top (smaller y), - at bottom. For VDD sources, + connects to the supply rail, - to ground.+ (top) to - (bottom) externally. Place with + on the higher-voltage rail.Models:
NMOS_3V3 not NMOS for .model names when the symbol Value is also a MOSFET type.u with Unicode mu (µ) in saved files. Can corrupt netlists on copy/paste.startup keyword: LTspice-only in .tran. Ramps sources from zero. Not portable.SRflop, Counter, OTA): LTspice-proprietary.*!LTspice: <directive>: Treated as a directive, not a comment — despite * prefix.m=<value> works on R, Q, J in addition to documented devices.x<number> instead of m=<number> (e.g., x2).npx claudepluginhub cognitohazard/ltspice-mcp --plugin ltspice-mcpGuides LTSpice/PyLTSpice circuit simulation from netlist creation through batch simulation, trace inspection, and convergence debugging.
Guides writing and editing ngspice circuit netlists (.cir, .sp, .spice), scripting .control blocks, and interpreting simulation results. Covers ngspice-specific syntax, behavioral sources, Monte Carlo, convergence, and common pitfalls.
Automatically generates and runs SPICE testbenches for KiCad schematic subcircuits, validating filter frequencies, divider ratios, opamp gains, LC resonance, and crystal load capacitance against simulation results.