Agent skill

Gas Snapshot Testing

by ccashwell in ccashwell/evm-cortex

A skill your agent uses when tracking gas costs, detecting regressions in CI, or optimizing Solidity contracts.

MITAuto-check passedBackend & APIs

Install Gas Snapshot Testing

skills CLI
$ npx skills add ccashwell/evm-cortex --skill gas-snapshot-testing -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ccashwell/evm-cortex gas-snapshot-testing --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ccashwell/evm-cortex.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/gas-snapshot-testing .claude/skills/gas-snapshot-testing && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
gas-snapshot-testing
GitHub stars
131
Token cost
~1.4k tokens
SKILL.md length
183 words
Files
1
Skills in repo
89
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when tracking gas costs, detecting regressions in CI, or optimizing Solidity contracts.

  • Tracking gas costs
  • SKILL.md covers Overview, Creating Snapshots, Checking for Regressions in CI and Gas Report, plus 5 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Detecting regressions in CI

What it does

Gas Snapshot Testing is an agent skill from ccashwell/evm-cortex. Use when tracking gas costs, detecting regressions in CI, or optimizing Solidity contracts. Covers forge snapshot, gas reports, CI integration, and optimization techniques.

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Backend & APIs, covering Smart contracts. It works with Solidity. The repository describes itself as: Ethereum protocol engineering squad for AI coding assistants. The licence is MIT.

When your agent uses it

  • Tracking gas costs
  • Detecting regressions in CI
  • Optimizing Solidity contracts

Example prompts

  • “/gas-snapshot-testing”

What it can do on your machine

Read from SKILL.md and the folder at commit f8f3301. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are bash, solidity and yaml).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Gas Snapshot Testing loads about 1.4k tokens when it runs. Until then it costs about 48 tokens; SKILL.md has 183 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~48
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ccashwell/evm-cortex at commit f8f3301, republished under its MIT licence (© ccashwell). 183 words, ~1,411 tokens.

Download SKILL.mdSave it as .claude/skills/gas-snapshot-testing/SKILL.md (or your agent's skills folder).
name
gas-snapshot-testing
description
Use when tracking gas costs, detecting regressions in CI, or optimizing Solidity contracts. Covers forge snapshot, gas reports, CI integration, and optimization techniques.

Gas Snapshot Testing

Overview

Gas snapshots capture the gas cost of every test function and store them in .gas-snapshot. This file is committed to the repo and used in CI to detect gas regressions.

Creating Snapshots

bash
# Generate gas snapshot
forge snapshot

# Output stored in .gas-snapshot:
# MyContractTest:test_deposit() (gas: 45231)
# MyContractTest:test_withdraw() (gas: 38912)
# MyContractTest:test_transfer() (gas: 21453)

Checking for Regressions in CI

bash
# Compare current gas against committed snapshot
# Fails if any test uses more gas than recorded
forge snapshot --check

# Allow up to 5% increase
forge snapshot --tolerance 5

Gas Report

bash
# Detailed per-function gas breakdown
forge test --gas-report

# Output:
# | src/Vault.sol:Vault |                 |       |        |       |         |
# |---------------------|-----------------|-------|--------|-------|---------|
# | Function Name       | min             | avg   | median | max   | # calls |
# | deposit             | 45231           | 47892 | 45231  | 53214 | 12      |
# | withdraw            | 38912           | 40123 | 38912  | 42345 | 8       |

# Filter to specific contracts
forge test --gas-report --match-contract Vault

CI Integration

GitHub Actions
yaml
name: Gas Check
on: [pull_request]

jobs:
  gas:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: foundry-rs/foundry-toolchain@v1

      - name: Install dependencies
        run: forge install

      - name: Check gas snapshots
        run: forge snapshot --check --tolerance 3

      - name: Gas report
        run: forge test --gas-report | tee gas-report.txt

      - name: Comment gas report on PR
        uses: actions/github-script@v7
        if: github.event_name == 'pull_request'
        with:
          script: |
            const fs = require('fs');
            const report = fs.readFileSync('gas-report.txt', 'utf8');
            github.rest.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: `## Gas Report\n\`\`\`\n${report}\n\`\`\``
            });

Snapshot-Driven Development

bash
# 1. Create baseline snapshot
forge snapshot --snap .gas-snapshot-baseline

# 2. Make optimizations
# ... edit contracts ...

# 3. Compare against baseline
forge snapshot --diff .gas-snapshot-baseline

# Output shows differences:
# test_deposit() (gas: 45231 -> 42100) -3131 (-6.92%)
# test_withdraw() (gas: 38912 -> 38900) -12 (-0.03%)

