edit_directive
Add or remove SPICE directives and schematic comments in LTspice circuit files. Supports exact or regex matching for deletion.
Instructions
Add or remove a SPICE directive or .asc free-text comment. Set kind=comment for annotation text; default is a SPICE directive. Works on .cir/.net and .asc; kind=comment is .asc-only. remove matches against directives AND comments, so callers can delete either kind without knowing which it is.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to circuit file (.cir, .net, or .asc) | |
| action | Yes | Whether to add or remove the directive | |
| instruction | Yes | SPICE directive text (e.g., '.tran 10m', '.ac dec 100 1 1G'). For ``kind='comment'`` this is the comment text instead. For remove: literal exact match by default — copy the line verbatim from ``read_circuit``. Pass ``regex:<pattern>`` to use a regex (matches against directives AND comments). Raises an error when nothing matched, so a typo can't silently leave the directive in place. | |
| kind | No | ``directive`` (default) — emit a SPICE directive line. ``comment`` — emit a free-text annotation. .asc-only; the tool refuses ``kind='comment'`` on .cir/.net since plain netlists already accept ``*`` / ``;`` comments inline. | directive |
| x | No | Optional X coordinate when adding to an .asc schematic. Default: directives are auto-placed in free space near the schematic's lower-left; comments default to the sheet origin (0,0). | |
| y | No | Optional Y coordinate (see ``x``). | |
| size | No | Font size (.asc only). 1=small, 2=normal (default), 3=large. |