pyzx-optimization

pyzx-optimization is a skill for Claude Code, Codex from xi-zhao/OpenQuantum. It costs 44 tokens per session (1,082 once invoked), scanned A, original, MIT.

A quantum-circuit optimization tool for Clifford+T circuits, which are circuits built from common quantum gates including H, S, T, and controlled operations. It rewrites the circuit with ZX-calculus rules and extracts an optimized circuit.

In plain words
What is it for?
Use it to optimize supported H, S, T, X, Y, Z, CX, and CZ gates, compare before-and-after gate counts, and optionally check full unitary equivalence apart from overall phase.
Why use it?
It helps compare alternative equivalent circuits when gate cost matters. Different costs, such as T gates, two-qubit gates, and total gates, may improve or worsen independently.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: installed under .agents/ (shared by several agents); mentions Codex.

Good fit Use it to optimize supported H, S, T, X, Y, Z, CX, and CZ gates, compare before-and-after gate counts, and optionally check full unitary equivalence apart from overall phase.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/xi-zhao/openquantum/pyzx-optimization
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 xi-zhao/OpenQuantum --skill pyzx-optimization
Clone the repo
git clone --depth 1 https://github.com/xi-zhao/OpenQuantum

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 pyzx-optimization

README.md
[![agentmods](https://agentmods.dev/badge/skills/xi-zhao/openquantum/pyzx-optimization/github.svg)](https://agentmods.dev/skills/xi-zhao/openquantum/pyzx-optimization)
Your own site
<a href="https://agentmods.dev/skills/xi-zhao/openquantum/pyzx-optimization"><img src="https://agentmods.dev/badge/skills/xi-zhao/openquantum/pyzx-optimization/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 pyzx-optimization

Your own site · 80×15
<a href="https://agentmods.dev/skills/xi-zhao/openquantum/pyzx-optimization"><img src="https://agentmods.dev/badge/skills/xi-zhao/openquantum/pyzx-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 44 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,082 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.00044 $0.01082
Opus 5.5 $0.00018 $0.00433
Sonnet 5.5 $0.00009 $0.00216
Haiku 4.5 $0.00004 $0.00108

Measured 5d ago against content hash d0cac83b8471, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

pyzx-optimization 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 5d ago.

The scan reads SKILL.md. This mod also ships 8 executable files (core/render-report.mjs, evals/run-evals.mjs, mcp/bridge.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.

.agents/skills/pyzx-optimization/SKILL.md · 42 lines

How it starts

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

PyZX 电路优化

原生 SDK 路径

本能力同时支持 PyZX 的原生公开 API。用户需要 Circuit、Graph、重写策略、提取、优化与等价性流程 时,由 Agent 在固定依赖环境中编写和运行任务代码,不限于下文便捷 Tool 的预设模型。

使用 node scripts/sdk-access.mjs inspect pyzx-optimization 定位环境,按完整 SDK 工作流执行。模块导航:pyzx;导航不是 API 白名单。

下文关于模型、门集、输入与预算的限制描述便捷 Tool 的合同;原生 SDK 另受上游版本、可选依赖、宿主资源与用户授权约束。已禁用或被拒绝的动作不能借代码路径绕过。执行状态和科研验收分别报告。

当用户需要减少 Clifford+T 电路的门开销、研究 ZX 重写或比较等价实现时,调用 Harness 注册的 pyzx_local.optimize_pyzx_circuit。

  • 提交 numQubits 和结构化 gates:支持 H、S、T、X、Y、Z、CX、CZ,量子位数与门数由输入决定。CX 的 targets 为控制位、目标位;不接受动态电路、测量或任意 QASM 输入。
  • 先明确比较目标是 T-count、双量子位门数还是总门数;三项可能此消彼长。报告 before/after 的实际值,不承诺每项都会改善。
  • Tool 返回输入和优化后的 OpenQASM 2,可按 referenceMode 独立构造完整酉矩阵,忽略整体相位比较。提取保留量子位排列;实际执行参考且发现不等价时,调用失败。
  • Y 在输入 QASM 中展开为 X 后接 Z,整体相位不影响此处合同;before 统计的是展开后的 PyZX 电路。QASM 可继续交给已有 QCEC 工具检查;本能力不做硬件映射。
  • 当前 L3(DSH 侧支持物化证据与可回放中央验收;Codex 侧保留 scientificValidation=observations_available 独立观察);依赖须显式准备;计算可能写本地缓存。

版本、准备命令、数值检查和限制见接入说明。

独立参考使用 referenceMode=auto|required|skip:auto 按默认阈值选择参考,required 使用调用方资源尝试所请求规模,skip 跳过。未执行时 reference.status=not_run,参考值和差异为 null;尝试后失败会返回错误。

电路量子位数和门数由调用方选择,适配器不额外设置人工规模上限。具体资源配置见本地计算说明。

依赖准备

运行前执行 node scripts/setup-paper-tools.mjs pyzx-optimization。缺失、旧锁和已安装环境的处理见共同准备说明;Tool 不自动安装或升级依赖。

独立科学观察与可回放科学验收(L3)

执行期独立验证器只产 observations,不自行推导科学验收;provenance.complete=not_checked,reproductionProfiles: []。独立解析前后 QASM,精确核对输入门表与请求(含已声明的 Y→X、Z 展开),防止通过相消门填充虚报优化幅度;复算门数/T 门数/双比特门数及依赖深度。≤6 qubits、≤512 输入门、≤2048 输出门且未跳过参考时,用独立复矩阵乘法核对全局相位无关酉等价。超出参考范围或缺环境时相应观察为 not_checked,不限制主 Tool 的计算规模。

DSH 完整调用含 workspace-write:宿主 Materializer 经 ctx.fs 原子写入并重读输入与结果字节,中央 Builder 按 [email protected] 派生科学验收并保存可读报告。缺少稠密酉对照或显式跳过参考保留 conditional,任何独立检查发现矛盾则 failed。Codex 继续只提供执行期 observations。

Read the full file on GitHub · 42 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. 5d ago Changed · +6 lines d0cac83b8471
  2. 1mo ago Changed · +11 lines 6f81afba63b2
  3. 2mo ago Changed · +4 lines 690e0c112e33
  4. 2mo ago First seen · 21 lines · 44 tokens per session scan A 026404198165

Subscribe to this mod's changes

pyzx-optimization is a skill published in the GitHub repository xi-zhao/OpenQuantum (75 stars, last pushed 2d ago), licensed MIT. It adds 44 tokens to every session and 1,082 once invoked, about $0.0002 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-09-15.

Related

pyzx-optimization compared with skills from other repositories

pyzx-optimization next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
pyzx-optimizationxi-zhao/OpenQuantumSkill752d agoMITA44Claude Code, Codex
manim-animatorsandbaseai/sandbase-skillsSkill2138d agoApache-2.0A59Claude Code
academic-researchsandbaseai/sandbase-skillsSkill2138d agoApache-2.0A39Claude Code
academic-trend-researchsandbaseai/sandbase-skillsSkill2138d agoApache-2.0A43Claude Code
openalex-guidecyanheads/openalex-mcp-serverSkill1813d agoApache-2.0A96Claude Code
arxiv-guidecyanheads/arxiv-mcp-serverSkill73d agoApache-2.0A81Claude Code
alexandriaThe-40-Thieves/alexandria-mcpSkill314d agoMITA71Claude Code