gas

gas is a command for coding agents from omermaksutii/RugProof. It costs 16 tokens per session (630 once invoked), scanned A, original, MIT.

A command for measuring and improving gas costs in Solidity projects. It runs a gas report, asks for optimization suggestions, and can optionally apply and measure approved patches.

In plain words
What is it for?
Use /gas to profile contract tests, find expensive storage and computation patterns, generate diffs, and compare gas usage after changes.
Why use it?
It replaces guesses about transaction cost with per-function measurements and before-and-after comparisons. It also flags unbounded loops that may cause denial-of-service problems.

Command

Part of the rugproof plugin — 35 commands, 23 agents 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 commands/omermaksutii/rugproof/gas
Clone the repo
git clone --depth 1 https://github.com/omermaksutii/RugProof

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

README.md
[![agentmods](https://agentmods.dev/badge/commands/omermaksutii/rugproof/gas.svg)](https://agentmods.dev/commands/omermaksutii/rugproof/gas)
Your own site
<a href="https://agentmods.dev/commands/omermaksutii/rugproof/gas"><img src="https://agentmods.dev/badge/commands/omermaksutii/rugproof/gas.svg" alt="Measured on agentmods" height="20"></a>
Per session 16 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 630 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.00016 $0.00630
Opus 5 $0.00008 $0.00315
Sonnet 5 $0.00003 $0.00126
Haiku 4.5 $0.00002 $0.00063

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

Security

Grade A, and why

gas 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 5d 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.

commands/gas.md · 73 lines

How it starts

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

/gas — gas profile and optimization

Procedure

Step 1 — Run forge gas report

mcp__forge-runner__gas_report()

Returns per-function gas costs from the existing test suite.

Step 2 — Identify expensive ops

Dispatch gas-optimizer subagent. It looks for:

  • Storage reads in loops — should be cached in memory
  • SSTORE on cold slots that could be merged into one slot (packing)
  • String revert reasons — use custom errors (error InsufficientBalance();)
  • Unbounded loops over storage
  • x = x + 1 instead of ++x / unchecked { ++x } in safe loops
  • Memory vs calldata for read-only function params (calldata is cheaper)
  • Public vs external for fns called only externally (external is cheaper)
  • Repeated keccak256 of constants — precompute
  • require over short-circuit when both sides are equally cheap
  • Bool storage flags — pack into bitfields if grouped
  • Modifier with body inlined vs reusable — inline can be cheaper

Step 3 — Generate suggestions

For each opportunity, produce a diff. Estimate gas saved using a benchmark test.

Step 4 — Apply and measure

If --apply, apply the patches and re-run gas report. Show before/after.

Step 5 — Output

Gas profile for src/Vault.sol:

  Function          Avg   Min   Max   Median
  deposit           147K  142K  158K  144K
  withdraw          203K  189K  225K  198K   ← top spender
  rebalance         412K  398K  431K  410K   ← top spender

Optimization opportunities:

  1. withdraw():
     - Cache `users[msg.sender]` in memory (called 4× in fn body)
     - Estimated savings: 8K gas/call
  2. rebalance():
     - Replace `string memory reason` with custom errors
     - Estimated savings: 12K gas/call
  3. Storage layout:
     - Pack `bool paused` + `uint8 feeRate` + `address admin` into one slot
     - Saves one SSTORE per init: 20K gas

Apply with --apply. Re-runs the gas report and shows deltas.

Notes

  • Don't sacrifice readability for marginal gas wins.
  • Avoid assembly optimizations unless gas savings are >10K and the code is well-commented.
  • Re-audit any gas-optimized code — assembly substitutions are a common bug source.

Read the full file on GitHub · 73 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. 5d ago First seen · 73 lines · 16 tokens per session scan A 5e81a63cdda2

Subscribe to this mod's changes

gas is a command published in the GitHub repository omermaksutii/RugProof (9 stars, last pushed 1mo ago), licensed MIT. It adds 16 tokens to every session and 630 once invoked, about $0.0001 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.