K-Dense-AI/scientific-agent-skills/skills/qiskit/SKILL.md
qiskit
Build, simulate, transpile, and execute quantum circuits with Qiskit and IBM Quantum Runtime. Use for Qiskit 2.x circuits and operators, V2 Sampler or Estimator primitives, target-aware transpilation, local or noisy simulation, IBM QPU execution, Runtime sessions or batches, error mitigation, and Qiskit ecosystem packages.
- Source repository stars
- 31,966
- Declared platforms
- 0
- Static risk flags
- 1
- Last source update
- 2026-07-28
- Source checked
- 2026-07-28
Decision brief
What it does—and where it fits
Use current Qiskit 2.x APIs to build circuits, prepare hardware-compatible instruction set architecture (ISA) circuits, and execute them through V2 primitives.
Not for
- Tasks that require unconfirmed production actions or broad system permissions.
- Environments where the pinned source and install steps cannot be inspected.
Compatibility matrix
Platform support, with evidence labels
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
Inspect first. Install second.
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/K-Dense-AI/scientific-agent-skills --skill "skills/qiskit"Inspect the Agent Skill "qiskit" from https://github.com/K-Dense-AI/scientific-agent-skills/blob/e7ac42510774624f327003c95b6650e2883bc01d/skills/qiskit/SKILL.md at commit e7ac42510774624f327003c95b6650e2883bc01d. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
What the source asks the agent to do
- 01
Core Workflow
Follow this sequence for every hardware-oriented workload:
Map the problem to a circuit and, for Estimator, one or more observables.Optimize the parameterized circuit once for the selected backend.Apply the layout to every observable. - 02
Choose the Right Path
Review the “Choose the Right Path” section in the pinned source before continuing.
Review and apply the “Choose the Right Path” source section. - 03
Installation
Create an isolated environment and install only the components needed:
Create an isolated environment and install only the components needed:bash uv venv --python 3.13 source .venv/bin/activate - 04
Core SDK plus plotting support
uv pip install "qiskit[visualization]==2.5.0"
uv pip install "qiskit[visualization]==2.5.0" - 05
Add only when needed
uv pip install "qiskit-ibm-runtime==0.48.0" uv pip install "qiskit-aer==0.17.2" python from qiskit import QuantumCircuit from qiskit.primitives import StatevectorSampler
uv pip install "qiskit-ibm-runtime==0.48.0" uv pip install "qiskit-aer==0.17.2" python from qiskit import QuantumCircuit from qiskit.primitives import StatevectorSamplercircuit = QuantumCircuit(2) circuit.h(0) circuit.cx(0, 1) circuit.measureall() creates the classical register named "meas"sampler = StatevectorSampler(seed=7) pubresult = sampler.run([circuit], shots=1024).result()[0] counts = pubresult.data.meas.getcounts() print(counts) python import numpy as np from qiskit import QuantumCircuit from qis…
Permission review
Static risk signals and limitations
Runs scripts
The documentation asks the agent to run terminal commands or scripts.
python scripts/check_environment.pyRuns scripts
The documentation asks the agent to run terminal commands or scripts.
python scripts/run_local_primitives.py --shots 1024 --seed 7Evidence record
Why each signal appears
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 87/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 31,966 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Provenance and original SKILL.md
- Repository
- K-Dense-AI/scientific-agent-skills
- Skill path
- skills/qiskit/SKILL.md
- Commit
- e7ac42510774624f327003c95b6650e2883bc01d
- License
- MIT
- Collected
- 2026-07-28
- Default branch
- main
View the original SKILL.md
Qiskit
Use current Qiskit 2.x APIs to build circuits, prepare hardware-compatible instruction set architecture (ISA) circuits, and execute them through V2 primitives.
This skill was verified on 2026-07-23 against the PyPI releases qiskit==2.5.0, qiskit-ibm-runtime==0.48.0, and qiskit-aer==0.17.2. Check references/sources.md before changing pins or documenting newly released behavior.
Choose the Right Path
| Goal | Recommended interface |
|---|---|
| Exact local sampling | qiskit.primitives.StatevectorSampler |
| Exact local expectation values | qiskit.primitives.StatevectorEstimator |
| High-performance or noisy simulation | Qiskit Aer |
| IBM QPU sampling | qiskit_ibm_runtime.SamplerV2 |
| IBM QPU expectation values and mitigation | qiskit_ibm_runtime.EstimatorV2 |
| Backend without native primitives | BackendSamplerV2 or BackendEstimatorV2 |
| Open-system or master-equation dynamics | Prefer QuTiP |
| Differentiable quantum machine learning | Prefer PennyLane unless Qiskit integration is required |
Installation
Create an isolated environment and install only the components needed:
uv venv --python 3.13
source .venv/bin/activate
# Core SDK plus plotting support
uv pip install "qiskit[visualization]==2.5.0"
# Add only when needed
uv pip install "qiskit-ibm-runtime==0.48.0"
uv pip install "qiskit-aer==0.17.2"
Do not install qiskit-terra; it was superseded by the qiskit distribution. Qiskit Runtime, Aer, Nature, Machine Learning, Optimization, and Algorithms are separate distributions.
For IBM account setup, CI-safe credential handling, optional packages, and environment repair, read references/setup.md.
Core Workflow
Follow this sequence for every hardware-oriented workload:
- Map the problem to a circuit and, for Estimator, one or more observables.
- Optimize the parameterized circuit once for the selected backend.
- Apply the layout to every observable.
- Execute ISA circuits through a V2 primitive using Primitive Unified Blocs (PUBs).
- Analyze register-aware results, metadata, uncertainty, and resource usage.
Do not bind and retranspile a parameterized circuit inside every optimizer iteration. Transpile the parameterized circuit once, then pass parameter arrays in PUBs.
Quick Local Sampling
from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorSampler
circuit = QuantumCircuit(2)
circuit.h(0)
circuit.cx(0, 1)
circuit.measure_all() # creates the classical register named "meas"
sampler = StatevectorSampler(seed=7)
pub_result = sampler.run([circuit], shots=1024).result()[0]
counts = pub_result.data.meas.get_counts()
print(counts)
Sampler V2 preserves shots and classical-register structure. Access the register by its actual name; measure_all() uses meas.
Quick Local Estimation
import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
from qiskit.primitives import StatevectorEstimator
from qiskit.quantum_info import SparsePauliOp
theta = Parameter("theta")
circuit = QuantumCircuit(2)
circuit.ry(theta, 0)
circuit.cx(0, 1)
observable = SparsePauliOp.from_list([("ZZ", 1.0), ("XX", 0.5)])
parameter_values = [[0.0], [np.pi / 4], [np.pi / 2]]
estimator = StatevectorEstimator(seed=7)
pub = (circuit, observable, parameter_values)
pub_result = estimator.run([pub]).result()[0]
print(pub_result.data.evs)
Estimator circuits should not contain final measurements. PUB arrays broadcast; verify circuit parameter order before constructing large sweeps.
IBM QPU Sampling
This example assumes credentials were saved securely as described in references/setup.md. It never embeds or prints an API key.
from qiskit import QuantumCircuit
from qiskit.transpiler import generate_preset_pass_manager
from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2 as Sampler
service = QiskitRuntimeService()
backend = service.least_busy(
operational=True,
simulator=False,
min_num_qubits=2,
)
circuit = QuantumCircuit(2)
circuit.h(0)
circuit.cx(0, 1)
circuit.measure_all()
pass_manager = generate_preset_pass_manager(
backend=backend,
optimization_level=1,
seed_transpiler=7,
)
isa_circuit = pass_manager.run(circuit)
sampler = Sampler(mode=backend)
job = sampler.run([isa_circuit], shots=1024)
print("job_id:", job.job_id())
counts = job.result()[0].data.meas.get_counts()
Save the job ID before waiting for results so the job can be retrieved later.
IBM QPU Estimation
Runtime Estimator requires both an ISA circuit and observables mapped through the transpiler layout:
from qiskit import QuantumCircuit
from qiskit.quantum_info import SparsePauliOp
from qiskit.transpiler import generate_preset_pass_manager
from qiskit_ibm_runtime import EstimatorV2 as Estimator
circuit = QuantumCircuit(2)
circuit.h(0)
circuit.cx(0, 1)
observable = SparsePauliOp.from_list([("ZZ", 1.0)])
pass_manager = generate_preset_pass_manager(
backend=backend,
optimization_level=1,
seed_transpiler=7,
)
isa_circuit = pass_manager.run(circuit)
isa_observable = observable.apply_layout(isa_circuit.layout)
estimator = Estimator(
mode=backend,
options={"resilience_level": 1},
)
pub_result = estimator.run(
[(isa_circuit, isa_observable)],
precision=0.02,
).result()[0]
print(pub_result.data.evs, pub_result.data.stds)
Error mitigation is not guaranteed to improve every workload and increases cost. Record the complete options and result metadata.
Non-Negotiable Qiskit 2.x Rules
- Use V2 primitive interfaces and PUB inputs. Do not write new V1
Sampler,Estimator, orQuantumInstancecode. - Runtime primitives accept ISA circuits; they do not perform layout, routing, and basis translation for you.
- Apply the transpiler layout to Estimator observables with
observable.apply_layout(isa_circuit.layout). - Use
mode=backend,mode=session, ormode=batchfor Runtime primitives. - Use
EstimatorV2for resilience levels and expectation-value mitigation. Sampler has different noise-management options and no Estimator-style resilience levels. - Treat
BackendV2.target,backend.operation_names,backend.coupling_map, and direct backend attributes as the source of hardware constraints. Do not usebackend.configuration()orBackendProperties. - Read Sampler output by classical register name. Bitstrings are displayed most-significant bit first; Qiskit qubit 0 is conventionally the least-significant bit.
- Use a fixed
seed_transpilerwhen comparing compilation settings. A simulator seed does not make QPU results deterministic. qiskit.pulsewas removed in Qiskit 2.0. Use supported fractional gates for IBM hardware or Qiskit Dynamics for pulse-model research.- QPY is the Qiskit-native circuit serialization format. Do not use Python pickle for untrusted circuit artifacts.
See references/migration.md for a detailed old-to-current API map.
Execution Modes
Choose based on workload shape and account plan:
- Job mode: one-off work; instantiate a primitive with
mode=backend. - Batch mode: independent jobs submitted together; available on the Open Plan.
- Session mode: iterative jobs that benefit from prioritized follow-on execution; unavailable on the Open Plan.
from qiskit_ibm_runtime import Batch, SamplerV2 as Sampler
with Batch(backend=backend, max_time="10m") as batch:
sampler = Sampler(mode=batch)
jobs = [sampler.run([circuit], shots=1024) for circuit in isa_circuits]
results = [job.result() for job in jobs]
Close sessions and batches after submission. Exiting their context stops new submissions but allows accepted jobs to finish, subject to service limits.
Reference Map
Read only the files needed for the current task:
| Topic | Reference |
|---|---|
| Versions, installation, authentication, CI | references/setup.md |
| Circuits, parameters, control flow, QPY | references/circuits.md |
| V2 PUBs, broadcasting, local and Runtime results | references/primitives.md |
| Targets, ISA circuits, layouts, pass managers | references/transpilation.md |
| IBM backends, modes, jobs, Aer, mitigation | references/backends.md |
| End-to-end map/optimize/execute/analyze patterns | references/patterns.md |
| Algorithms, addons, Nature, ML, Optimization | references/algorithms.md |
| Circuit, result, state, and backend plots | references/visualization.md |
| Qiskit 0.x/1.x and Runtime migration | references/migration.md |
| Testing, reproducibility, and troubleshooting | references/testing.md |
| Upstream docs, release notes, and version baseline | references/sources.md |
Bundled Scripts
Run from the skill directory:
# Installed-package and legacy-environment checks; no network or credential reads
python scripts/check_environment.py
# Runnable V2 local Sampler and Estimator example
python scripts/run_local_primitives.py --shots 1024 --seed 7
# Read-only IBM backend capability inspection; uses saved credentials
python scripts/inspect_runtime.py --min-qubits 5
The Runtime inspection script selects or inspects a backend but never submits a quantum job.
Final Checklist
Before returning Qiskit code:
- Confirm package versions and Python compatibility.
- Run locally with statevector primitives or Aer.
- Verify parameter order, observable qubit count, and classical-register names.
- Transpile against the exact
BackendV2target and inspect depth and two-qubit operations. - Apply the final layout to every observable.
- Estimate QPU cost and choose job, batch, or session mode.
- Save job IDs, package versions, seeds, backend name, primitive options, and result metadata.
- Never expose API keys in source, logs, notebooks, or version control.
Alternatives
Compare before choosing
event4u-app/agent-config
design-review
Use when the user says "review the design", "check the UI", or wants a comprehensive UI/UX review. Uses a 7-phase methodology covering interaction, responsiveness, accessibility, and more.
K-Dense-AI/scientific-agent-skills
dask
Distributed computing for larger-than-RAM pandas/NumPy workflows. Use when you need to scale existing pandas/NumPy code beyond memory or across clusters. Best for parallel file processing, distributed ML, integration with existing pandas code. For out-of-core analytics on single machine use vaex; for in-memory speed use polars.
K-Dense-AI/scientific-agent-skills
medchem
Medicinal chemistry filters for compound triage. Apply drug-likeness rules (Lipinski, Veber, CNS), structural alert catalogs (PAINS, NIBR, ChEMBL), complexity metrics, and the medchem query language for library filtering.
K-Dense-AI/scientific-agent-skills
neurokit2
Use NeuroKit2 to build or audit reproducible research workflows for physiological time-series preprocessing, event/interval analysis, multimodal alignment, variability, and complexity. Trigger when code imports neurokit2 or needs its current APIs, schemas, and method-aware validation—not for diagnosis or device validation.