用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill gdsfactory-component-designer命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | gdsfactory-component-designer |
| description | > Use when this capability is needed. |
This skill lets an LLM agent generate, visualize, and iteratively modify photonic-IC components using the gdsfactory Python library.
Activate this skill when the user:
The examples below use bare python, but you must adapt the invocation to
whatever Python environment the user has set up. Common alternatives:
| Setup | Command |
|---|---|
| System / venv / conda | python |
| uv project | uv run python |
| pipx-installed gdsfactory | pipx run --spec gdsfactory python |
| Nix shell | nix develop -c python |
Probe the environment first (e.g. check for a pyproject.toml with
[tool.uv], or an active virtualenv) and pick the appropriate command. When
in doubt, try python -c "import gdsfactory" — if it fails, fall back to
uv run python or ask the user.
Before generating any component, make sure the PDK is activated. The generic PDK ships with gdsfactory and is always available:
import gdsfactory as gf
# Activate the built-in generic PDK (always available)
gf.gpdk.PDK.activate()
If the user specifies a third-party PDK (e.g. cspdk, ubcpdk,
sky130, gf45spclo), import and activate it instead.
Always clear the cell cache between independent component generations to avoid
stale state: gf.clear_cache().
gdsfactory ships with 300+ parametric component factory functions under
gf.components. To instantiate a component, call its factory function:
import gdsfactory as gf
gf.gpdk.PDK.activate()
# Example: 1×2 MMI splitter
c = gf.components.mmi1x2(width_mmi=5.0, length_mmi=25.0, gap_mmi=0.25)
Every component factory function is a standard Python callable with typed
parameters. Use help() or inspect.signature() to discover the parameters.
Visualization is essential: render and inspect the component after creating or modifying it to verify the result.
Use the helper script bundled with this skill for reliable headless rendering. From a bash tool or Python subprocess:
python .agents/skills/gdsfactory-component-designer/scripts/visualize_component.py \
"gf.components.mmi1x2(width_mmi=5.0, length_mmi=25.0)" \
/tmp/mmi1x2.png
After saving, always import the image into context so you and the user can see it.
The simplest modification is changing the factory-function arguments. Always
call gf.clear_cache() before regenerating to avoid stale data.
Build a custom component by placing and connecting sub-components. Use the
@gf.cell decorator for proper naming and caching.
# Write to GDS file
gdspath = c.write_gds("/tmp/my_component.gds")
When the user asks for a component, follow this streamlined loop:
| Component | Factory function | Key parameters |
|---|---|---|
| Straight waveguide | gf.components.straight | length, width |
| Euler bend | gf.components.bend_euler | radius, angle |
| 1×2 MMI | gf.components.mmi1x2 | width_mmi, length_mmi |
| Ring resonator | gf.components.ring_single | gap, radius |
| Grating coupler | gf.components.grating_coupler_te | period, n_periods |
The full gdsfactory docs are at https://gdsfactory.github.io/gdsfactory/.
Browse tutorial notebooks under docs/notebooks/ or over 100 sample Python
scripts under gdsfactory/samples/ for worked examples.
Don't guess – search the repo for examples first.
DCplxTransgdsfactory's geometry backend is kfactory, built on KLayout's Python db module. Full API docs: https://www.klayout.de/doc-qt5/code/module_db.html
DCplxTrans constructorklayout.db.DCplxTrans represents a rotation + mirror + translation on µm-unit coordinates. Positional and keyword arguments are both supported:
import klayout.db as kdb
# positional: DCplxTrans(mag, angle, mirror, u)
t = kdb.DCplxTrans(1.0, 45.0, True, kdb.DVector(10.0, 5.0))
# keyword (preferred for clarity):
t = kdb.DCplxTrans(mag=1.0, angle=45.0, mirror=True, u=kdb.DVector(10.0, 5.0))
Parameters (application order: mirror → rotate → translate):
| Parameter | Type | Description |
|---|---|---|
mag | float | Scaling factor — always 1.0; see warning below |
angle | float | CCW rotation in degrees |
mirror | bool | Mirror about x-axis before rotation |
u | DVector | Translation in µm |
⚠️ Never set
mag != 1.0. No foundry accepts scaled instances. Use component factory parameters to create differently-sized variants.
ℹ️
ComponentReference.dcplx_transsnaps to the manufacturing grid viaICplxTrans, so off-grid placements are silently adjusted.
ComponentReference.dcplx_transimport gdsfactory as gf
import klayout.db as kdb
circuit = gf.Component("circuit")
ref = circuit.add_ref(gf.components.mmi1x2())
# rotate 45°, mirror, translate to (10, 5) µm
ref.dcplx_trans = kdb.DCplxTrans(mag=1.0, angle=45.0, mirror=True, u=kdb.DVector(10.0, 5.0))
DCplxTrans objects compose with * (right-hand operand applied first):
rotate = kdb.DCplxTrans(angle=90.0)
translation = kdb.DCplxTrans(u=kdb.DVector(20.0, 0.0))
ref.dcplx_trans = translation * rotate # rotate first, then translate
| Goal | Example |
|---|---|
| Translate | kdb.DCplxTrans(u=kdb.DVector(dx, dy)) |
| Rotate 90° CCW | kdb.DCplxTrans(angle=90.0) |
| Mirror about x-axis | kdb.DCplxTrans(mirror=True) |
| Rotate then translate | translation * rotate |
| Read / modify in place | ref.dcplx_trans / ref.dcplx_trans = t * ref.dcplx_trans |
Source: gdsfactory/gdsfactory — distributed by TomeVault.