By caidish
Automate AI-agent driven workflows in KLayout for nanodevice chip design: detect flake boundaries from microscope images, align stacks to GDS templates, draw geometries and routes, overlay references, toggle layers, capture visuals, and export layouts via MCP server.
npx claudepluginhub caidish/klayoutclaw --plugin klayoutclawDetect individual material layers (graphite, graphene, bottom hBN, top hBN) from their optimal source images. Use when segmenting specific materials in a van der Waals heterostructure stack from microscope images.
Agent review protocol for validating committed flake polygons in KLayout. Use after the commit step to visually inspect polygons against the microscope image, verify contour quality, and decide pass/fail/retry.
Align microscope stack images to a GDS fabrication template using lithographic marker detection. Computes image→GDS transform and commits warped image + material contours to KLayout.
Register source microscope images to the full_stack coordinate system using SIFT (same-substrate) or Chamfer+DE (cross-substrate) alignment. Use when aligning bottom_part, top_part, or other source images to the full_stack reference image for van der Waals stack detection.
Orchestrate end-to-end nanodevice design from user query through optional flake detection, material analysis, device geometry creation, routing, evaluation, and save. Device-agnostic methodology -- the agent derives physics rules from device type and available materials.
Detect and map van der Waals heterostructure flake boundaries from microscope images into KLayout polygons. Split workflow with 5 sub-skills (align, detect, combine, commit, review) for agent-orchestrated stack detection. Use this skill when the user wants to detect flakes from multiple source images, align cross-substrate images, segment hBN/graphene/graphite stacks, or run the full stack detection pipeline.
Transform detection results into the common full_stack coordinate system, build unified traces.json, and draw overlay images. Use after align and detect steps are complete.
Insert detected flake polygons into KLayout as GDS geometry using the geometry skill's add_polygon.py. Use after combine completes to commit traces.json contours as polygons on the correct layers.
Toggle KLayout layer visibility on and off for better visualization. Use this skill when the user wants to show/hide layers, toggle layer display, change layer visibility, or focus on specific layers in KLayout. Also trigger when the user says things like "hide the metal layer", "show only mesa", "turn off layer 3", or wants to isolate layers for inspection.
Run agentic E2E tests for KlayoutClaw. Gives Claude Code natural-language tasks, lets it autonomously choose MCP tools, independently verifies layout state via direct MCP calls, and judges outcomes with gpt-5-mini. Use when the user wants to run agentic tests, validate KlayoutClaw, or benchmark agent performance.
Create geometry in KLayout via MCP — rectangles, polygons, paths, cells, and cell instances. Use this skill whenever the user wants to draw, add, or create shapes/geometry/structures in KLayout, even if they don't say "geometry" explicitly. Trigger on phrases like "draw a rectangle", "add a polygon", "create a cell", "place an instance", "make a shape", or any layout/chip/mask design geometry task.
Load a reference image (microscope photo, optical image, SEM) into KLayout as a background overlay for design alignment. Use this skill whenever the user wants to load an image, add a background image, overlay a microscope photo, import a reference picture, align to a photo, or trace over an image. Also trigger when the user says "load this image", "use this photo as reference", "overlay the microscope image", or needs to position/scale/remove background images.
Import a GDS file into the current KLayout layout, flatten hierarchy, and merge into a single top cell. Use this instead of raw Layout.read() which leaves orphaned cell indices and multi-top-cell states.
Route nanodevice contacts to bonding pads with multi-window EBL support. Use this skill when the user needs to place bonding pads, route leads from device contacts to pads, set up multi-window EBL routing with different line widths per window, or add boundary connection patches between EBL write fields. Also trigger for "fan out", "route to pads", "bonding pads", "EBL windows", "multi-pass lithography", "connection patches".
Use when implementing any task using Test-Reinforced Development — separates test writing (Overseer) from implementation (Executor) with anti-cheating enforcement. Invoke with /trd <task description>.
Capture the current KLayout layout as a PNG image for visual inspection. Use this skill whenever the user wants to see, view, screenshot, preview, or visually inspect the current layout. Also trigger when the user asks "what does it look like", "show me the layout", "take a screenshot", "capture the design", or needs a visual check of their GDS geometry.
Drive KLayout from any AI agent — chip & nanodevice layout over MCP.
KlayoutClaw plugs KLayout into the Model Context Protocol so Claude, Codex, Cline, or your own agent can create layouts, run pya scripts, autoroute pins, and drive full nanodevice fabrication pipelines — all in your existing KLayout GUI.
macOS only for now. Linux / Windows are on the roadmap.

