gas-optimize

Analyzes Solidity contracts and produces ranked gas optimization recommendations with before/after code.

Updated Apr 3, 2026
One-click install
npx skills add https://github.com/Ayoub-ouederni/SENTINEL --skill gas-optimize-ayoub-ouederni
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gas-optimize
Source: https://github.com/Ayoub-ouederni/SENTINEL/tree/main/.claude/skills/gas-optimize
Command: npx skills add https://github.com/Ayoub-ouederni/SENTINEL --skill gas-optimize-ayoub-ouederni

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Solidity developers often ship contracts with inefficient storage layouts, redundant SLOADs, and suboptimal data structures that inflate transaction costs for every user. This Skill audits a contract and produces a prioritized gas optimization report with concrete savings estimates. ## Core Features & Use Cases - Ranked Optimization Report: Findings grouped by impact (high/medium/low) with file:line references, before/after code, and estimated gas savings per technique. - Comprehensive Coverage: Storage packing, caching, constant/immutable usage, mappings vs arrays, calldata vs memory, unchecked arithmetic, compiler optimizer settings, and L2-specific calldata considerations. - Use Case: Before deploying a DeFi contract to mainnet, run the analysis to discover that reordering state variables eliminates two storage slots and caching an oracle price saves thousands of gas per call. ## Quick Start Analyze MyToken.sol for gas optimization opportunities and show the highest-impact fixes with before and after code.

Frequently Asked Questions about gas-optimize

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

FAQPage Schema
How do I reduce gas costs in a Solidity contract?

Start with storage optimizations: pack variables into fewer slots, cache repeated storage reads in local variables, and use constant or immutable where possible. Then review data structures, external call caching, and unchecked arithmetic for loop counters.

What are the highest-impact Solidity gas optimizations?

Storage layout changes have the highest impact since SSTORE costs up to 20,000 gas and SLOAD costs 2,100 gas. Variable packing, struct packing, and replacing storage writes with events can save tens of thousands of gas per transaction.

Does gas optimization differ between L1 and L2 networks?

Yes. On L2 rollups, calldata posted to L1 dominates costs while storage operations are relatively cheaper, so minimizing parameter sizes matters more. Standard optimizations still apply, but techniques like events-over-storage have reduced ROI on L2.

When should I use assembly for gas optimization in Solidity?

Only when a function is on an extremely hot path, savings exceed roughly 500 gas per call, and the logic is simple enough to audit. All assembly recommendations should be flagged for security review since they bypass compiler safety checks.

How do optimizer runs in foundry.toml affect gas costs?

Low runs (around 200) optimize for cheaper deployment with slightly more expensive execution, while high runs (10,000+) reduce execution cost at the expense of deployment. Match the setting to expected call frequency of the contract.