caidish/klayoutclaw/klayout-gds-import
Claude Code and agent skill by caidish/klayoutclaw
- community
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-importSKILL.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.cellmay 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:
- Reads the GDS into the current layout (or a fresh tab),
- Flattens hierarchy so there are no subcells left,
- Collapses any residual multi-top-cell state into a single top cell,
- Rebinds
CellView.cellto the resolved top, zooms to fit, and refreshes
the layer panel.
Parameters
| Parameter | Type | Default | Description | |
|---|---|---|---|---|
filepath | string | — | Required. Absolute path to a .gds file on disk. | |
flatten | bool | true | If true, flatten all subcells into the top cell after reading (cell.flatten(-1, True)). | |
merge_into_current | bool | true | If 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:
To import into a fresh tab (non-destructive to existing work):
Return value
On success the script prints a JSON blob like:
On failure:
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=trueleaves 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.mdsections onLayout.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
- SKILL.md in the repositoryCheckingskills/klayout_gds_import/SKILL.md
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
[](https://verified-skill.com/skills/caidish/klayoutclaw/klayout-gds-import)