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.
npx agentmods add skills/zaryab2000/decipher-gas-optimizoor/loop-optimizationnpx skills add zaryab2000/decipher-gas-optimizoor --skill loop-optimizationgit clone --depth 1 https://github.com/zaryab2000/decipher-gas-optimizoorWrote 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.
[](https://agentmods.dev/skills/zaryab2000/decipher-gas-optimizoor/loop-optimization)<a href="https://agentmods.dev/skills/zaryab2000/decipher-gas-optimizoor/loop-optimization"><img src="https://agentmods.dev/badge/skills/zaryab2000/decipher-gas-optimizoor/loop-optimization.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00103 | $0.01807 |
| Opus 5 | $0.00051 | $0.00903 |
| Sonnet 5 | $0.00021 | $0.00361 |
| Haiku 4.5 | $0.00010 | $0.00181 |
Grade A, and why
loop-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.
How it starts
The opening of the file, as written. The whole thing — 157 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Purpose
Find and fix gas inefficiencies in Solidity loop constructs. Every per-iteration cost multiplies linearly — 100 iterations × 100 gas = 10,000 gas. Loop bodies are the highest-leverage location for gas optimization in Solidity contracts.
When to Use
- Writing or reviewing any
fororwhileloop in a Solidity contract - Auditing contracts for gas efficiency before deployment
- Responding to gas reports showing high per-call cost on functions with loops
- Reviewing contract code in Foundry-based projects (
forge test --gas-report)
When NOT to Use
- Memory arrays:
.lengthon a memory array is an MLOAD — already cheap; no caching needed - Single-iteration loops: constant overhead savings (LO-003/LO-004) are not worth the noise
- Loops with external calls that modify state: caching storage before such a loop risks stale values
- Loops that modify the array length: never cache
.lengthif the loop body callspush()orpop() - Solidity 0.8.22+ with simple counters: the compiler auto-skips overflow checks; LO-003 is redundant (but harmless — apply anyway for version-agnostic code)
Rationalizations to Reject
| Claim | Why it is wrong | Correct action |
|---|---|---|
| "The loop is small" | Per-iteration costs multiply linearly — 100 iterations × 100 gas = 10,000 gas | Apply all loop optimizations regardless of loop size |
| "The compiler handles caching" | Solidity does not cache storage reads across iterations; each loop iteration pays SLOAD cost | Explicitly cache all loop-invariant storage reads before the loop |
| "It already has unchecked" | unchecked on the counter does not cache the length or body storage reads | Apply LO-001 + LO-002 + LO-003 together; they are independent savings |
Platform Detection
# Confirm Foundry is available
forge --version
# Run gas report to find expensive loop functions
forge test --gas-report
# Trace SLOAD count in a specific loop function
forge test --match-test <testName> -vvvv | grep SLOAD
What ships with it
3 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.
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.
- 4d ago First seen · 157 lines · 103 tokens per session scan A bdc7474e8969
loop-optimization is a skill published in the GitHub repository zaryab2000/decipher-gas-optimizoor (7 stars, last pushed 6mo ago), licensed MIT. It adds 103 tokens to every session and 1,807 once invoked, about $0.0005 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.
Other skills, from other repositories
solidity-gas-optimizer
Analyze and optimize gas consumption in Solidity smart contracts using proven patterns and best practices.
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.
pentagonal-clawd
Use when the user asks to create, generate, build, audit, fix, compile, or look up smart contracts and tokens. Pentagonal Clawd is a sovereign smart contract forge and token intelligence platform with AI-powered 8-agent security pen testing across Ethereum, Solana, Polygon, Base, Arbitrum, Optimism, and BSC.
solidity-language-docs
Solidity 0.8.36 — smart contracts, types, functions, modifiers, events, inheritance, libraries, assembly, ABI.
pentagonal
Smart contract security auditor and deployment assistant. Generates, audits, and deploys Solidity/Rust smart contracts with AI-powered vulnerability detection across EVM and Solana chains.
blockchain-expert
Expert-level blockchain, Web3, smart contracts, DeFi, and cryptocurrency development.