Gas-Specific Test Patterns

solidity
contract GasTest is Test {
    MyContract target;

    function setUp() public {
        target = new MyContract();
        // Warm storage slots for realistic measurements
        target.initialize();
    }

    // Naming convention: gas_ prefix for benchmark tests
    function test_gas_deposit_firstTime() public {
        // Cold storage write — most expensive
        target.deposit(1 ether);
    }

    function test_gas_deposit_subsequent() public {
        target.deposit(1 ether); // warm up
        target.deposit(1 ether); // measure this
    }

    function test_gas_batchDeposit_10() public {
        for (uint256 i = 0; i < 10; i++) {
            target.deposit(1 ether);
        }
    }

    // Measure specific operations with gasleft()
    function test_gas_specificOperation() public {
        // Setup (not measured)
        target.deposit(1 ether);

        uint256 gasBefore = gasleft();
        target.withdraw(0.5 ether);
        uint256 gasUsed = gasBefore - gasleft();

        // Log for manual review
        emit log_named_uint("withdraw gas", gasUsed);

        // Assert gas bound
        assertLt(gasUsed, 50_000, "withdraw too expensive");
    }
}

Common Gas Optimizations

OptimizationGas SavedRisk
calldata over memory for external args200-2000None
Pack storage (multiple vars in one slot)2100 per cold SLOADReadability
Use uint256 over smaller uints0-30 per operationNone
Unchecked math (where overflow impossible)40-100 per opMust prove safety
Cache storage reads in memory100 per SLOADNone
Use custom errors over require strings200-5000 per revertCompatibility
immutable for constructor-set values2100 per readNone
solidity
// Before: 3 SLOADs
function getInfo() external view returns (uint256, uint256, uint256) {
    return (value1, value2, value3);
}

// After: cache in memory
function getInfo() external view returns (uint256 a, uint256 b, uint256 c) {
    a = value1;
    b = value2;
    c = value3;
}

// Unchecked math where overflow is impossible
function distribute(uint256 total, uint256 share) internal pure returns (uint256) {
    unchecked {
        return total / share; // share is validated > 0 by caller
    }
}

Checklist

  • .gas-snapshot committed to repo
  • CI runs forge snapshot --check on every PR
  • Tolerance threshold set appropriately (1-5%)
  • Separate gas benchmark tests from functional tests
  • Warm storage slots in setUp before measuring
  • Cold vs warm storage costs differentiated in benchmarks
  • Gas report reviewed for unexpected cost spikes after changes
  • Document accepted gas regression rationale in PR description

© ccashwell, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/gas-snapshot-testing of ccashwell/evm-cortex.

Open the folder on GitHubat commit f8f3301

Compare with similar skills

Gas Snapshot Testing next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Gas Snapshot Testing compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Gas Snapshot Testing this skillccashwell/evm-cortex131—~1.4kAutomated safety check: PassMIT
Fizz Convertpashov/skills1.2k2 repos~3.7kAutomated safety check: PassMIT
Feynman Auditor0xiehnnkta/nemesis-auditor2431 repos~11kAutomated safety check: PassMIT
Smart Contract Auditgreatpie/smart-contract-audit-skill101—~1.1kAutomated safety check: PassNone
RadarAuditware/radar154—~2.1kAutomated safety check: PassGPL-3.0
Solidity AuditorGabson0x/bountyforge442—~3.7kAutomated safety check: PassNone

Similar skills

  • Fizz Convert

    pashov/skills

    Convert English-language properties in PROPERTIES.md (produced by the Fizz skill) into Solidity assertions inside the existing fuzz harness, then flip their checkboxes.

    1.2k GitHub starsUsed in 2 repos~3.7k tokens
    Backend & APIsAuto-check passed
  • Feynman Auditor

    0xiehnnkta/nemesis-auditor

    Deep business logic bug finder using the Feynman technique. An agent skill from 0xiehnnkta/nemesis-auditor.

    243 GitHub starsUsed in 1 repo~11k tokens
    Backend & APIsAuto-check passed
  • Smart Contract Audit

    greatpie/smart-contract-audit-skill

    Script-backed, out-of-box auditing workflow for Solidity/EVM repositories based on EVMbench detect/patch/exploit methodology.

    101 GitHub stars~1.1k tokensUpdated 7 mo ago
    Backend & APIsAuto-check passed
  • Radar

    Auditware/radar

    Use radar for smart contract security analysis, AST generation, and detection template development.

    154 GitHub stars~2.1k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • Solidity Auditor

    Gabson0x/bountyforge

    Security audit of Solidity code while you develop. An agent skill from Gabson0x/bountyforge.

    442 GitHub stars~3.7k tokensUpdated 22 days ago
    Backend & APIsAuto-check passed
  • Add Explorer

    lidofinance/diffyscan

    Adds or repairs Diffyscan explorer API routing and response adapters for a new host, chain or payload format.

    142 GitHub stars~1k tokensUpdated 2 days ago
    Backend & APIsAuto-check passed

