gas-optimizer

gas-optimizer is an agent for Claude Code from omermaksutii/RugProof. It costs 21 tokens per session (780 once invoked), scanned A, original, MIT.

A Solidity code review assistant focused on reducing gas, the fee paid to run operations on an Ethereum-compatible blockchain. It finds expensive code patterns and proposes concrete patches with estimated savings.

In plain words
What is it for?
Use it to inspect storage reads, loops, function parameters, errors, modifiers, inheritance, and repeated computations, then review suggested before-and-after changes.
Why use it?
It helps reduce transaction costs and can identify unbounded loops that may also make a function run out of gas and become unusable.

Agent for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: model in frontmatter.

Part of the rugproof plugin — 35 commands, 23 agents shipped together

Good fit Use it to inspect storage reads, loops, function parameters, errors, modifiers, inheritance, and repeated computations, then review suggested before-and-after changes.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/omermaksutii/rugproof/gas-optimizer
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.

Clone the repo
git clone --depth 1 https://github.com/omermaksutii/RugProof

Made for: Claude Code.

Or install rugproof, the plugin that ships this one along with the rest of its 35 commands, 23 agents.

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-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/agents/omermaksutii/rugproof/gas-optimizer/github.svg)](https://agentmods.dev/agents/omermaksutii/rugproof/gas-optimizer)
Your own site
<a href="https://agentmods.dev/agents/omermaksutii/rugproof/gas-optimizer"><img src="https://agentmods.dev/badge/agents/omermaksutii/rugproof/gas-optimizer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for gas-optimizer

Your own site · 80×15
<a href="https://agentmods.dev/agents/omermaksutii/rugproof/gas-optimizer"><img src="https://agentmods.dev/badge/agents/omermaksutii/rugproof/gas-optimizer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 21 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 780 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00021 $0.00780
Opus 5.5 $0.00008 $0.00312
Sonnet 5.5 $0.00004 $0.00156
Haiku 4.5 $0.00002 $0.00078

Measured 1mo ago against content hash f25cf636963e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

gas-optimizer 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 1mo 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.

agents/gas-optimizer.md · 84 lines

How it starts

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

You find gas-saving opportunities and produce diffs with estimated savings.

Approach

Read the contract. For each function over ~50 lines or any function with a gas cost > 100K, look for:

Storage

  • Cold SLOAD: reads in a loop → cache in memory.
  • Storage layout: pack adjacent same-width fields.
  • Bool flags grouped → bitfield.
  • Constant storage → use constant / immutable (lives in bytecode).

Computation

  • x = x + 1 → ++x (saves a stack-op).
  • Safe arithmetic in a bounded loop → unchecked { ++i; }.
  • keccak256 of constants → precompute as bytes32 constant.
  • Repeated function calls → cache result.

ABI

  • memory ↔ calldata for read-only params (calldata is cheaper).
  • public → external if only called externally.
  • require("string") → custom errors (error InsufficientBalance();).

Loops

  • Cache arr.length (don't reload on each iteration).
  • Avoid pushing to storage arrays in a loop if possible.
  • Bound loops by const if user-controlled input is unbounded → also a DoS fix.

Inheritance / Modifiers

  • Inline small one-use modifiers.
  • Avoid virtual on functions never overridden.

Estimate savings

For each opportunity:

  • Look up base costs (SLOAD = 2100 cold / 100 warm; SSTORE = 20K fresh / 5K modify; keccak256 = 30 + 6/word; etc.).
  • Estimate per-call savings.
  • Estimate per-deploy savings (e.g. custom errors save deploy bytecode).

Output

Gas opportunities for src/Vault.sol:

  1. Cache `users[msg.sender]` in withdraw() [lines 142-160]
     Pattern: 4× cold SLOAD on `users[msg.sender].balance`
     Savings: ~6.3K gas per call
     Patch:
       --- before
       +++ after
       @@ -140,5 +140,6 @@
       -    if (users[msg.sender].balance > 0 && users[msg.sender].locked == false) {
       -        uint256 amt = users[msg.sender].balance;
       +    User memory u = users[msg.sender];
       +    if (u.balance > 0 && !u.locked) {
       +        uint256 amt = u.balance;

  2. Replace string reverts with custom errors [whole file, 12 instances]
     Savings: ~50 gas per revert + ~3K deploy bytecode
     Patch: ...

  3. Pack `paused` (bool) + `feeRate` (uint8) + `admin` (address) into one slot
     Savings: 20K (avoid extra SSTORE), one less storage slot
     Caveat: this changes storage layout — ONLY safe if not upgradeable, or apply as part of a planned upgrade

Total estimated savings:
  deposit:       ~3K gas
  withdraw:      ~9K gas
  rebalance:    ~12K gas

Read the full file on GitHub · 84 lines

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. 1mo ago First seen · 84 lines · 21 tokens per session scan A f25cf636963e

Subscribe to this mod's changes

gas-optimizer is an agent published in the GitHub repository omermaksutii/RugProof (10 stars, last pushed 2mo ago), licensed MIT. It adds 21 tokens to every session and 780 once invoked, about $0.0001 per session on Opus 5.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 agents, from other repositories

README

Sub-agent definitions for Claude Code delegation.

s977043/river-review · 0 tokens

chainaware-gamefi-screener

Screens wallets connecting to a Web3 game or P2E (Play-to-Earn) platform using ChainAware's Behavioral Prediction MCP. Detects bot farms, multi-account cheaters, and reward abusers, then classifies legitimate players into experience tiers for matchmaking and calculates their P2E reward eligibility. Use this agent…

ChainAware/behavioral-prediction-mcp · 247 tokens

chainaware-marketing-director

Full-cycle marketing campaign orchestrator for Web3 platforms. Takes a wallet list (or single wallet), a plain-text platform description, and a campaign goal — then orchestrates ChainAware's specialist subagents to produce a complete Marketing Campaign Brief: segmented audience, prioritized leads, whale roster…

ChainAware/behavioral-prediction-mcp · 244 tokens

chainaware-airdrop-screener

Batch screens wallets for airdrop eligibility using ChainAware's Behavioral Prediction MCP. Automatically filters out bots, new addresses, and high-fraud wallets, then ranks the remaining eligible wallets by reputation score for fair, merit-based token allocation. Use this agent PROACTIVELY whenever a user provides a…

ChainAware/behavioral-prediction-mcp · 207 tokens

chainaware-governance-screener

DAO governance voter screening and voting weight calculation using ChainAware's Behavioral Prediction MCP. Returns a governance participation profile — experience tier, fraud risk, and a recommended voting weight multiplier — to help DAOs prevent Sybil attacks and reward quality participants. Use this agent…

ChainAware/behavioral-prediction-mcp · 234 tokens

chainaware-lead-scorer

Scores a wallet as a sales lead using ChainAware's Behavioral Prediction MCP. Returns a lead score (0–100), a lead tier (Hot / Warm / Cold / Dead), a conversion probability, and a recommended outreach angle — so sales and marketing teams know exactly which wallets to prioritise and how to approach them. Use this agent…

ChainAware/behavioral-prediction-mcp · 253 tokens