TS Circuit DSL
Use this skill when the user wants to create or modify circuit definitions in TypeScript (examples/*.ts) for elec.
Goal
Produce valid, deterministic circuit specs in TS, then convert to canonical .scm and validate.
Required Flow
- •Define component templates with
defineComponent(...). - •Create circuit with
defineCircuit({ target: "pico" | ... }). - •Add instances via
addPart(...). - •Set component values via
setPartProp(...). - •Connect nets via
connect(...). - •Define bus constraints (currently
setI2c(...)for I2C). - •Export
default c.toIR(). - •Run:
- •
npm run build - •
node dist/src/cli.js ts2scm <input.ts> -o <output.scm> - •
node dist/src/cli.js fmt --check <output.scm> - •
node dist/src/cli.js lint <output.scm>
Rules
- •Keep naming stable and explicit (
U_*,R_*,C_*, net names). - •Do not mutate IR directly. Use builder APIs.
- •Keep outputs deterministic by relying on canonical generator, not manual SCM edits.
- •If lint fails, fix TS and regenerate SCM.
References
- •API examples:
references/api-patterns.md - •Authoring checklist:
references/checklist.md