Python-based circuit design with KiCad integration and AI acceleration.
Generate professional KiCad projects from Python code with hierarchical design, version control, and automated documentation.
# Install with uv (recommended)
uv add circuit-synth
# Or with pip
pip install circuit-synth
By default, circuit-synth runs with minimal logging output (WARNING level). To enable detailed logs for debugging:
# Enable verbose logging via environment variable
export CIRCUIT_SYNTH_LOG_LEVEL=INFO
# Or set it in your Python script
import os
os.environ['CIRCUIT_SYNTH_LOG_LEVEL'] = 'INFO'
Available log levels:
ERROR
: Only show errorsWARNING
: Show warnings and errors (default)INFO
: Show informational messages, progress updatesDEBUG
: Show detailed debugging information
# Create new project with example circuit
uv run cs-new-project
# This generates a complete ESP32-C6 development board
cd circuit-synth && uv run python example_project/circuit-synth/main.py
from circuit_synth import *
@circuit(name="Power_Supply")
def power_supply(vbus_in, vcc_3v3_out, gnd):
"""5V to 3.3V power regulation subcircuit"""
# Components with KiCad integration
regulator = Component(
symbol="Regulator_Linear:AMS1117-3.3",
ref="U",
footprint="Package_TO_SOT_SMD:SOT-223-3_TabPin2"
)
# Input/output capacitors
cap_in = Component(symbol="Device:C", ref="C", value="10uF",
footprint="Capacitor_SMD:C_0805_2012Metric")
cap_out = Component(symbol="Device:C", ref="C", value="22uF",
footprint="Capacitor_SMD:C_0805_2012Metric")
# Explicit connections
regulator["VI"] += vbus_in # Input pin
regulator["VO"] += vcc_3v3_out # Output pin
regulator["GND"] += gnd
cap_in[1] += vbus_in
cap_in[2] += gnd
cap_out[1] += vcc_3v3_out
cap_out[2] += gnd
@circuit(name="Main_Circuit")
def main_circuit():
"""Complete circuit with hierarchical design"""
# Create shared nets
vbus = Net('VBUS')
vcc_3v3 = Net('VCC_3V3')
gnd = Net('GND')
# Use the power supply subcircuit
power_circuit = power_supply(vbus, vcc_3v3, gnd)
# Generate KiCad project
if __name__ == "__main__":
circuit = main_circuit()
circuit.generate_kicad_project("my_board")
- Professional KiCad Output: Generate .kicad_pro, .kicad_sch, .kicad_pcb files with modern kicad-sch-api integration
- Hierarchical Design: Modular subcircuits like software modules
- Atomic KiCad Operations: Add/remove individual components from existing schematics with rollback safety
- Modern KiCad Integration: Uses PyPI kicad-sch-api (v0.1.1+) for professional schematic generation
- Component Intelligence: JLCPCB & DigiKey integration, symbol/footprint verification
- Fast JLCPCB Search: Direct search with 80% speed improvement, 90% less tokens
- AI Integration: Claude Code agents for automated design assistance
- Circuit Debugging: AI-powered PCB troubleshooting with systematic fault-finding
- FMEA Analysis: Comprehensive reliability analysis with physics-based failure models
- Test Generation: Automated test plans for validation
- Version Control: Git-friendly text-based circuit definitions
Circuit-synth integrates with the modern kicad-sch-api PyPI package - a valuable standalone tool that was extracted from circuit-synth for broader community use.
- Professional KiCad Files: Generates industry-standard .kicad_sch files with proper formatting
- Symbol Library Integration: Full access to KiCad's extensive symbol libraries
- Hierarchical Support: Clean handling of complex multi-sheet designs
- Version Compatibility: Works with modern KiCad versions (v7.0+)
Circuit-synth uses a hybrid approach combining the best of both worlds:
- Legacy System: Handles component positioning and hierarchical structure
- Modern API: Professional schematic file writing via kicad-sch-api
- Intelligent Selection: Automatically chooses the right approach per schematic type
# The modern API integration is automatic - just use circuit-synth as normal!
@circuit(name="MyCircuit")
def my_design():
# Your circuit design here
pass
# Behind the scenes: circuit-synth + kicad-sch-api = professional results
The kicad-sch-api package is also valuable as a standalone tool for Python KiCad integration:
pip install kicad-sch-api
Visit the kicad-sch-api repository for standalone usage examples.
# AI agent commands (with Claude Code)
/find-symbol STM32 # Search KiCad symbols
/find-footprint LQFP64 # Find footprints
/generate-validated-circuit "ESP32 IoT sensor" mcu
# Circuit debugging commands (NEW!)
/debug-start "Board not powering on" --board="my_board"
/debug-measure "VCC: 3.3V, GND: 0V"
/debug-analyze # Get AI analysis
/debug-suggest # Next troubleshooting steps
Circuit-synth includes specialized AI agents for different aspects of circuit design. Each agent has deep expertise in their domain:
- Use for: Complex multi-component designs, system-level architecture
- Expertise: Circuit topology planning, component selection, design trade-offs
- Example: "Design a complete IoT sensor node with power management, wireless connectivity, and sensor interfaces"
- Use for: Converting natural language to working Python circuit code
- Expertise: circuit-synth syntax, KiCad integration, hierarchical design patterns
- Example: "Generate Python code for a USB-C PD trigger circuit with 20V output"
- Use for: Circuit analysis, performance optimization, validation
- Expertise: SPICE simulation setup, component modeling, performance analysis
- Example: "Simulate this amplifier circuit and optimize for 40dB gain with <100mW power"
- Use for: Hardware debugging, fault-finding, troubleshooting non-working boards
- Expertise: Systematic debugging, test equipment usage, failure pattern recognition
- Example: "My board isn't powering on - help me debug the issue step by step"
- Use for: Component selection across all suppliers, price comparison, availability checking
- Expertise: JLCPCB, DigiKey, and future suppliers (Mouser, LCSC, etc.)
- Example: "Find 0.1uF 0603 capacitors across all suppliers with pricing comparison"
- Use for: Real-time component availability, pricing, and alternatives
- Expertise: JLCPCB catalog search, stock levels, KiCad symbol verification
- Example: "Find STM32 with 3 SPIs available on JLCPCB under $5"
- Use for: Open-ended research, codebase analysis, complex searches
- Expertise: Technical research, documentation analysis, multi-step problem solving
- Example: "Research best practices for EMI reduction in switching power supplies"
- Use for: Creating comprehensive test procedures for circuit validation
- Expertise: Functional, performance, safety, and manufacturing test plans
- Example: "Generate test plan for ESP32 dev board with power measurements"
- Use for: Reliability analysis, risk assessment, failure prediction
- Expertise: Component failure modes, physics of failure, IPC Class 3 compliance
- Example: "Analyze my circuit for potential failure modes and generate FMEA report"
# Start with circuit-architect for complex projects
"Design an ESP32-based environmental monitoring station"
# Use circuit-synth for code generation
"Generate circuit-synth code for the power supply section"
# Validate with simulation-expert
"Simulate this buck converter and verify 3.3V output ripple"
# Optimize with component-search
"Replace expensive components with JLCPCB alternatives"
Pro Tip: Let the circuit-architect coordinate complex projects - it will automatically delegate to other specialists as needed!
- Circuit Design: circuit-architect, circuit-synth, simulation-expert, test-plan-creator
- Development: circuit_generation_agent, contributor, first_setup_agent
- Manufacturing: component-search, jlc-parts-finder, stm32-mcu-finder
- Circuit Design: analyze-design, find-footprint, find-symbol, validate-existing-circuit
- Development: dev-run-tests, dev-update-and-commit, dev-review-branch
- Manufacturing: find-parts, find-mcu, find_stm32
- Library Setup: cs-library-setup, cs-setup-snapeda-api, cs-setup-digikey-api
- Test Planning: create-test-plan, generate-manufacturing-tests
- Setup: setup-kicad-plugins, setup_circuit_synth
cs-new-project # Complete project setup with ESP32-C6 example
cd circuit-synth && uv run python example_project/circuit-synth/main.py # Generate KiCad files from Python code
Available when working with Claude Code in a circuit-synth project:
# Component Search (with API fallback)
/find-symbol STM32 # Local β DigiKey GitHub β SnapEDA/DigiKey APIs
/find-footprint LQFP64 # Multi-source component search
/find-stm32 "3 SPIs, USB" # STM32 with specific peripherals
# Circuit generation
/generate-validated-circuit "ESP32 IoT sensor" mcu
/validate-existing-circuit # Validate current circuit code
# Component Intelligence
/find-parts "0.1uF 0603 X7R capacitor" # Search all suppliers
/find-parts "STM32F407" --source jlcpcb # JLCPCB only
/find-parts "LM358" --compare # Compare across suppliers
/find-stm32 "3 SPIs, USB, available JLCPCB" # STM32-specific search
# Fast JLCPCB CLI (no agents, 80% faster)
jlc-fast search STM32G4 # Direct search
jlc-fast cheapest "10uF 0805" # Find cheapest option
jlc-fast most-available LM358 # Find highest stock
# FMEA analysis
/analyze-fmea my_circuit.py # Run FMEA analysis on circuit
When working with Claude Code, these agents provide domain expertise:
- circuit-architect: Overall circuit design and system architecture
- circuit-synth: Python code generation for circuits
- simulation-expert: SPICE simulation and validation
- component-guru: Component selection and JLCPCB sourcing
- jlc-parts-finder: Real-time JLCPCB availability checking
- stm32-mcu-finder: STM32 peripheral search and selection
- test-plan-creator: Automated test plan generation
- fmea-analyzer: Reliability analysis and failure prediction
Circuit-synth provides atomic operations for surgical modifications to existing KiCad schematics, enabling incremental updates without regenerating entire projects:
from circuit_synth.kicad.atomic_integration import AtomicKiCadIntegration, migrate_circuit_to_atomic
# Initialize atomic integration for a KiCad project
atomic = AtomicKiCadIntegration("/path/to/project")
# Add components using atomic operations
atomic.add_component_atomic("main", {
'symbol': 'Device:R',
'ref': 'R1',
'value': '10k',
'footprint': 'Resistor_SMD:R_0603_1608Metric',
'position': (100, 80)
})
# Remove components
atomic.remove_component_atomic("main", "R1")
# Fix hierarchical main schematics with sheet references
subcircuits = [
{"name": "USB_Port", "filename": "USB_Port.kicad_sch", "position": (35, 35), "size": (43, 25)},
{"name": "Power_Supply", "filename": "Power_Supply.kicad_sch", "position": (95, 35), "size": (44, 20)}
]
atomic.fix_hierarchical_main_schematic(subcircuits)
# Migrate JSON netlist to KiCad using atomic operations
migrate_circuit_to_atomic("circuit.json", "output_project/")
- True Atomic Operations: Add/remove individual components with rollback safety
- Hierarchical Sheet Management: Fixes blank main schematics automatically
- Production Integration: Seamless integration with existing circuit-synth pipeline
- S-Expression Safety: Proper parsing with backup/restore on failure
- JSON Pipeline Integration: Full compatibility with circuit-synth JSON format
- Incremental Updates: Add components to existing designs without full regeneration
- Debug and Fix: Resolve blank schematic issues (like ESP32-C6 project)
- External Integration: Third-party tools can manipulate circuit-synth schematics
- Advanced Workflows: Power users building custom automation
Circuit-synth includes comprehensive failure analysis capabilities to ensure your designs are reliable:
from circuit_synth.quality_assurance import EnhancedFMEAAnalyzer
from circuit_synth.quality_assurance import ComprehensiveFMEAReportGenerator
# Analyze your circuit for failures
analyzer = EnhancedFMEAAnalyzer()
circuit_context = {
'environment': 'industrial', # Set operating environment
'safety_critical': True, # Affects severity ratings
'production_volume': 'high' # Influences detection ratings
}
# Generate comprehensive PDF report (50+ pages)
generator = ComprehensiveFMEAReportGenerator("My Project")
report_path = generator.generate_comprehensive_report(
analysis_results,
output_path="FMEA_Report.pdf"
)
- 300+ Failure Modes: Component failures, solder joints, environmental stress
- Physics-Based Models: Arrhenius, Coffin-Manson, Black's equation
- IPC Class 3 Compliance: High-reliability assembly standards
- Risk Assessment: RPN (Risk Priority Number) calculations
- Mitigation Strategies: Specific recommendations for each failure mode
# Quick FMEA analysis
uv run python -m circuit_synth.tools.quality_assurance.fmea_cli my_circuit.py
# Specify output file
uv run python -m circuit_synth.tools.quality_assurance.fmea_cli my_circuit.py -o FMEA_Report.pdf
# Analyze with custom threshold
uv run python -m circuit_synth.tools.quality_assurance.fmea_cli my_circuit.py --threshold 150
See FMEA Guide for detailed documentation.
Hybrid component discovery across multiple sources with automatic fallback:
cs-library-setup # Show configuration status
cs-setup-snapeda-api YOUR_KEY # Optional: SnapEDA API access
cs-setup-digikey-api KEY CLIENT_ID # Optional: DigiKey API access
Enhanced /find-symbol
and /find-footprint
commands automatically search:
- Local KiCad (user installation)
- DigiKey GitHub (150 curated libraries, auto-converted)
- SnapEDA API (millions of components)
- DigiKey API (supplier validation)
Results show source tags: [Local]
, [DigiKey GitHub]
, [SnapEDA]
, [DigiKey API]
The optimized search API provides direct JLCPCB component lookup without agent overhead:
from circuit_synth.manufacturing.jlcpcb import fast_jlc_search, find_cheapest_jlc
# Fast search with filtering
results = fast_jlc_search("STM32G4", min_stock=100, max_results=5)
for r in results:
print(f"{r.part_number}: {r.description} (${r.price}, stock: {r.stock})")
# Find cheapest option
cheapest = find_cheapest_jlc("0.1uF 0603", min_stock=1000)
print(f"Cheapest: {cheapest.part_number} at ${cheapest.price}")
# Search components
jlc-fast search "USB-C connector" --min-stock 500
# Find cheapest with stock
jlc-fast cheapest "10k resistor" --min-stock 10000
# Performance benchmark
jlc-fast benchmark
- 80% faster: ~0.5s vs ~30s with agent-based search
- 90% less tokens: 0 LLM tokens vs ~500 per search
- Intelligent caching: Avoid repeated API calls
- Batch operations: Search multiple components efficiently
my_circuit_project/
βββ example_project/
β βββ circuit-synth/
β β βββ main.py # ESP32-C6 dev board (hierarchical)
β β βββ power_supply.py # 5Vβ3.3V regulation
β β βββ usb.py # USB-C with CC resistors
β β βββ esp32c6.py # ESP32-C6 microcontroller
β β βββ led_blinker.py # Status LED control
β βββ ESP32_C6_Dev_Board/ # Generated KiCad files
β βββ ESP32_C6_Dev_Board.kicad_pro
β βββ ESP32_C6_Dev_Board.kicad_sch
β βββ ESP32_C6_Dev_Board.kicad_pcb
β βββ ESP32_C6_Dev_Board.net
βββ README.md # Project guide
βββ CLAUDE.md # AI assistant instructions
βββ pyproject.toml # Project dependencies
Traditional EE Workflow | With Circuit-Synth |
---|---|
Manual component placement | python example_project/circuit-synth/main.py β Complete project |
Hunt through symbol libraries | Verified components with JLCPCB & DigiKey availability |
Visual net verification | Explicit Python connections |
GUI-based editing | Version-controlled Python files |
Copy-paste patterns | Reusable circuit functions |
Manual FMEA documentation | Automated 50+ page reliability analysis |
# Clone and install
git clone https://github.com/circuit-synth/circuit-synth.git
cd circuit-synth
uv sync
# Run tests
uv run pytest
# Optional: Register Claude Code agents
uv run register-agents
For 6x performance improvement:
# Build modules
# Test integration
# Run comprehensive tests
./tools/testing/run_full_regression_tests.py
# Python tests only
uv run pytest --cov=circuit_synth
# Pre-release regression test
./tools/testing/run_full_regression_tests.py
# Code quality
black src/ && isort src/ && flake8 src/ && mypy src/
KiCad 8.0+ required:
# macOS
brew install kicad
# Linux
sudo apt install kicad
# Windows
# Download from kicad.org
Install the AI-powered KiCad plugin for direct Claude Code integration:
# Install KiCad plugins
uv run cs-setup-kicad-plugins
Usage:
- PCB Editor: Tools β External Plugins β "Circuit-Synth AI"
- Schematic Editor: Tools β Generate BOM β "Circuit-Synth AI"
# Optional performance settings
export CIRCUIT_SYNTH_PARALLEL_PROCESSING=true
# KiCad path override (if needed)
export KICAD_SYMBOL_DIR="/custom/path/to/symbols"
export KICAD_FOOTPRINT_DIR="/custom/path/to/footprints"
# JLCPCB API configuration (optional)
export JLCPCB_API_KEY="your_api_key"
export JLCPCB_CACHE_DURATION=3600 # Cache for 1 hour
# DigiKey API configuration (optional, for component search)
export DIGIKEY_CLIENT_ID="your_client_id"
export DIGIKEY_CLIENT_SECRET="your_client_secret"
# Or run: python -m circuit_synth.manufacturing.digikey.config_manager
circuit-synth provides integrated access to multiple component distributors for real-time availability, pricing, and specifications.
Search across all suppliers with one interface:
from circuit_synth.manufacturing import find_parts
# Search all suppliers
results = find_parts("0.1uF 0603 X7R", sources="all")
# Search specific supplier
jlc_results = find_parts("STM32F407", sources="jlcpcb")
dk_results = find_parts("LM358", sources="digikey")
# Compare across suppliers
comparison = find_parts("3.3V regulator", sources="all", compare=True)
print(comparison) # Shows price/availability comparison table
# Filter by requirements
high_stock = find_parts("10k resistor", min_stock=10000, max_price=0.10)
Best for PCB assembly and production:
from circuit_synth.manufacturing.jlcpcb import search_jlc_components_web
# Find components available for assembly
results = search_jlc_components_web("STM32F407", max_results=10)
Best for prototyping and wide selection:
from circuit_synth.manufacturing.digikey import search_digikey_components
# Search DigiKey's 8M+ component catalog
results = search_digikey_components("0.1uF 0603 X7R", max_results=10)
# Get detailed pricing and alternatives
from circuit_synth.manufacturing.digikey import DigiKeyComponentSearch
searcher = DigiKeyComponentSearch()
component = searcher.get_component_details("399-1096-1-ND")
alternatives = searcher.find_alternatives(component, max_results=5)
# Interactive configuration
python -m circuit_synth.manufacturing.digikey.config_manager
# Test connection
python -m circuit_synth.manufacturing.digikey.test_connection
See docs/DIGIKEY_SETUP.md for detailed setup instructions.
- Prototyping: Use DigiKey for fast delivery and no minimums
- Small Batch: Compare JLCPCB vs DigiKey for best value
- Production: Optimize with JLCPCB for integrated assembly
- Risk Mitigation: Maintain alternatives from multiple sources
KiCad Symbol/Footprint Not Found:
# Verify KiCad installation
kicad-cli version
# Search for components (with Claude Code)
/find-symbol STM32
/find-footprint LQFP64
Build Issues:
# Clean rebuild
See CONTRIBUTING.md for development setup and guidelines.
- Frontend: Python 3.9+ with type hints
- KiCad Integration: Direct file format support (.kicad_pro, .kicad_sch, .kicad_pcb)
- AI Integration: Claude Code agents with specialized circuit design expertise
circuit-synth/
βββ src/circuit_synth/ # Python package
β βββ core/ # Core circuit representation
β βββ kicad/ # KiCad file I/O
β βββ component_info/ # Component databases
β βββ manufacturing/ # JLCPCB, DigiKey, etc.
β βββ simulation/ # SPICE integration
βββ example_project/ # Complete usage example
βββ tests/ # Test suites
βββ tools/ # Development and build tools (organized by category)
- Fork repository and create feature branch
- Follow coding standards (black, isort, mypy)
- Add tests for new functionality
- Update documentation as needed
- Submit pull request with clear description
- Python: Type hints, dataclasses, SOLID principles
- Documentation: Clear docstrings and inline comments
- Testing: Comprehensive test coverage for new features
See CONTRIBUTING.md for detailed guidelines.
Professional PCB Design with Python