cairo-coding

Optimize Cairo code with patterns for loops, arithmetic, and limb assembly.

259|90|Updated Jan 2, 2023
One-click install
npx skills add https://github.com/keep-starknet-strange/garaga --skill cairo-coding
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cairo-coding
Source: https://github.com/keep-starknet-strange/garaga/tree/main/.claude/skills/cairo-coding
Command: npx skills add https://github.com/keep-starknet-strange/garaga --skill cairo-coding

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cairo development often struggles with performance and correctness: loops can be slow, arithmetic can be expensive, and limb assembly or storage packing can be error-prone. This skill provides proven patterns and rules to write and optimize Cairo code, reducing gas costs and improving reliability.

Core Features & Use Cases

  • Performance-focused patterns for arithmetic, loops, and limb packing.
  • Auditing guidance to identify bottlenecks and refactor for efficiency.
  • Real-world scenarios include optimizing BoundedInt usage, storage packing, and modular arithmetic in StarkNet contracts.

Quick Start

Install and run the included bounded_int_calc.py to generate BoundedInt implementations for your Cairo arithmetic needs.

Frequently Asked Questions about cairo-coding

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

FAQPage Schema
How do I optimize slow loops and expensive arithmetic in Cairo contracts?

You can optimize Cairo code by applying proven patterns and rules that refactor slow loops, expensive arithmetic, and inefficient limb assembly, reducing gas costs and improving execution reliability.

What is the best way to handle BoundedInt calculations in StarkNet?

Handling BoundedInt calculations in StarkNet involves using specific optimization patterns and generating implementations via a bounded integer calculation script to ensure modular arithmetic operates efficiently and correctly.

How do I audit StarkNet storage packing for efficiency bottlenecks?

Auditing StarkNet storage packing for efficiency bottlenecks requires applying specialized auditing guidance to identify expensive operations and refactor storage-slot packing for improved performance and correctness.

Can I use these optimization patterns for general Cairo tooling or only for StarkNet contracts?

You can use these optimization patterns for both StarkNet contracts and general Cairo tooling, as they apply broadly to performance profiling, modular arithmetic, and limb assembly across Cairo development.

Why does my Cairo modular arithmetic consume so much gas?

Cairo modular arithmetic consumes excessive gas when using inefficient limb assembly or unoptimized loops, which can be resolved by applying targeted performance-focused patterns to refactor the expensive arithmetic operations.