Generate, plan, and layout circuits from natural language prompts using a multi-agent orchestration pipeline with SKiDL, KiCad, and Docker isolation.
Circuitron is an AI-powered PCB design accelerator that converts natural language requirements into SKiDL scripts, KiCad schematics, and PCB layouts using a multi-agent orchestration pipeline.
This skill provides guidance for developing, extending, and maintaining the Circuitron project—a sophisticated multi-stage agent workflow that automates PCB design from natural language to production-ready layouts.
The system follows a sophisticated, multi-stage agent workflow defined in `circuitron/pipeline.py`:
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**:
- The **Validator** agent checks the generated code.
- If validation fails, the **Corrector** agent attempts to fix it. This loop continues until the code is valid or a retry limit is reached.
6. **Runtime Check & Correction Loop**:
- A runtime check is performed in a Docker container.
- If it fails, the **Runtime Corrector** agent attempts a fix. This loop continues until the script runs successfully.
7. **ERC (Electrical Rule Check) & Handling Loop**:
- The **ERC Handler** agent runs ERC checks.
- If errors or unapproved warnings are found, it attempts to fix them. This loop continues until ERC passes or warnings are explicitly accepted by the agent.
8. **Final Execution**: The final, validated script is executed to produce KiCad files.
Agents are created in `circuitron/agents.py` as pure functions. They are configured with a prompt, model, output type, tools, and model settings.
**Example:**
```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:**
Agent tools are defined in `circuitron/tools.py`. Prefer the `@function_tool` decorator for new async functions.
**Example:**
```python
@function_tool
async def search_kicad_libraries(query: str, max_results: int = 50) -> str:
"""Search KiCad libraries using ``skidl.search``."""
# ... implementation using DockerSession ...
```
**Alternative (wrapping 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.
**Key Patterns:**
Attach the shared MCP server for agents that need documentation/RAG or validation tools.
**Example:**
```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,
)
```
- Functions and variables: `snake_case`
- Classes: `PascalCase`
- All arguments and their types
- Return type specification
- Concise usage example
```bash
pytest -q
```
**Refuse to commit any code if tests fail or coverage decreases.**
**Before starting any new task:**
**After completing any significant change:**
**This protocol is mandatory for all AI coding assistants and must be followed for every codebase change.**
You are the sole implementation agent for this repository:
1. **Generate all source files, config, and docs needed to meet requirements**
2. **Follow strict TDD:**
- Write a failing test (`pytest`) for any new behavior before writing production code
- Write minimal production code to pass the test
- Refactor for clarity after passing
3. **Keep coverage ≥90%**; add edge/corner-case tests for every feature
**CRITICAL: ALWAYS reference official documentation before implementing anything new or changing existing behavior.**
1. The `context7` MCP server provides documentation for any library/framework/language (if available locally)
2. If `context7` is not available, rely on official documentation on the internet
**SKiDL Documentation:**
When using any API, class, method, or tool:
1. Look up the relevant section in the official documentation
2. Verify syntax, arguments, return types, and intended behavior
3. Follow usage patterns recommended in the official examples
4. If uncertain, re-check the official docs or ask the user for clarification—never guess or hallucinate API usage
```powershell
& C:/Users/shaur/circuitron/circuitron_venv/Scripts/Activate.ps1
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/circuitron-ai-pcb-design-accelerator/raw