explain

explain is a command for coding agents from zaryab2000/decipher-gas-optimizoor. It costs 0 tokens per session (672 once invoked), scanned A, original, MIT.

A command for explaining one named Solidity gas-optimization pattern using the Ethereum Virtual Machine, the system that runs smart contracts. It returns the concept, the underlying operation, exact gas figures, a before-and-after example, and cases where the change should not be made.

In plain words
What is it for?
Use it to explain patterns such as storage reads, packed slots, unchecked arithmetic, custom errors, calldata, visibility, immutable values, loop caching, and unbounded loops.
Why use it?
It turns an optimization suggestion into a concrete explanation of what the contract and EVM are doing. This helps developers judge both the expected gas difference and the situations where the pattern is unsafe or unsuitable.

Command

Part of the decipher-gas-optimizoor plugin — 11 skills, 5 commands, 1 agent 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/zaryab2000/decipher-gas-optimizoor/explain
Clone the repo
git clone --depth 1 https://github.com/zaryab2000/decipher-gas-optimizoor

Or install decipher-gas-optimizoor, the plugin that ships this one along with the rest of its 11 skills, 5 commands, 1 agent.

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 explain

README.md
[![agentmods](https://agentmods.dev/badge/commands/zaryab2000/decipher-gas-optimizoor/explain.svg)](https://agentmods.dev/commands/zaryab2000/decipher-gas-optimizoor/explain)
Your own site
<a href="https://agentmods.dev/commands/zaryab2000/decipher-gas-optimizoor/explain"><img src="https://agentmods.dev/badge/commands/zaryab2000/decipher-gas-optimizoor/explain.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 672 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.00000 $0.00672
Opus 5 $0.00000 $0.00336
Sonnet 5 $0.00000 $0.00134
Haiku 4.5 $0.00000 $0.00067

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

Security

Grade A, and why

explain 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/explain.md · 46 lines

How it starts

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

/decipher-gas-optimizoor:explain

Explain the EVM mechanic behind a specific gas optimization pattern with exact cost numbers, before/after code, and when NOT to apply it.

Accepted patterns

cold-sload | slot-packing | unchecked | custom-errors | calldata | external-vs-public | immutable | loop-caching | unbounded-loop

If the user supplies an unknown pattern, respond:

Unknown pattern "[X]". Accepted patterns: cold-sload, slot-packing, unchecked, custom-errors, calldata, external-vs-public, immutable, loop-caching, unbounded-loop


Output format (use for every pattern)

Produce exactly five sections:

  1. What it is — one sentence.
  2. The EVM mechanic — why the naive code is expensive at the opcode level.
  3. Gas cost difference — exact numbers in a table.
  4. Before / after example — minimal Solidity snippets.
  5. When NOT to apply — concrete conditions.

Pattern stubs

Use these as anchors; fill in from your knowledge of EVM gas mechanics.

Pattern Core mechanic Key numbers
cold-sload First SLOAD in a tx costs 2,100 gas (EIP-2929); warm = 100; MLOAD = 3 Cache to local var: 2,100 → 3 gas per subsequent read
slot-packing Each 32-byte storage slot = one SSTORE/SLOAD; fields share a slot if they fit Cold SSTORE 22,100 gas/slot; saving 1 slot = 22,100 gas on first write
unchecked Solidity 0.8+ emits ISZERO+JUMPI after every arithmetic op ~30 gas/op; safe only when overflow is provably impossible
custom-errors require(c,"str") ABI-encodes full string; custom error = 4-byte selector ~15–50 gas/revert + ~200 gas × string_bytes at deployment
calldata memory param triggers CALLDATACOPY (3 gas/byte); calldata reads directly ~3 gas/byte saved; for 10-element bytes32[] = ~960 gas
external-vs-public public generates internal+external entry points; external skips internal ~24 gas/call (scalar); thousands for array params via calldata
immutable Immutable values baked into deployed bytecode as PUSH32 ~3 gas/read vs 2,100 gas cold SLOAD; use when set once in constructor
loop-caching Storage reads inside loops pay 100 gas (warm) per iteration Cache before loop: 2,100 gas once + 3 gas × N vs 100 gas × N
unbounded-loop Block gas limit ~30M; cold-storage loop: max ~14,285 iterations before DoS Not a per-call saving — a correctness risk; fix with pagination or pull pattern

Read the full file on GitHub · 46 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 · 46 lines · 0 tokens per session scan A fced36386f9d

Subscribe to this mod's changes

explain is a command published in the GitHub repository zaryab2000/decipher-gas-optimizoor (7 stars, last pushed 6mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 672 tokens. 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.