zemax-python-connect

zemax-python-connect is a skill for Claude Code, Codex from Hao-xl/zemax-python-connect. It costs 77 tokens per session (3,264 once invoked), scanned A, original, MIT.

A focused guide for connecting Python to Zemax OpticStudio, optical design software, through its ZOS-API programming interface. It checks installation paths, required files, licenses, connection modes, and the active optical system.

In plain words
What is it for?
Use it to locate and verify Zemax files, establish independent or interactive Python connections, diagnose authorization and IPC errors, and report the verified connection state.
Why use it?
It helps diagnose connection failures without assuming that another computer has the same installation or version. It also prevents closing user-owned OpticStudio sessions and requires permission before long disk searches.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions Codex.

Good fit Use it to locate and verify Zemax files, establish independent or interactive Python connections, diagnose authorization and IPC errors, and report the verified connection state.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hao-xl/zemax-python-connect/zemax-python-connect
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Hao-xl/zemax-python-connect --skill zemax-python-connect
Clone the repo
git clone --depth 1 https://github.com/Hao-xl/zemax-python-connect

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for zemax-python-connect

README.md
[![agentmods](https://agentmods.dev/badge/skills/hao-xl/zemax-python-connect/zemax-python-connect/github.svg)](https://agentmods.dev/skills/hao-xl/zemax-python-connect/zemax-python-connect)
Your own site
<a href="https://agentmods.dev/skills/hao-xl/zemax-python-connect/zemax-python-connect"><img src="https://agentmods.dev/badge/skills/hao-xl/zemax-python-connect/zemax-python-connect/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for zemax-python-connect

Your own site · 80×15
<a href="https://agentmods.dev/skills/hao-xl/zemax-python-connect/zemax-python-connect"><img src="https://agentmods.dev/badge/skills/hao-xl/zemax-python-connect/zemax-python-connect.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 77 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,264 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00077 $0.03264
Opus 5.5 $0.00031 $0.01306
Sonnet 5.5 $0.00015 $0.00653
Haiku 4.5 $0.00008 $0.00326

Measured 1mo ago against content hash 77db6b9438b9, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

zemax-python-connect scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

The scan reads SKILL.md. This mod also ships 10 executable files (examples/interactive_minimal.py, examples/standalone_minimal.py, scripts/connection_diagnose.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

SKILL.md · 265 lines

How it starts

The opening of the file, as written. The whole thing — 265 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Zemax Python 连接

范围

本 skill 只负责建立和验证 Python 与 Zemax OpticStudio 的 ZOS-API 连接。

当连接状态不确定时,先使用本 skill。连接验证完成后,再使用 zemax-python 进行模型操作、评价函数、优化、分析和容差等后续工作。

本 skill 不负责光学系统设计,也不负责具体优化策略。

Agent 执行契约(必须遵守)

  1. 不假设 Python、Zemax 数据目录、OpticStudio 安装目录或版本与其他电脑相同。
  2. 先运行 doctor.py --mode locator。只有已经验证 ZOSAPI_NetHelper.dll 存在,才允许初始化 ZOSAPI_NetHelper。
  3. 初始化后必须读取 GetZemaxDirectory(),并再次确认实际安装目录中存在 ZOSAPI.dll 和 ZOSAPI_Interfaces.dll。
  4. 独立模式必须满足 APP_MODE=Server;交互模式必须满足 APP_MODE=Plugin。仅有非空 app 不代表成功。
  5. 两种模式都必须确认有效许可证和非空 PrimarySystem。
  6. 独立模式只关闭 Python 自己创建的实例;即使连接中途失败,也必须清理已创建的应用。
  7. 交互模式永远不调用 CloseApplication()。
  8. 不自动结束用户已有的 OpticStudio 进程。需要结束进程时,先解释原因并取得用户同意。
  9. 每次报告解析到的数据根目录、实际安装目录、NetHelper 路径、版本、许可证、应用模式和 PrimarySystem 状态。
  10. 路径发现必须按顺序执行:Windows 快速来源 → 自动有限深度磁盘搜索 → 经用户明确允许的全盘搜索。禁止跳过授权直接全盘搜索。
  11. 全盘搜索前必须告知用户:通常约 2–15 分钟,文件很多或磁盘较慢时可能超过 30 分钟;只有用户明确允许后,才可传入 --exhaustive-search --confirm-long-scan。
  12. 磁盘搜索必须汇报已扫描目录数、权限拒绝目录数、其他扫描错误数和耗时,不得静默忽略权限失败。

Codex/Agent 沙箱重要规则

OpticStudio ZOS-API 使用 .NET Remoting IPC。某些 Agent 沙箱允许读取 DLL,却会阻止 IPC 连接。典型错误包括:

System.Runtime.Remoting.RemotingException
连接到 IPC 端口失败: 拒绝访问
Access denied

出现 ERROR_CODE=IPC_ACCESS_DENIED 时,不要继续猜测 DLL、许可证或实例编号,也不要反复重启 Zemax。应向用户说明原因并请求批准,在 Agent 沙箱外重新运行完全相同的 Zemax Python 命令。沙箱外执行仍必须限制为本 skill 的诊断或连接脚本。

连接模式选择

用户目标 推荐模式 API
批量自动化、创建/打开/保存文件,不需要观察 GUI 实时变化 独立应用程序 CreateNewApplication()
用户希望在已经打开的 OpticStudio GUI 中看到实时修改 交互扩展 ConnectAsExtension(instance)
用户明确说 Python 应实时修改可见的 LDE 或 Layout 交互扩展 ConnectAsExtension(instance)
用户只需要生成 .zos / .zmx 输出文件 独立应用程序 CreateNewApplication()

第一原则:先定位,再初始化,再验证实际安装目录

优先运行统一诊断:

python scripts\doctor.py --mode locator

它会输出 Python 位数、pythonnet 版本、候选目录、已验证的 ZOSAPI_NetHelper.dll、初始化器解析出的实际 OpticStudio 安装目录,以及 ZOSAPI.dll / ZOSAPI_Interfaces.dll 的完整路径。

也可以只运行定位脚本:

python scripts\zosapi_locator.py --list-candidates

Read the full file on GitHub · 265 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 265 lines · 77 tokens per session scan A 77db6b9438b9

Subscribe to this mod's changes

zemax-python-connect is a skill published in the GitHub repository Hao-xl/zemax-python-connect (9 stars, last pushed 3mo ago), licensed MIT. It adds 77 tokens to every session and 3,264 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

jupyter-notebook

Iterative Python via live Jupyter kernel (hamelnb).

NousResearch/hermes-agent · 18 tokens

matlab

Builds, reviews, migrates, and plans MATLAB or GNU Octave numerical workflows. Use for arrays, tabular/time data, tests, projects, graphics, MAT files, and explicit Python interoperability.

K-Dense-AI/scientific-agent-skills · 44 tokens

pennylane

Builds and differentiates PennyLane quantum circuits, hybrid PyTorch or JAX models, molecular VQE and QAOA workflows. Use for variational quantum algorithms, quantum machine learning, simulator validation, and moving validated circuits to provider plugins. For hardware-specific compilation use qiskit or cirq; for…

K-Dense-AI/scientific-agent-skills · 74 tokens

cuopt-numerical-optimization-api

LP, MILP, and QP (beta) with cuOpt — Python, C, and CLI. Use when the user is solving LP, MILP, or QP with any cuOpt interface.

NVIDIA/skills · 51 tokens

rocm-kernels

Provides guidance for writing and benchmarking optimized Triton kernels for AMD GPUs (MI355X, R9700) on ROCm, targeting HuggingFace diffusers (LTX-Video, SD3, FLUX) and transformers. Core kernels: RMSNorm, RoPE 3D, GEGLU, AdaLN. Includes XCD swizzle, autotune, diffusers integration patterns, and LTX-Video pipeline…

huggingface/kernels · 93 tokens

gh-address-comments

Help address review/issue comments on the open GitHub PR for the current branch using gh CLI; verify gh auth first and prompt the user to authenticate if not logged in.

foryourhealth111-pixel/Vibe-Skills · 39 tokens