More from ccashwell/evm-cortex

All 89 skills in this repo
  • Xray Pre Audit

    ccashwell/evm-cortex

    A skill your agent uses when preparing for a security audit, performing reconnaissance on a new codebase, or creating a protocol overview.

    131 GitHub stars~25k tokensUpdated 9 days ago
    Auto-check passed
  • Aave Integration

    ccashwell/evm-cortex

    A skill your agent uses when integrating with Aave V3 for lending, borrowing, flash loans, or building on top of Aave markets.

    131 GitHub stars~1.3k tokensUpdated 9 days ago
    Auto-check passed
  • Access Control Patterns

    ccashwell/evm-cortex

    Access control design patterns for Solidity protocols. An agent skill from ccashwell/evm-cortex.

    131 GitHub stars~1.8k tokensUpdated 9 days ago
    Auto-check passed
  • Anvil Patterns

    ccashwell/evm-cortex

    A skill your agent uses when running a local Ethereum node with Anvil.

    131 GitHub stars~1.3k tokensUpdated 9 days ago
    Auto-check passed
  • Audit Breadth Scan

    ccashwell/evm-cortex

    A skill your agent uses when performing systematic breadth-first review of all contracts during a security audit.

    131 GitHub stars~1.4k tokensUpdated 9 days ago
    Auto-check passed
  • Audit Depth Analysis

    ccashwell/evm-cortex

    A skill your agent uses when performing deep analysis of specific findings or high-risk areas during a security audit.

    131 GitHub stars~1.6k tokensUpdated 9 days ago
    Auto-check passed

Works with

Categories

Questions about Gas Snapshot Testing

What does Gas Snapshot Testing do?

A skill your agent uses when tracking gas costs, detecting regressions in CI, or optimizing Solidity contracts. Gas Snapshot Testing is an agent skill from ccashwell/evm-cortex. Use when tracking gas costs, detecting regressions in CI, or optimizing Solidity contracts.

When should I use Gas Snapshot Testing?

Gas Snapshot Testing fits situations like: tracking gas costs; detecting regressions in CI; optimizing Solidity contracts.

How do I install Gas Snapshot Testing in Claude Code?

Run `npx skills add ccashwell/evm-cortex --skill gas-snapshot-testing -a claude-code`. Or copy the skill folder (skills/gas-snapshot-testing in ccashwell/evm-cortex) into .claude/skills/gas-snapshot-testing in your project. Claude Code loads it when a task matches its description.

How do I install Gas Snapshot Testing in Codex?

Run `npx skills add ccashwell/evm-cortex --skill gas-snapshot-testing -a codex`. Or copy the skill folder (skills/gas-snapshot-testing in ccashwell/evm-cortex) into .agents/skills/gas-snapshot-testing in your project. Codex loads it when a task matches its description.

Can I use Gas Snapshot Testing in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ccashwell/evm-cortex --skill gas-snapshot-testing -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/gas-snapshot-testing, .gemini/skills/gas-snapshot-testing, .github/skills/gas-snapshot-testing and .opencode/skills/gas-snapshot-testing in your project.

What does Gas Snapshot Testing need to run?

SKILL.md names no scripts, command-line tools or credentials: Gas Snapshot Testing is instructions for the agent only.

Does Gas Snapshot Testing access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Gas Snapshot Testing safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Gas Snapshot Testing use?

Gas Snapshot Testing is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Gas Snapshot Testing use?

About 1.4k tokens (SKILL.md is roughly 5.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Gas Snapshot Testing?

Skills that share tags, products or a category with Gas Snapshot Testing: Fizz Convert (pashov/skills, 1.2k stars), Feynman Auditor (0xiehnnkta/nemesis-auditor, 243 stars), Smart Contract Audit (greatpie/smart-contract-audit-skill, 101 stars) and Radar (Auditware/radar, 154 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Gas Snapshot Testing?

ccashwell (a GitHub user) maintains it in ccashwell/evm-cortex, which has 131 GitHub stars. The repository holds 89 skills in this directory. The repository was last updated on September 30, 2026.

Source: ccashwell/evm-cortex on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.