caidish/klayoutclaw/nanodevice-flakedetect-commit
Claude Code and agent skill by caidish/klayoutclaw
- community
Checking that the SKILL.md file is still in the repository.
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.
Install
npx vskill@latest install caidish/klayoutclaw/nanodevice-flakedetect-commitSKILL.md
nanodevice_flakedetect_commit — KLayout Polygon Insertion
Pure agent workflow using existing skills and MCP tools. No custom scripts needed.
Scope: This workflow is for pre-gdsalign only. If you have already runnanodevice_gdsalign, use thecontour_gdscoordinates fromtraces_gds.jsondirectly and do not apply the image-center transform described below.
When to Use
After the combine step completes. Requires traces.json from <out>/combine/.
Prerequisites
- KLayout running with KlayoutClaw plugin (v0.5+)
- A layout open (use
create_layoutMCP tool if needed) - Background image loaded (use
imageskill'sadd_image.py) traces.jsonproduced by the combine step
Commit Protocol
Step 1: Load background image
NOTE: The add_image.py script uses the MCP client which does NOT work from inside a Docker container. Instead, use execute_script directly to load the image:
Step 2: Read traces.json
Load <out>/combine/traces.json. Extract:
image_size_um—[w_um, h_um]for coordinate transformlayer_map— material name →"layer/datatype"stringmaterials— per-material contour lists withcontour_umcoordinates
Step 3: Coordinate transform
Contours in traces.json use image-origin coordinates (0,0 at top-left, y-axis pointing down, units in microns).
KLayout uses centered coordinates (0,0 at image center, y-axis pointing up, units in microns).
Transform each point:
The y-axis sign flip (h_um/2 - img_y_um) is the most common source of errors.
Step 4: Add polygons via execute_script
NOTE: The add_polygon.py script uses the MCP client which does NOT work from inside a Docker container. Instead, use execute_script to add polygons directly:
This is faster and more reliable than calling add_polygon.py for each material, and works from inside Docker containers.
Step 5: Verify with screenshot
Use the MCP screenshot tool to capture the viewport and visually confirm polygons align with the background image:
Layer Assignments
| Material | Layer | Color | |
|---|---|---|---|
| top_hBN | 10/0 | green | |
| graphene | 11/0 | red | |
| bottom_hBN | 12/0 | blue-ish | |
| graphite | 13/0 | yellow |
These defaults come from traces.json layer_map — always use the values from the JSON, not hardcoded.
Common Pitfalls
- Y-axis flip:
kl_y = h_um/2 - img_y_um— forgetting the sign flip puts polygons upside down. - MCP client scripts fail in Docker:
add_polygon.pyandadd_image.pyconnect to KLayout MCP on localhost, which doesn't work from inside a container. Always useexecute_scriptinstead (shown above). - Cell name: When using
execute_script, use_layout.top_cell()to get the current top cell — don't hardcode a cell name. - Background centering: The image must be centered at KLayout's (0,0) origin so that the coordinate transform
kl_x = x_um - w_um/2aligns correctly. - Large contours: Some materials (bottom_hBN) can have 5000+ contour points. Use
execute_scriptwith the full polygon — it handles large point arrays efficiently.
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/nanodevice_flakedetect_commit/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/nanodevice-flakedetect-commit)