Tutorials
Where you learn klink, and where the runnable demos live. Start with the chat walkthroughs to feel how the agent turns a sentence into a layout, then follow the step-by-step tutorials by area; each runnable starter card gives the run command and measured numbers, so you can just type it and go.
python … command are wheel-packaged runnable starters (klink init scaffolds them into your project); running a demo needs no MCP — it's an ordinary script talking to KLayout over the plugin port. Use an empty or test session, not your hand-built working tab.Chat walkthroughs real conversation
Not step-by-step instructions but real conversation logs: a user asks for something in plain language, and klink's AI agent genuinely calls tools in a live KLayout to draw the layout / run DRC / run LVS. For the full follow-along version, see the illustrated tutorials below.
Draw a Hall bar from one sentence
"Draw a Hall bar with a bar body and 3 contacts on each side" → the agent really draws the mesa, contacts, probe pads and calls the router.
Read the conversation → chat · DRCRun DRC, catch a violation, fix it
"Draw two traces too close together" → DRC catches 1 spacing violation → move one away → rerun, 0 violations. Real DRC counts.
Read the conversation → chat · LVSCustom device all the way to LVS match
"Fit a device → place & route from a netlist → run LVS" → 173 devices, routed 94/94, real LVS match=True.
Mark ports → route → drag-to-reroute
"Convert hand-drawn triangles to ports → route to an MMI → move it and reroute" → 0.8 µm ports from triangles, a 40 µm straight route, then a 60 µm S-bend after the drag.
Read the conversation →Nanodevice nanodevice
EBL and probe-device generation: writefield planning, batch RPCs, and the full Port + Anchor to routing on-ramp.
Hall bar device
The full geometry-first loop: draw the mesa/contacts/pads, mark Port + Anchor intent, route the fanout with one call, verify with the routing report.
python example_template/nanodevice/hallbar.py
semantic bundle + routed (--live writes to KLayout)
EBL wraparound nanodevice
Hand-drawn routing under writefield constraints: keepout boundaries, pre-planned crossing windows (corridor Anchors), stitch-patch compensation, and marking Port/Anchor after the fact.
python example_template/nanodevice/ebl_wraparound.py
40 electrodes · 12 patches · 0 violations · 0 overlaps
Read the tutorial → Batch RPC · parametric live KLayoutNeural electrode array harness
Parametrized by --elec-rows; 394 objects written with batched shape.insert_many. An ~8x scale gap between bond pads and electrodes, closed with a corridor Anchor before routing all nets in one pass.
python example_template/nanodevice/neural_electrode.py --port <port> --elec-rows 4
48 ports · 24 nets routed · overlap 0 · hit 0
Read the tutorial →Photonics photonics
gdsfactory bridge: three ways to get ports, and taking over an ordinary gdsfactory script into the drag-and-reroute loop.
Three ways to get ports + drag-to-reroute
A conversation through three ways to get a Port: hand-drawn triangle conversion (with a "base drawn wrong" cautionary example), standard gdsfactory auto-ports, and PDK blackbox stub-convention harvest; then the SEND → route → move → reroute loop. Every step shows the agent's words + the tool call + the result.
python example_template/photonics/gf_ports.py --port <port>
All five scenarios in one run · --reroute after a drag reconnects without rebuilding
gdsfactory MZI takeover and drag-to-reroute
One import_gf_component call takes over an ordinary gdsfactory thermo-optic MZI script; after dragging any component in the GUI, the same photonics.reroute call only re-routes — it never rebuilds a device.
python example_template/photonics/gf_mzi_module.py --port <port>
6 optical nets · reroute 12 routes · 0 crossings
Read the tutorial →Passives passives
Four families of parametric geometry templates, runnable offline, --live pushes to KLayout.
PnR · place & route any device digital/
Place, route and live-LVS any custom device from a netlist — device-agnostic place & route, not "digital logic". This group each needs a live KLayout session.
Custom device: fit → PCell → P&R → LVS
Fit a parametric edge model from a few exemplar drawings at different sizes, register a real PCell, place 173 instances from a netlist, run FlexDR detailed routing, finish with live LVS match=True.
python example_template/digital/fit_device_pnr_lvs.py --port <port>
routed 94/94 · LVS match=True · 173 devices
Read the tutorial → structdevice · padframe Needs a live KLayout sessionA probe-card-first padframe
The probe card / pad ring exists first and the circuit must meet it: harvest the ring, assign net→pad, place half-in/half-out, split the power grid by region — both the card and --no-card bare-stub modes pass live LVS match=True.
python example_template/digital/padframe_pnr_lvs.py --port <port>
routed 94/94 · LVS match=True · 16 pads connected
Read the tutorial →Multilayer place & route at scale
A 766-device synthetic netlist (toy 4-bit ALU, 268 gates); a built-in layer-count advisor compares core-area cost on a 3-layer vs a custom 7-layer stack, then a multilayer routing engine wires it. Copy the file, edit PUBLIC_MULTILAYER for your own stack.
python example_template/digital/multilayer_pnr_lvs.py --port <port>
routed 405/405 · LVS match=True · 766 devices · ~17s (run the command; no separate step-by-step page)
Hand-written netlist → lint → P&R → LVS
A 3-stage ring oscillator hand-written as a netlist, first lint_netlist (fix-it hints before any geometry exists), then place / route / LVS. A netlist is pure data — any topology, no logic synthesizer needed.
python example_template/digital/chat_to_netlist_pnr.py --port <port>
lint 0 err · routed 3/3 · LVS match=True (run the command; no separate step-by-step page)
Imaging imaging
Five kinds of picture from one GDS: cross-section, per-step process film, a self-contained 3D web viewer, an SEM-style top view, and paper-grade Blender renders -- all driven by one VisualStack declaration plus one .pyxs recipe, fully runnable offline.
Control plane · collaboration control plane
Not a kind of device but the control plane itself: one agent driving several KLayout windows at once, humans and the agent collaborating through the toolbar.
Guides guides
Standalone, complete guides not tied to one demo: verification and 3D visualization.
DRC · LVS
From first deck to production runset: a DRC-language crash course, a same-source starter deck, KLayout's native LVS pipeline end to end.
Read the guide → Guide · 2.5d View2.5D View
Your layer stack in 3D from one process declaration: a single call drives KLayout's native 2.5d viewer.
Read the guide →