noir-optimize-acir
Optimizes Noir programs by measuring ACIR circuit size and opcode counts through benchmarking and recompilation.
Install
mkdir -p .claude/skills/noir-optimize-acir && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/3059" && unzip -o skill.zip -d .claude/skills/noir-optimize-acir && rm skill.zipInstalls to .claude/skills/noir-optimize-acir
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Workflow for measuring and optimizing the ACIR circuit size of a constrained Noir program. Use when asked to optimize a Noir program's gate count or circuit size.Key capabilities
- →Measure ACIR circuit gate count
- →Benchmark proving time
- →Analyze ACIR opcodes
- →Optimize circuit size
- →Export library function circuits
How it works
It uses nargo to compile programs and the bb CLI to measure gate counts, allowing for iterative optimization based on circuit size metrics.
Inputs & outputs
When to use noir-optimize-acir
- →Measure circuit gate count
- →Optimize noir program
- →Benchmark proving time
- →Analyze ACIR opcodes
About this skill
ACIR Optimization Loop
This workflow targets ACIR circuit size for constrained Noir programs. It does not apply to unconstrained (Brillig) functions — Brillig runs on a conventional VM where standard profiling and algorithmic improvements apply instead, and bb gates won't reflect Brillig performance.
Measuring Circuit Size
Binary projects
Compile the program and measure gate count with:
nargo compile && bb gates -b ./target/<package>.json
Library projects
Libraries cannot be compiled with nargo compile. Instead, mark the functions you want to measure with #[export] and use nargo export:
nargo export && bb gates -b ./export/<function_name>.json
Artifacts are written to the export/ directory and named after the exported function (not the package).
If bb is not available, ask the user for their backend's equivalent command. Other backends should have a similar CLI interface.
The output contains two fields:
circuit_size: the actual gate count after backend compilation. This determines proving time, which is generally the bottleneck.acir_opcodes: number of ACIR operations. This affects execution time (witness generation). A change can reduce opcodes without affecting circuit size or vice versa — both matter, but prioritizecircuit_sizewhen they conflict.
Always record a baseline of both metrics before making changes.
Optimization Loop
- Baseline: compile and record
circuit_size. - Apply one change at a time.
- Recompile and measure: compare
circuit_sizeto the baseline. - Revert if worse: if
circuit_sizeincreased or stayed the same, undo the change. Not every "optimization" helps — the compiler may already handle it, or the overhead of the new approach may outweigh the savings. - Repeat from step 2 with the next candidate change.
What to Try
Candidate optimizations roughly ordered by impact:
- Hint and verify: replace expensive in-circuit computation with an unconstrained hint and constrained verification. This is the highest-impact optimization for most programs.
- Reduce what you hint: if you're hinting intermediate values (selectors, masks, indices), see if you can hint only the final result and verify it directly.
- Hoist assertions out of branches: replace
if c { assert_eq(x, a) } else { assert_eq(x, b) }withassert_eq(x, if c { a } else { b }). - Simplify comparisons: inequality checks (
<,<=) cost more than equality (==). But don't introduce extra state to avoid them — measure first.
What Not to Try
- Don't hint division or modular arithmetic: the compiler already injects unconstrained helpers for these.
- Don't hand-roll conditional selects:
if/elseexpressions compile to the same circuit asc * (a - b) + b. - Don't replace
<=with flag tracking without measuring: adding mutable state across loop iterations can produce more gates than a simple comparison.
When not to use it
- →Unconstrained Brillig functions
- →Non-Noir programs
Prerequisites
Limitations
- →Does not apply to unconstrained functions
- →Requires bb CLI availability
How it compares
It provides a quantitative feedback loop for circuit optimization rather than relying on manual estimation.
Compared to similar skills
noir-optimize-acir side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| noir-optimize-acir (this skill) | 1 | 3mo | Review | Intermediate |
| godot-gdscript-patterns | 57 | 4mo | No flags | Intermediate |
| angular | 100 | 4mo | Review | Advanced |
| cpp-pro | 18 | 4mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by noir-lang
View all by noir-lang →You might also like
godot-gdscript-patterns
sickn33
Master Godot 4 GDScript patterns including signals, scenes, state machines, and optimization. Use when building Godot games, implementing game systems, or learning GDScript best practices.
angular
sickn33
Modern Angular (v20+) expert with deep knowledge of Signals, Standalone Components, Zoneless applications, SSR/Hydration, and reactive patterns. Use PROACTIVELY for Angular development, component architecture, state management, performance optimization, and migration to modern patterns.
cpp-pro
sickn33
Write idiomatic C++ code with modern features, RAII, smart pointers, and STL algorithms. Handles templates, move semantics, and performance optimization. Use PROACTIVELY for C++ refactoring, memory safety, or complex C++ patterns.
web-games
davila7
Web browser game development principles. Framework selection, WebGPU, optimization, PWA.
agent-v3-performance-engineer
ruvnet
Agent skill for v3-performance-engineer - invoke with $agent-v3-performance-engineer
game-patterns
JasonXuDeveloper
Zero-GC game patterns with JEngine using modern C# 9+. Triggers on: game loop, spawn system, wave spawner, cooldown, ability timer, damage over time, DoT, health regen, bullet pool, enemy pool, object pool pattern, projectile system, combat system, zero allocation, no GC, performance optimization