AI-powered PCB design accelerator that converts natural language requirements into SKiDL scripts, KiCad schematics, and PCB layouts using a multi-agent orchestration pipeline with validation and correction loops.
Generate, plan, and layout circuits from natural language prompts using an AI-powered multi-agent orchestration pipeline.
Circuitron is an AI-powered PCB design accelerator that converts natural language requirements into SKiDL scripts, KiCad schematics, and PCB layouts. It uses a sophisticated multi-stage agent workflow with robust nested correction loops to ensure valid, working circuit designs.
The system follows a multi-stage agent workflow with validation and correction loops:
1. **Planner** → **Plan Editor** (optional user feedback loop)
2. **Part Finder** → **Part Selector**
3. **Documentation Agent** (gathers context via RAG)
4. **Code Generator**
5. **Validation & Correction Loop**: Validator checks code → Corrector fixes issues (repeats until valid or retry limit)
6. **Runtime Check & Correction Loop**: Docker runtime check → Runtime Corrector fixes failures (repeats until successful)
7. **ERC (Electrical Rule Check) & Handling Loop**: ERC Handler runs checks → Fixes errors/warnings (repeats until passing or explicitly accepted)
8. **Final Execution**: Validated script produces KiCad files
**High-value files:**
Agents are created as pure functions in `circuitron/agents.py`, configured with prompts, models, output types, tools, and model settings:
```python
def create_planning_agent() -> Agent:
"""Create and configure the Planning Agent."""
model_settings = ModelSettings(tool_choice="required")
tools: list[Tool] = [execute_calculation]
return Agent(
name="Circuitron-Planner",
instructions=PLAN_PROMPT,
model=settings.planning_model,
output_type=PlanOutput,
tools=tools,
input_guardrails=[pcb_query_guardrail],
model_settings=model_settings,
)
```
**Notes:**
Define agent tools in `circuitron/tools.py` using the `@function_tool` decorator:
```python
@function_tool
async def search_kicad_libraries(query: str, max_results: int = 50) -> str:
"""Search KiCad libraries using skidl.search."""
# Implementation using DockerSession...
```
Or wrap existing functions:
```python
async def run_runtime_check(...) -> str:
# Implementation...
run_runtime_check_tool = function_tool(run_runtime_check)
```
All external tool execution (KiCad, calculations) occurs in isolated Docker containers:
Attach the shared MCP server for agents needing documentation/RAG or validation:
```python
def _tool_choice_for_mcp(model: str) -> str:
return "auto" if model == "o4-mini" else "required"
def create_documentation_agent() -> Agent:
model_settings = ModelSettings(
tool_choice=_tool_choice_for_mcp(settings.documentation_model)
)
return Agent(
name="Circuitron-DocSeeker",
instructions=DOC_AGENT_PROMPT,
model=settings.documentation_model,
output_type=DocumentationOutput,
mcp_servers=[mcp_manager.get_server()],
model_settings=model_settings,
)
```
**CRITICAL**: Always reference official documentation before implementing new features or changing behavior:
1. Use `context7` MCP server tools for library/framework documentation (when available locally)
2. Fallback to official online documentation when in cloud environments
3. For SKiDL: https://devbisme.github.io/skidl/
4. Verify syntax, arguments, return types, and behavior patterns from official sources
- All arguments and types listed
- Return type specified
- Concise usage example
- Unit tests with mocked LLM outputs for every Agents-SDK tool
- Edge-case tests for every tool and SKiDL helper
- Run tests after every change: `pytest -q`
- Never commit if tests fail or coverage decreases
Follow strict TDD workflow:
1. Write a failing test for any new behavior
2. Write minimal production code to pass the test
3. Refactor for clarity after passing
4. Maintain ≥90% coverage with comprehensive edge cases
Activate virtual environment in PowerShell before running commands:
```powershell
& C:/Users/shaur/circuitron/circuitron_venv/Scripts/Activate.ps1
```
**Notes:**
**Before starting any task:**
**After completing significant changes:**
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/circuitron-pcb-design-workflow/raw