foundry-cheatcodes

A reference guide to Foundry VM cheatcodes for testing Ethereum smart contracts. These commands let Forge tests change blockchain state or simulate conditions such as different callers and external responses.

In plain words
What is it for?
Write or debug tests that change time, block numbers, fees, balances, storage, and forks; fake callers; expect errors or events; and mock contract calls.
Why use it?
It removes the need to remember which test command is used for each simulated blockchain condition.

Skill for Claude CodeCodex

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 skills/hirama/solidity-agentic-stack/foundry-cheatcodes
Any agent
npx skills add Hirama/solidity-agentic-stack --skill foundry-cheatcodes
Clone the repo
git clone --depth 1 https://github.com/Hirama/solidity-agentic-stack

Made for: Claude Code, Codex.

Per session 70 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,620 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.00070 $0.01620
Opus 5 $0.00035 $0.00810
Sonnet 5 $0.00014 $0.00324
Haiku 4.5 $0.00007 $0.00162

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

Security

Grade A, and why

foundry-cheatcodes 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 2d 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.

.claude/skills/foundry-cheatcodes/SKILL.md · 178 lines

How it starts

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

Foundry Cheatcodes

vm.* cheatcodes are how Forge tests manipulate EVM state and assert behavior. They live in forge-std/Test.sol (Vm interface). Full reference: https://getfoundry.sh/reference/cheatcodes/overview

When to use this skill

  • Writing a test that needs to fake msg.sender (prank)
  • Asserting a revert (expectRevert)
  • Asserting an event was emitted (expectEmit)
  • Mocking an external contract call (mockCall)
  • Manipulating block context (warp, roll, fee)
  • Setting balances or storage directly (deal, store, etch)
  • Forking mainnet for integration tests (createFork, selectFork)
  • Reading env vars or JSON in tests/scripts (envUint, parseJson)

Cheat sheet — most common

Block & time

Cheat Use
vm.warp(uint256) Set block.timestamp
vm.roll(uint256) Set block.number
vm.fee(uint256) Set block.basefee
vm.chainId(uint256) Set block.chainid
vm.prevrandao(bytes32) Set block.prevrandao (post-merge)
vm.txGasPrice(uint256) Set tx.gasprice

Caller / pranks

Cheat Use
vm.prank(addr) Next call uses addr as msg.sender
vm.prank(addr, origin) Also set tx.origin
vm.startPrank(addr) All calls until stopPrank
vm.stopPrank() End an active prank
vm.readCallers() Inspect current prank mode

Account state

Cheat Use
vm.deal(addr, uint256) Set ETH balance
vm.store(addr, slot, value) Write a storage slot
vm.load(addr, slot) Read a storage slot
vm.etch(addr, bytecode) Replace bytecode at addr
vm.setNonce(addr, uint64) / vm.getNonce(addr) Nonce control

Expectations

Cheat Use
vm.expectRevert() Next call must revert (any reason)
vm.expectRevert(bytes selector) Must revert w/ that selector (custom errors)
vm.expectRevert(bytes message) Must revert w/ that bytes/string
vm.expectEmit(true, true, true, true) Next emit must match
vm.expectCall(addr, calldata) A specific external call must happen

Read the full file on GitHub · 178 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. 2d ago First seen · 178 lines · 70 tokens per session scan A 753cb19c59fd

Subscribe to this mod's changes

foundry-cheatcodes is a skill published in the GitHub repository Hirama/solidity-agentic-stack (5 stars, last pushed 2mo ago), licensed MIT. It adds 70 tokens to every session and 1,620 once invoked, about $0.0003 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.

Related

Other skills, from other repositories

analyzing-ethereum-smart-contract-vulnerabilities

Perform static and symbolic analysis of Solidity smart contracts using Slither and Mythril to detect reentrancy, integer overflow, access control, and other vulnerability classes before deployment to Ethereum mainnet.

mukul975/Anthropic-Cybersecurity-Skills · 49 tokens

official-sui-skills

Pointer to the official Mysten Labs skills for building on Sui — language fundamentals, object model, PTBs, SDKs, publishing, upgrades, frontend integration, accessing on-chain data. Maintained upstream at github.com/MystenLabs/skills; pinned to the same ref the audit catalog derives from (see…

MystenLabs/sui · 116 tokens

nostr-expert

Nostr protocol implementation patterns in Quartz (AmethystMultiplatform's KMP Nostr library). Use when working with: (1) Nostr events (creating, parsing, signing), (2) Event kinds and tags, (3) NIP implementations (80+ NIP packages in quartz/), (4) Event builders and TagArrayBuilder DSL, (5) Nostr cryptography…

vitorpamplona/amethyst · 182 tokens

nip85-trusted-assertions

The NIP-85 trusted-assertions model in Quartz (nip85TrustedAssertions/) — kind 10040 trust-provider lists, kind 30382 contact cards / user assertions, 30383 event assertions, 30384 addressable assertions, 30385 external-id assertions. Use when building or parsing these events, working with the typed tags (RankTag…

vitorpamplona/amethyst · 148 tokens

ansem-crypto

Use when evaluating crypto narratives, attention rotation, memecoin cycles, Solana-style ecosystem momentum, social distribution, and reflexive retail flows in an Ansem-style crypto market framework.

questflowai/investorskills · 41 tokens

arthur-hayes-liquidity

Use when evaluating crypto markets through an Arthur Hayes-style liquidity lens: dollar liquidity, funding, risk appetite, cycle psychology, and macro-driven crypto positioning.

questflowai/investorskills · 38 tokens