cairo-optimization

Profile Cairo code hotspots and apply targeted performance optimizations.

Updated Apr 3, 2026
One-click install
npx skills add https://github.com/cartridge-gg/scoundrel --skill cairo-optimization
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: cairo-optimization
Source: https://github.com/cartridge-gg/scoundrel/tree/main/.agents/skills/cairo-optimization
Command: npx skills add https://github.com/cartridge-gg/scoundrel --skill cairo-optimization

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Improve Cairo performance after correctness is established by profiling hotspots, rewriting expensive loops/arithmetic, and hardening bounded-int usage.

Core Features & Use Cases

  • Hotspot profiling to identify costly code paths in Cairo contracts.
  • Arithmetic/loop optimization patterns to reduce gas and runtime.
  • Storage layout improvements and bounded-int hardening to improve safety and efficiency.
  • Reference to a structured workflow and benchmarking guidance.

Quick Start

Profile the target code with the profiling tool, apply one optimization class at a time, and re-run tests to quantify resource changes.

Frequently Asked Questions about cairo-optimization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When do I need to harden bounded-int usage in Cairo programs?▼

Harden bounded-int usage when profiling reveals arithmetic hotspots or when optimizing storage layout. It improves both safety and execution efficiency in Cairo contracts.

How do I profile Cairo code to find performance bottlenecks?▼

Profiling Cairo code identifies costly hot paths and loops by measuring runtime resource usage. You profile the target contract with a profiling tool to pinpoint exact hotspots before applying targeted performance improvements.

What is the best way to reduce gas consumption in Cairo contracts?▼

Reducing gas requires profiling hotspots and rewriting expensive loops and arithmetic. Storage layout improvements and bounded-int hardening further optimize efficiency while maintaining safety.

How do I optimize Cairo loops after verifying correctness?▼

After verifying correctness, apply one optimization class at a time to Cairo loops or arithmetic. Re-run tests and benchmarks after each change to quantify resource reductions and ensure no regressions are introduced.

Why does my optimized Cairo code fail tests after reducing gas?▼

Failing tests usually indicate correctness was broken by applying multiple optimizations simultaneously. Iterate one optimization class at a time and validate results against tests after each change to isolate regressions.

When do I need to harden bounded-int usage in Cairo programs?▼

Harden bounded-int usage when profiling reveals arithmetic hotspots or when optimizing storage layout. It improves both safety and execution efficiency in Cairo contracts.