generate-circuit

generate-circuit is a command for Claude Code from circuit-synth/kicad-sch-api. It costs 45 tokens per session (4,830 once invoked), scanned A, original, MIT.

A Python-based way to generate KiCad schematics, which are diagrams showing electronic components and their connections. It includes operations for adding, viewing, changing, and removing components, wires, labels, and connection points.

In plain words
What is it for?
Use it to turn a circuit description into a KiCad schematic, place components, route wires, and create a Python script for the design.
Why use it?
It helps avoid misplaced parts and broken connections by following KiCad’s required 1.27 mm placement grid.

Command for Claude Code

Written for Claude Code: installed under .claude/.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/circuit-synth/kicad-sch-api/generate-circuit
Clone the repo
git clone --depth 1 https://github.com/circuit-synth/kicad-sch-api

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for generate-circuit

README.md
[![agentmods](https://agentmods.dev/badge/commands/circuit-synth/kicad-sch-api/generate-circuit.svg)](https://agentmods.dev/commands/circuit-synth/kicad-sch-api/generate-circuit)
Your own site
<a href="https://agentmods.dev/commands/circuit-synth/kicad-sch-api/generate-circuit"><img src="https://agentmods.dev/badge/commands/circuit-synth/kicad-sch-api/generate-circuit.svg" alt="Measured on agentmods" height="20"></a>
Per session 45 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,830 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00045 $0.04830
Opus 5 $0.00023 $0.02415
Sonnet 5 $0.00009 $0.00966
Haiku 4.5 $0.00005 $0.00483

Measured 6d ago against content hash ba68ec78ab6d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

generate-circuit scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/user/generate-circuit.md · 550 lines

How it starts

The opening of the file, as written. The whole thing — 550 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Generate Professional KiCAD Circuit Schematic

You are generating a professional KiCAD schematic using kicad-sch-api with expert-level component placement and routing.

User's Circuit Request

Description: {{arg}}

Your task is to generate a complete, professional Python script that creates this circuit schematically.


⚠️ ULTRA CRITICAL: GRID ALIGNMENT (1.27mm) ⚠️

🔴 THE MOST CRITICAL RULE: ALL POSITIONS MUST BE ON 1.27mm GRID! 🔴

KiCAD uses a 1.27mm (50 mil) grid for schematic components and wires.

EVERY position MUST be a multiple of 1.27mm:

  • ✅ Valid: 0, 1.27, 2.54, 3.81, 5.08, 6.35, 7.62, 8.89, 10.16, 11.43, 12.70...
  • ✅ Valid: 100.33, 101.60, 102.87, 104.14, 105.41, 106.68, 107.95...
  • ❌ Invalid: 100.5, 115.3, 129.540, 184.150 (OFF GRID!)

Why this matters:

  • Off-grid components cause crooked wires
  • Off-grid wires cause connectivity issues
  • Off-grid placement looks unprofessional
  • Can cause ERC (Electrical Rule Check) failures

How to ensure grid alignment:

def snap_to_grid(value, grid=1.27):
    """Snap a value to nearest grid point."""
    return round(value / grid) * grid

# Use for ALL positions
signal_y = snap_to_grid(130.0)  # Ensures exactly on grid
r1_x = snap_to_grid(180.0)
vout_x = snap_to_grid(200.0)

# Verify grid alignment
assert signal_y % 1.27 < 0.01, f"Y position {signal_y} not on 1.27mm grid!"

Pin positions and grid:

  • Component centers MUST be on grid
  • Pin offsets from component center may cause pins to be off-grid
  • Use actual pin positions from list_component_pins() for wire endpoints (already on correct positions)
  • Never manually calculate pin positions - always query them!

⚠️ CRITICAL: KiCAD Y-Axis Is INVERTED ⚠️

THE SECOND MOST IMPORTANT THING TO UNDERSTAND:

In KiCAD schematics, the Y-axis is INVERTED compared to normal math coordinates:

  • LOWER Y values = HIGHER on screen (TOP of schematic)
  • HIGHER Y values = LOWER on screen (BOTTOM of schematic)
  • X-axis is normal (increases to the right)

Read the full file on GitHub · 550 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 550 lines · 45 tokens per session scan A ba68ec78ab6d

Subscribe to this mod's changes

generate-circuit is a command published in the GitHub repository circuit-synth/kicad-sch-api (52 stars, last pushed 9mo ago), licensed MIT. It adds 45 tokens to every session and 4,830 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.