gas-optimization

gas-optimization is a skill for Claude Code, Codex from 0xendale/evm-agent-toolkit. It costs 72 tokens per session (1,473 once invoked), scanned A, original, MIT.

A guide for reducing the gas cost of Solidity, Vyper, and Yul smart contracts. Gas is the fee paid to run operations on a blockchain.

In plain words
What is it for?
Finding expensive storage access, loops, data handling, and deployment code, then testing whether each proposed change is actually cheaper.
Why use it?
It focuses on measured cost reductions while checking that the contract still behaves exactly as before.

Skill for Claude CodeCodex

Part of the evm-agent-toolkit plugin — 3 skills, 1 MCP server shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/0xendale/evm-agent-toolkit/gas-optimization
Any agent
npx skills add 0xendale/evm-agent-toolkit --skill gas-optimization
Clone the repo
git clone --depth 1 https://github.com/0xendale/evm-agent-toolkit

Made for: Claude Code, Codex.

Or install evm-agent-toolkit, the plugin that ships this one along with the rest of its 3 skills, 1 MCP server.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for gas-optimization

README.md
[![agentmods](https://agentmods.dev/badge/skills/0xendale/evm-agent-toolkit/gas-optimization.svg)](https://agentmods.dev/skills/0xendale/evm-agent-toolkit/gas-optimization)
Your own site
<a href="https://agentmods.dev/skills/0xendale/evm-agent-toolkit/gas-optimization"><img src="https://agentmods.dev/badge/skills/0xendale/evm-agent-toolkit/gas-optimization.svg" alt="Measured on agentmods" height="20"></a>
Per session 72 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,473 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00072 $0.01473
Opus 5 $0.00036 $0.00737
Sonnet 5 $0.00014 $0.00295
Haiku 4.5 $0.00007 $0.00147

Measured 4d ago against content hash 86dbba827c4f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

gas-optimization scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/gas-optimization/SKILL.md · 72 lines

How it starts

The opening of the file, as written. The whole thing — 72 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Gas Optimization

Overview

Reduce the gas a contract spends without changing its observable behavior. Every proposed saving is a hypothesis until measured. The core discipline is: find candidates, rewrite one at a time, prove the behavior is unchanged, and prove the gas actually went down — discard anything that fails either proof.

The Iron Rule: never claim a gas saving you have not measured. A rewrite that "should" be cheaper but isn't, or that subtly changes behavior, is a regression. No exceptions for "obvious" wins.

When to Use

  • Lowering deployment or runtime gas of Solidity/Vyper/Yul contracts
  • Symptoms: "gas too high", expensive SSTORE/SLOAD, large for loops, structs with many fields, string memory/bytes memory external args, repeated .length reads, i++ in loops
  • Considering unchecked, constant/immutable, mappings-over-arrays, bitwise tricks, or transient storage

Do NOT use for: correctness bugs or security audits (use vulnerability-scanning), or micro-tweaks to code that isn't on a hot path and isn't deployed at scale — readability usually wins there.

Workflow

Run these four steps in order. They are reasoning steps you perform, not scripts.

  1. Seek — Read the target contract and match it against the known waste patterns in reference/patterns.md. List every candidate with its location. Ground every later idea in the EVM cost facts in reference/cost-model.md.
  2. Innovate — For each candidate, propose one concrete rewrite. You may also propose novel rewrites beyond the library, but only if you can name the exact opcode/cost reason it's cheaper. Reject ideas you cannot justify from the cost model.
  3. Execute — Apply rewrites one at a time, then verify each (see below). If verification fails, revert that rewrite and move on. Do not batch unverified changes.
  4. Manage — After the loop, report each accepted change: location, pattern, measured gas delta (before → after), and any behavioral caveat. Be honest about rewrites you discarded and why.

Read the full file on GitHub · 72 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 72 lines · 72 tokens per session scan A 86dbba827c4f

Subscribe to this mod's changes

gas-optimization is a skill published in the GitHub repository 0xendale/evm-agent-toolkit (1 stars, last pushed 1mo ago), licensed MIT. It adds 72 tokens to every session and 1,473 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

ethereum-development

Production-grade Ethereum/EVM development workflow for smart contracts, dApps, transactions, clients, gas optimization, testing, security review, deployment, verification, monitoring, and incident response across Foundry, Hardhat, Solidity, TypeScript, viem, ethers, wagmi, and common EVM networks.

dirtybits/agent-skills · 64 tokens

Gas Optimizer

Advanced gas optimization tool for Ethereum and EVM-compatible chains. Analyzes transactions, simulates gas usage, suggests optimal gas prices, batches transactions, and implements gas-saving patterns for smart contract interactions.

XSpoonAi/spoon-awesome-skill · 44 tokens

evm-bytecode-analysis

Analyze supplied deployed EVM runtime bytecode with EVMole or guide a separate application in integrating a published EVMole Rust, Go, Python, or JavaScript binding. Use for unverified-contract inspection, ABI reconstruction from runtime code, selector discovery, storage-access analysis, EVM control-flow inspection…

cdump/evmole · 135 tokens

web3-bug-classes

Complete reference for all 10 DeFi smart contract bug classes. Use this when hunting for specific vulnerability types, need attack patterns for accounting desync, access control, incomplete path, off-by-one, oracle manipulation, ERC4626 vaults, reentrancy, flash loans, signature replay, or proxy/upgrade bugs.

Awarexone/web3-bug-bounty-hunting-ai-skills · 72 tokens

web3-methodology-research

External research synthesis from Trail of Bits, SlowMist, ConsenSys, Immunefi, and Cyfrin. Use this for advanced audit methodology, Echidna/Medusa fuzzing setup, Slither custom detector writing, attack pattern deep dives, or the 4-phase learning roadmap.

Awarexone/web3-bug-bounty-hunting-ai-skills · 66 tokens

web3-poc-foundry

Complete Foundry PoC writing guide + all cheatcodes + DeFiHackLabs reproduction patterns. Use this when building a proof of concept exploit, setting up a fork test, using Foundry cheatcodes, or reproducing a known DeFi hack for learning.

Awarexone/web3-bug-bounty-hunting-ai-skills · 59 tokens