README.md
April 9, 2026 ยท View on GitHub
agents.md for Quantum Simulation
A comprehensive, language-agnostic specification that instructs AI coding agents
to build a complete quantum computing SDK from scratch.
๐งฌ What Is This?
This repository contains AGENTS.md โ a ~7,700-line
specification file that tells an AI coding agent exactly how to build a
complete quantum computing SDK. It is not code. It is a blueprint for code.
When you feed this file to an AI agent, it will generate a fully functional quantum simulation library in the programming language of your choice โ including:
| Component | Description |
|---|---|
| โ๏ธ Real Quantum Simulation | State-vector evolution, Born-rule sampling, mid-circuit measurement |
| ๐งฎ ~80 Gate Catalog | Tiers 0โ14: from Pauli gates to QFT, arithmetic circuits, and oracles |
| ๐ข Complex & Matrix Math | Built from scratch โ no numpy, no BLAS, no external math libraries |
| ๐ OpenQASM 3.1 Support | Full transpiler: serialize, deserialize, and compile quantum programs |
| ๐๏ธ Compilation Pipeline | SABRE layout/routing, basis-gate decomposition (ZYZ, KAK/Weyl), optimization |
| โ๏ธ Cloud Backends | IBM Quantum (Sampler V2) and qBraid REST API integrations |
| ๐งช 900+ Test Suite | Unit, integration, and round-trip tests with statistical validation |
No stubs. No approximations. No external quantum backends.
Every operation โ tensor products, gate application via subspace iteration, state collapse โ is implemented from scratch.
๐ Architecture at a Glance
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ QuantumCircuit โ
โ qc.h(0).cx(0,1).measure(0,0).measure(1,1) โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโ
โ Transpiler โ
โ โโโโโโโโโโโโโโโโโโโโโโ โ
โ โ OpenQASM 3.1 โ โ
โ โ Serialize/Parse โ โ
โ โโโโโโโโโโโโโโโโโโโโโโค โ
โ โ Compilation โ โ
โ โ โ Unroll โ โ
โ โ โ SABRE Layout โ โ
โ โ โ SABRE Routing โ โ
โ โ โ Basis Decomp โ โ
โ โ โ Optimization โ โ
โ โโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ
โSimulatorโ โ IBM Cloud โ โ qBraid โ
โ Backend โ โ Backend โ โ Backend โ
โโโโโโฌโโโโโ โโโโโโโฌโโโโโโ โโโโโโโฌโโโโโโ
โ โ โ
โผ โผ โผ
ExecutionResult: { "00": 50, "11": 50 }
๐ฌ Gate Tier System
The specification defines ~80 quantum gates organized into 15 tiers of abstraction, where every gate ultimately decomposes into single-qubit gates + CNOT:
Tier 0 โโโโโโโโโโโโโโโ Single-qubit primitives (I, H, X, Y, Z, RX, RY, RZ, S, T, SX, U, ...)
Tier 1 โโโโโโโโโโโโโโโ CX โ the universal entangling primitive
Tier 2 โโโโโโโโโโโโโ Controlled gates (CZ, CY, CP, CRX, CH, CU, ...)
Tier 3 โโโโโโโโโโโ Interaction gates (SWAP, RZZ, RXX, iSWAP, ECR, ...)
Tier 4 โโโโโโโโโ Three-qubit gates (Toffoli, Fredkin, ...)
Tier 5 โโโโโโโ Multi-controlled gates (MCX, MCPhase, C3X, C4X, ...)
Tier 6 โโโโโโ N-qubit composites (Diagonal, Permutation, MCMT, ...)
Tier 7 โโโโโ Uniformly controlled & unitary synthesis (UCGate, UnitaryGate, ...)
Tier 8 โโโโ Hamiltonian simulation (PauliEvolution, HamiltonianGate)
Tier 9 โโโ Quantum Fourier Transform
Tier 10 โโโ Reversible classical logic (AND, OR, XOR, ...)
Tier 11 โโ Quantum arithmetic (Adders, Multiplier)
Tier 12 โโ Function loading (Chebyshev, Reciprocal, ...)
Tier 13 โ Comparison & oracles (Phase/BitFlip Oracle, ...)
Tier 14 โ State preparation (GraphState)
๐ How to Use
The Basic Idea
- Pick an AI coding agent (see the table below)
- Feed it the
AGENTS.mdfile - Tell it which programming language you want
- Let it build the entire SDK, module by module
The specification is designed so the agent asks you for the target language first, then follows a strict build order โ implementing each module and running its tests before moving on.
๐ค Running with AI Coding Agents
Quick Reference
| Tool | Method | Complexity |
|---|---|---|
| Claude Code | Automatic via CLAUDE.md | โญ Easiest |
| Claude (Web/App) | Upload or paste | โญโญ Easy |
| Cursor | Project rules | โญโญ Easy |
| Windsurf | Project rules | โญโญ Easy |
| GitHub Copilot | Instructions file | โญโญ Easy |
| Cline | Custom instructions | โญโญ Easy |
| Aider | Conventions file | โญโญ Easy |
| Roo Code | Instructions file | โญโญ Easy |
| Amazon Q Developer | Project context | โญโญ Easy |
| ChatGPT / GPT | Upload file | โญโญโญ Manual |
| Gemini | Upload or paste | โญโญโญ Manual |
| Codex CLI | Instructions file | โญโญ Easy |
| bolt.new / Lovable / v0 | Paste in prompt | โญโญโญ Manual |
Claude Code
Easiest method โ Claude Code natively supports
AGENTS.mdvia theCLAUDE.mdpointer.
This repo is already configured. Just clone and run:
git clone https://github.com/nicedoc/agents.md-for-quantum-simulation.git
cd agents.md-for-quantum-simulation
claude
Claude Code will automatically read CLAUDE.md โ which references @AGENTS.md
โ and follow the full specification.
How it works:
CLAUDE.mdcontains@AGENTS.md, which tells Claude Code to load the specification- The agent will ask you for your target programming language
- Then it builds everything step by step
๐ก Tip: You can also use Claude Code in VS Code or JetBrains via the official extensions.
Claude Web
For claude.ai or the Claude desktop/mobile apps:
- Start a new conversation
- Attach the
AGENTS.mdfile (๐ button), or paste its contents - Send your first message:
I've attached a specification file (AGENTS.md) for building a quantum computing
SDK. Please read it completely and then follow the implementation plan.
I want to use TypeScript as the target language.
โ ๏ธ Context window: The spec is ~7,700 lines. Claude's large context window handles this well. If you hit limits, you can split the conversation across sessions, referencing specific sections.
Cursor
Option A โ Project Rules (recommended):
- Open the project folder in Cursor
- Go to Settings โ Rules (or create
.cursor/rules) - Add a rule file that references the spec:
Read and follow the complete specification in AGENTS.md.
It defines a quantum computing SDK to build from scratch.
Ask me for the target programming language before writing any code.
- Use Composer (Cmd/Ctrl+I) or Chat to start:
Follow the AGENTS.md specification. Let's begin with Step 1.
Option B โ Direct in chat:
- Open
AGENTS.mdin the editor - Select all content โ open Chat (Cmd/Ctrl+L)
- The file is automatically included as context
Windsurf
- Open the project in Windsurf
- Create
.windsurfrulesin the project root:
Read and follow the AGENTS.md specification completely.
It defines a quantum computing SDK. Follow the build order in Section 8.
Ask me for the target programming language first.
- Open Cascade and say:
Follow the AGENTS.md specification in this project. Let's start building.
Windsurf's Cascade can read project files directly, so it will pick up the full spec.
Github Copilot
For Copilot Chat in VS Code / JetBrains:
- Create
.github/copilot-instructions.md:
Read and follow the complete specification in AGENTS.md at the project root. It
defines a quantum computing SDK to implement from scratch. Follow the exact
build order in Section 8.2. Ask the user for the target programming language
before writing any code.
- Open Copilot Chat and reference the file:
@workspace Read AGENTS.md and follow the implementation plan.
Let's start with Step 1: types module.
For GitHub Copilot Coding Agent (in GitHub):
- Open an issue referencing the spec:
Implement the quantum computing SDK as specified in AGENTS.md using TypeScript.
Start with Step 1 (types) and follow the build order in Section 8.2.
- Assign the Copilot coding agent to the issue
Cline VS Code
- Install the Cline extension in VS Code
- Open Settings โ Custom Instructions and add:
Always read and follow the AGENTS.md file in the project root.
It is a complete specification for a quantum computing SDK.
Follow the build order in Section 8.2. Run tests after each module.
- In the Cline panel:
Read AGENTS.md and start implementing the quantum SDK.
I want to use Python. Begin with Step 1: types module.
Cline has full file system access and can run tests automatically after each module.
Aider
- Create a
.aider.conf.ymlor use the--readflag:
aider --read AGENTS.md
- Or add to
.aider.conf.yml:
read:
- AGENTS.md
- Start aider and give your instruction:
Follow the AGENTS.md specification to build a quantum computing SDK in Python.
Start with Step 1: implement the types module in src/types.py.
๐ก Tip: Use
--modelto pick your preferred LLM backend with Aider.
Roo Code
- Create
.roo/rulesor.roocode/rulesin the project root with a markdown file:
# Project Rules
Read and follow the complete specification in AGENTS.md. It defines a quantum
computing SDK to build from scratch. Follow the build order in Section 8.2
exactly. Run tests after implementing each module before moving to the next.
- In the Roo Code panel:
Read AGENTS.md and implement the quantum SDK in Rust. Start with Step 1.
Amazon Q Developer
- Open the project in your IDE with Amazon Q Developer installed
- In the Q Chat panel, reference the spec:
Read the file AGENTS.md in this project. It contains a complete specification
for building a quantum computing SDK. Follow it to implement the SDK in Python.
Start with Step 1 from Section 8.2.
Amazon Q can read project files when you reference them in chat.
ChatGPT
For ChatGPT (Web/App):
- Start a new conversation
- Attach
AGENTS.mdusing the ๐ button - Send:
I've uploaded a specification file called AGENTS.md. It defines a complete
quantum computing SDK to build from scratch. Please read it entirely, then
follow the implementation plan in Section 8. I want to use TypeScript.
For OpenAI Codex CLI:
# Set up the instructions
echo "Read and follow AGENTS.md completely." > codex-instructions.md
codex --instructions codex-instructions.md
โ ๏ธ Note: Due to context limits, ChatGPT may need you to work section by section. Start with "Read Sections 1-3" then proceed incrementally.
Codex CLI
- Create
AGENTS.mdinstructions file (already present in this repo) - Use the
--instructionsflag orcodex.md:
# Option A: instructions flag
codex --instructions AGENTS.md "Build the quantum SDK in TypeScript, start with Step 1"
# Option B: Create codex.md pointing to the spec
echo "Follow the specification in AGENTS.md exactly." > codex.md
codex
Gemini
For Gemini (Web/App):
- Start a new conversation
- Upload
AGENTS.md - Send:
I've uploaded a detailed specification file. It defines a complete quantum
computing SDK. Read it fully, then implement it step by step in Python
following the build order in Section 8.2.
For Gemini in Google AI Studio / Vertex AI:
- Add
AGENTS.mdas system instructions or context - Start the conversation with your language choice
For Gemini Code Assist (IDE):
- Reference the file in your IDE's Gemini chat
- Ask it to follow the specification
๐ก Gemini's large context window (1M+ tokens) can handle the entire spec in one pass.
Web Builders
For web-based AI code generators (bolt.new, Lovable, v0, Replit Agent, etc.):
- Copy the contents of
AGENTS.md - Paste it into the prompt / system instructions area
- Add your instruction:
Follow this specification to build a quantum computing SDK in TypeScript.
Start with the types module (Step 1) and proceed through all 16 steps.
โ ๏ธ These tools may have smaller context windows. Consider splitting the spec into sections and feeding them incrementally.
๐ก Tips for Best Results
๐ฏ Prompting Strategy
| Strategy | Description |
|---|---|
| Be explicit about the language | "Use TypeScript" / "Use Python" / "Use Rust" |
| Follow the build order | The spec defines Steps 1โ16. Go in order. |
| Run tests after each module | The spec requires this. Remind the agent. |
| Reference sections directly | "Implement the gates from Section 3, Tier 0" |
| Split if needed | For smaller context windows, work section by section |
๐งฉ Incremental Approach (for any agent)
If the agent can't process the full spec at once:
Step 1: "Read Sections 1โ2 of AGENTS.md (Overview & Conventions)"
Step 2: "Read Section 3, Tiers 0โ1 (Single-qubit gates & CX)"
Step 3: "Now implement src/complex.{ext} and src/matrix.{ext}"
Step 4: "Read Section 3, Tiers 2โ5 and implement src/gates.{ext}"
...continue through all sections...
๐ Spec Size Reference
| Metric | Value |
|---|---|
| Total lines | ~7,760 |
| Total sections | 13 |
| Gate definitions | ~80 gates across 15 tiers |
| Required tests | 900+ |
| Estimated tokens | ~60,000โ80,000 |
๐ Repository Structure
.
โโโ ๐ AGENTS.md # The full specification (this is the star of the show)
โโโ ๐ CLAUDE.md # Pointer file for Claude Code (@AGENTS.md)
โโโ ๐ README.md # You are here
โโโ โ๏ธ LICENSE # MIT License
After an agent finishes building, the repo will look like:
.
โโโ AGENTS.md
โโโ CLAUDE.md
โโโ README.md (updated with API docs)
โโโ LICENSE
โโโ src/
โ โโโ types.{ext}
โ โโโ complex.{ext}
โ โโโ matrix.{ext}
โ โโโ gates.{ext} # ~80 gates, Tiers 0โ14
โ โโโ expansion.{ext} # OpenQASM 3.1 Expansion API
โ โโโ parameter.{ext}
โ โโโ circuit.{ext} # QuantumCircuit builder
โ โโโ transpiler.{ext} # OpenQASM 3.1 transpiler + compiler
โ โโโ simulator.{ext} # State-vector simulation engine
โ โโโ backend.{ext}
โ โโโ ibm_backend.{ext} # IBM Quantum cloud
โ โโโ qbraid_backend.{ext}# qBraid cloud
โ โโโ bloch.{ext}
โ โโโ mod.{ext}
โโโ tests/
โ โโโ complex.test.{ext}
โ โโโ matrix.test.{ext}
โ โโโ gates.test.{ext}
โ โโโ ... (900+ tests)
โ โโโ integration.test.{ext}
โโโ {build config}
๐ค FAQ
What programming languages does this support?
Any language. The spec is language-agnostic. It has been designed to work with TypeScript, Python, Rust, Go, Java, C#, and others. The agent adapts idioms, naming conventions, and tooling to your chosen language.
How long does it take to generate?
It depends on the agent and the language. With a capable agent like Claude Code, expect several hours of autonomous work. The spec is large and detailed โ that's by design.
Does the generated code actually simulate quantum circuits?
Yes. The simulator uses real state-vector evolution over complex vector spaces with subspace iteration for gate application and Born-rule sampling for measurement. It's a real quantum simulator โ not a mock or stub.
Can I use this to run circuits on real quantum hardware?
Yes. The spec includes IBM Quantum and qBraid backend integrations. After generating the SDK, configure your API credentials and submit circuits to real quantum processors.
Why is the spec so long?
Precision. Every gate matrix, every decomposition, every phase convention, every edge case is specified explicitly. This eliminates ambiguity and ensures the generated code is mathematically correct. Quantum computing is unforgiving โ a wrong sign or missing phase factor means wrong results.
What is the Phase Convention section about?
Quantum gates that differ only by a "global phase" are physically equivalent in isolation โ but that phase becomes observable when you add controls. The Phase Convention (Section 2) ensures every gate, decomposition, and equality check handles phase consistently across the entire library. It's the mathematical backbone.
What if my AI agent can't handle the full file?
Work incrementally. Feed it section by section, following the build order in Section 8.2. Each module depends only on previous ones, so you can build step by step.
๐ License
MIT โ Henrique Emanoel Viana
Built with โ๏ธ and a very detailed specification.