git clone https://github.com/caidish/KlayoutClaw.git
cd KlayoutClaw
python install.py # copies plugin into ~/.klayout/pymacros
open /Applications/klayout.app # KLayout starts the MCP server on :8765
python tests/test_connection.py # verify
Point any MCP client at http://127.0.0.1:8765/mcp:
claude mcp add --transport http klayoutclaw http://127.0.0.1:8765/mcp
Then just ask:
"Create a Hall bar with a 100×25 µm graphene channel, 6 side probes, and bonding pads. Save as hallbar.gds."
| Layer | Purpose |
|---|---|
MCP Server (plugin/) | KLayout autorun macro. 19 JSON-RPC tools on 127.0.0.1:8765: layout I/O, execute_script, screenshot, autoroute, design evaluation, plus 9 vc_* version-control tools. Zero external deps. |
Skills (skills/) | Claude Code plugin with 9 skills — geometry, display, visual, image, GDS import, and 4 nanodevice pipelines (flakedetect, gdsalign, routing, e2e design). Loaded automatically. |
Qlaybot (agent/) | Standalone TypeScript agent (v0.4.4) built on Pi-Agent SDK. Ink/React TUI, 10 slash commands, planning sandbox, categorized memory with FTS5 + vector search, 3-phase context compaction, JSON-RPC mode. Auto-launches KLayout. |
Tools (tools/) | Subprocess helpers: GDS→PNG, routing engine (numpy/scipy/scikit-image), design evaluator (gdstk/shapely). |
Any MCP client KLayout GUI
(Claude / Codex / Qlaybot / …) + KlayoutClaw plugin
┌──────────────────┐ HTTP/JSON-RPC ┌──────────────────┐
│ │ ◄──────────────► │ pya.QTcpServer │
│ agent + skills │ :8765/mcp │ (Qt main thread)│
└──────────────────┘ └──────────────────┘
An autonomous run of the full vdW heterostructure pipeline — load a GDS template, overlay flake-detection results, generate a Hall bar, route every pin to bonding pads — from a single prompt.
https://github.com/user-attachments/assets/f51d5649-e69b-4885-b17f-f849277a05a6
Video not rendering? Uncompressed copy at docs/Demo.mp4.
cd agent
npm install && npm run build
export ANTHROPIC_API_KEY=...
npm start # interactive TUI
Qlaybot ships its own MCP client and auto-launches KLayout. First run creates ~/.qlaybot/. After npm link, the qlaybot command is available globally. See agent/README.md for the full CLI, RPC mode, subagents, and 697-test suite.
The MCP server itself uses only Python stdlib + KLayout's pya. Subprocess tools (auto_route, evaluate_design) and nanodevice skills need a scientific Python stack — we recommend a conda env named instrMCPdev:
conda create -n instrMCPdev python=3.11 -y && conda activate instrMCPdev
pip install numpy scipy scikit-image scikit-learn opencv-python-headless \
gdstk shapely matplotlib klayout==0.30.3
Pass python_path= to override the env per-call.
docs/tools.md — MCP tool reference (all 19)docs/skills.md — skill catalogdocs/ui-plugin.md — UI panel + status bardocs/plans/ — architecture design notesCONTRIBUTING.md — how to helpThe auto-routing engine borrows algorithmic techniques from Klayout-Router by Legendrexial (MIT).
MIT — see LICENSE. Questions or collaboration: caidish1234@gmail.com.
AI-powered hardware development platform — design, verify, synthesize, and deploy working RTL with natural language. 18 agents, 25 skills, 8 IP blocks.
Share bugs, ideas, or general feedback.
KiCad electronics design skills. Analyze schematics, review PCB layouts, download datasheets, source components, and prep boards for fabrication.
97-agent RTL design pipeline with 97 skills for 6-Phase hardware design automation (Research → Architecture → μArch → RTL → Verify → Design Note)
Skill for reading and parsing electronic component datasheets, extracting specifications and technical information.
Plan and design gridfinity baseplates for 3D printing with optimal grid layouts and print bed slicing
Permanent coding companion for Claude Code — survives any update. MCP-based terminal pet with ASCII art, stats, reactions, and personality.