Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Cirq Quantum Circuits

ASecurity

Designing, simulating, and optimizing quantum circuits using Google Cirq and TensorFlow Quantum. Use when building grid-qubit layouts, custom gate definitions, noisy density matrix simulations (Cirq Simulator), Sycamore hardware topologies, or quantum machine learning models.

8 stars
0 votes
0 copies
0 views
Added 9/29/2026
ai-agentspythongo

Security Analysis

A100/100

Scanned 9/29/2026

$npx -y skills add hamzabellouch/agent-skills --skill cirq-quantum-circuits --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cirq Quantum Circuits?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Cirq Quantum Circuits
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hamzabellouch-cirq-quantum-circuits/badge)](https://www.skillsdirectory.com/skills/hamzabellouch-cirq-quantum-circuits)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: cirq-quantum-circuits
metadata:
  category: Quantum Computing and Quantum AI
description: Designing, simulating, and optimizing quantum circuits using Google Cirq and TensorFlow Quantum. Use when building grid-qubit layouts, custom gate definitions, noisy density matrix simulations (Cirq Simulator), Sycamore hardware topologies, or quantum machine learning models.
compatibility: Cirq 1.2+, Python 3.10+, TensorFlow Quantum (TFQ), NumPy, SciPy
---

# Cirq Quantum Circuit Engineering Guidelines

This skill covers Google Cirq circuit architecture, GridQubit topology mapping, custom unitary gate definition, noisy density matrix simulation, and optimization routines for NISQ processors like Google Sycamore.

---

## 1. Cirq Fundamentals & Grid Topology

Cirq is engineered around physical hardware geometry using 2D grid placement (`cirq.GridQubit`):

```
                   cirq.GridQubit(0, 1)
                            |
   cirq.GridQubit(1, 0) -- cirq.GridQubit(1, 1) -- cirq.GridQubit(1, 2)
                            |
                   cirq.GridQubit(2, 1)
```

### 1.1 Creating Parametric Entangled Circuits

```python
import cirq
import sympy
import numpy as np

def create_sycamore_entangled_circuit(rows: int = 2, cols: int = 2) -> cirq.Circuit:
    # 1. Define Grid Qubits
    qubits = [cirq.GridQubit(r, c) for r in range(rows) for c in range(cols)]
    
    # 2. Symbolic Parameter for Variational Rotation
    theta = sympy.Symbol('theta')
    phi = sympy.Symbol('phi')
    
    circuit = cirq.Circuit()

    # Layer 1: Single Qubit Rotations
    circuit.append([cirq.H(q) for q in qubits])
    circuit.append([cirq.ry(theta).on(q) for q in qubits])

    # Layer 2: Entangling CZ Gates along adjacent Grid Neighbors
    circuit.append(cirq.CZ(qubits[0], qubits[1]))
    circuit.append(cirq.CZ(qubits[1], qubits[3]))
    circuit.append(cirq.CZ(qubits[2], qubits[3]))

    # Layer 3: Parametric Phase Rotations & Measurements
    circuit.append([cirq.rz(phi).on(q) for q in qubits])
    circuit.append([cirq.measure(q, key=f"q_{q.row}_{q.col}") for q in qubits])

    return circuit, qubits
```

---

## 2. Noisy Density Matrix Simulation (`cirq.DensityMatrixSimulator`)

Simulating real-world quantum hardware noise (depolarizing, amplitude damping) requires density matrix operations:

```python
import cirq

def simulate_noisy_circuit(circuit: cirq.Circuit, noise_probability: float = 0.02):
    """Applies depolarizing noise channel to 2-qubit operations and simulates results."""
    # 1. Define Noise Model
    noise_model = cirq.depolarize(p=noise_probability)
    
    # 2. Insert Noise Channel after 2-qubit gates
    noisy_circuit = circuit.with_noise(noise_model)
    
    # 3. Simulate using Density Matrix Simulator
    simulator = cirq.DensityMatrixSimulator()
    result = simulator.run(noisy_circuit, repetitions=1000)
    
    # Calculate Measurement Histogram
    histogram = result.histogram(key='q_0_0')
    print("Measurement Counts (q_0_0):", histogram)
    return result
```

---

## 3. Custom Gate Definition & Unitary Verification

Create domain-specific custom gates by extending `cirq.Gate`:

```python
import cirq
import numpy as np

class CustomSqrtISWAPGate(cirq.Gate):
    """Custom implementation of sqrt(iSWAP) gate."""
    def __init__(self):
        super().__init__()

    def _num_qubits_(self) -> int:
        return 2

    def _unitary_(self) -> np.ndarray:
        return np.array([
            [1, 0, 0, 0],
            [0, 1/np.sqrt(2), 1j/np.sqrt(2), 0],
            [0, 1j/np.sqrt(2), 1/np.sqrt(2), 0],
            [0, 0, 0, 1]
        ], dtype=np.complex128)

    def _circuit_diagram_info_(self, args: cirq.CircuitDiagramInfoArgs) -> str:
        return ("√iSWAP", "√iSWAP")

# Usage Example
q0, q1 = cirq.LineQubit.range(2)
custom_gate = CustomSqrtISWAPGate()
circuit = cirq.Circuit(custom_gate.on(q0, q1))
print("Custom Gate Circuit:\n", circuit)
```

---

## 4. Anti-Patterns & Critical Pitfalls

| Anti-Pattern | Severity | Consequence | Correct Pattern |
|---|---|---|---|
| Applying 2-qubit gates on non-adjacent `GridQubit`s | Critical | Hardware compilation failure on Google Sycamore | Enforce topological adjacency checks (`cirq.is_adjacent`) |
| Unbound Symbolic Variables (`sympy.Symbol`) | High | Simulator Runtime Crash during `.run()` | Resolve parameters via `cirq.ParamResolver({'theta': 0.5})` |
| Using `cirq.Simulator` for channels with noise | Medium | Noise channels silently ignored | Use `cirq.DensityMatrixSimulator()` for noisy channels |
| Over-allocating statevector simulation (>28 qubits) | High | Host system RAM exhaustion (OOM crash) | Use tensor network simulators (`qsimcirq`) for large circuits |

---

## 5. Verification Checklist

- [ ] **Grid Alignment Check**: Confirm all 2-qubit gates connect physically adjacent grid qubits.
- [ ] **Parameter Resolution**: Test parameter sweep resolution using `cirq.Sweepable`.
- [ ] **Gate Unitary Sanity**: Verify `cirq.has_unitary(gate)` returns `True` for custom gates.

Attribution

hamzabellouchhamzabellouch
View sourceSee grades on GitHubMore from hamzabellouch →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698621 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →