caidish/klayoutclaw/klayout-gds-import

Claude Code and agent skill by caidish/klayoutclaw

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

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.

Install

npx vskill@latest install caidish/klayoutclaw/klayout-gds-import

SKILL.md

klayout_gds_import — Safe GDS Import

Import a GDS file into the running KLayout session in a way that avoids the well-known Layout.read() pitfalls documented in CLAUDE.md:

  • Cell-name collisions between the destination layout and the imported GDS

produce orphaned cell index slots (cells() reports N but cell(N-1) is invalid).

  • After a name collision, CellView.cell may point at a destroyed cell,

causing downstream crashes.

  • Multi-top-cell states are confusing for downstream routing / evaluation

tools that assume a single top cell.

This skill provides a single-shot importer that:

  1. Reads the GDS into the current layout (or a fresh tab),
  2. Flattens hierarchy so there are no subcells left,
  3. Collapses any residual multi-top-cell state into a single top cell,
  4. Rebinds CellView.cell to the resolved top, zooms to fit, and refreshes

the layer panel.

Parameters

ParameterTypeDefaultDescription
filepathstring—Required. Absolute path to a .gds file on disk.
flattenbooltrueIf true, flatten all subcells into the top cell after reading (cell.flatten(-1, True)).
merge_into_currentbooltrueIf true, merge the GDS shapes into the currently focused layout. If false, open a new tab via mw.create_layout(1) first.

Usage

From a shell with access to the KlayoutClaw MCP server:

bash
python skills/klayout_gds_import/scripts/import_gds.py \
--filepath /path/to/template.gds \
--flatten \
--merge-into-current

To import into a fresh tab (non-destructive to existing work):

bash
python skills/klayout_gds_import/scripts/import_gds.py \
--filepath /path/to/template.gds \
--no-merge-into-current
Return value

On success the script prints a JSON blob like:

json
{"status": "ok", "top_cell": "TOP", "shapes_added": 1342}

On failure:

json
{"status": "error", "error": "<message + traceback>"}

Edge cases handled

  • Cell-name collisions — the importer reads the GDS, then iterates all

top cells via each_top_cell() (never cell(i) by index) to avoid the orphaned-slot crash documented in CLAUDE.md.

  • Multi-top-cell after import — if flatten=true leaves more than one

top cell, the importer picks the top cell with the largest bbox as the canonical top, moves shapes from the other top cells into it shape-by-shape via shapes().each() + shapes().insert(), and deletes the emptied cells.

  • Dangling `CellView.cell` — after the read, the importer explicitly

rebinds cv.cell = <resolved_top> before returning, matching the pattern in CLAUDE.md under "Dangling cv.cell after Layout.read()".

  • No destructive clear — this skill never calls Layout.clear() when

merge_into_current=true, so existing user geometry is preserved.

  • Image annotations — preserved. Images live on the LayoutView, not the

Layout, so a plain read() does not touch them.

Reference

  • Script: scripts/import_gds.py
  • Uses: skills/scripts/mcp_client.py (shared MCP client)
  • Related pitfalls: see CLAUDE.md sections on Layout.read() cell-name

collisions and dangling cv.cell.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/caidish/klayoutclaw/klayout-gds-import/badge)](https://verified-skill.com/skills/caidish/klayoutclaw/klayout-gds-import)

Something wrong with this skill or its page? Tell us.