/foundry:forge-testingfrom foundry
Foundry cheatcodes, assertions, and forge test CLI. Use for vm.prank, expectRevert, verbosity, and general Foundry mechanics. For Crane/IndexedEx protocol and Diamond tests, prefer crane-testing and production-first deploy paths over mocks.
Ships in foundry. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Write native Solidity tests using Foundry's testing framework.
In this monorepo, prefer production contracts and factory/TestBase deploy paths. Do not invent mocks for facets, DFPkgs, vaults, or managers.
crane-testing + inherit CraneTest (not new for production Crane contracts).indexedex-testing + IndexedexTest / protocol TestBases.new MyContract() / mock examples are not the preferred pattern for Crane or IndexedEx features.crane-testing / indexedex-testingFor Crane work, replace new MyContract() with factory/TestBase setup from crane-testing.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Test, console} from "forge-std/Test.sol";
import {MyContract} from "../src/MyContract.sol";
contract MyContractTest is Test {
MyContract public target;
function setUp() public {
// Generic example only. Crane: inherit CraneTest + factories.
target = new MyContract();
}
function test_BasicFunction() public {
uint256 result = target.doSomething();
assertEq(result, 42);
}
function testFail_ShouldRevert() public {
target.functionThatReverts();
}
}
| Prefix | Behavior |
|---|---|
test_ or test | Expected to pass |
testFail_ or testFail | Expected to revert |
testFuzz_ | Fuzz test with random inputs |
# Run all tests
forge test
# Run specific test contract
forge test --match-contract MyContractTest
# Run specific test function
forge test --match-test test_BasicFunction
# Run with verbosity (show logs)
forge test -vvv
# Watch mode
forge test --watch
| Flag | Output |
|---|---|
| (none) | Summary only |
-vv | Logs and assertion failures |
-vvv | Stack traces for failures |
-vvvv | Setup traces for failures |
-vvvvv | All traces including setup |
See cheatcodes.md for the complete reference.
// Set caller for next call
vm.prank(address(0x123));
// Set caller for multiple calls
vm.startPrank(address(0x123));
// ... calls as 0x123
vm.stopPrank();
// Give ETH to address
vm.deal(address(0x123), 1 ether);
// Set block timestamp
vm.warp(block.timestamp + 1 days);
// Set block number
vm.roll(block.number + 100);
// Expect any revert
vm.expectRevert();
target.functionThatReverts();
// Expect specific error
vm.expectRevert("Insufficient balance");
target.withdraw(1000);
// Expect custom error
vm.expectRevert(InsufficientBalance.selector);
target.withdraw(1000);
// Expect event (check all indexed topics + data)
vm.expectEmit(true, true, true, true);
emit Transfer(from, to, amount);
target.transfer(to, amount);
See assertions.md for the complete reference.
// Equality
assertEq(a, b);
assertEq(a, b, "custom error message");
// Comparisons
assertGt(a, b); // a > b
assertGe(a, b); // a >= b
assertLt(a, b); // a < b
assertLe(a, b); // a <= b
// Approximate equality (for decimals)
assertApproxEqAbs(a, b, maxDelta);
assertApproxEqRel(a, b, maxPercentDelta);
// Boolean
assertTrue(condition);
assertFalse(condition);
import {console} from "forge-std/Test.sol";
console.log("Value:", someValue);
console.log("Address:", someAddress);
console.logBytes32(someHash);
See patterns.md for detailed examples.
address alice = makeAddr("alice");
address bob = makeAddr("bob");
vm.deal(alice, 10 ether);
vm.prank(alice);
target.deposit{value: 1 ether}();
function setUp() public {
vm.createSelectFork("mainnet");
}
function test_InteractWithMainnet() public {
IERC20 dai = IERC20(0x6B175474E89094C44Da98b954EesdfeCaE69310);
// Test against real mainnet state
}
// Write to specific storage slot
vm.store(address(target), bytes32(uint256(0)), bytes32(uint256(100)));
// Read from storage slot
bytes32 value = vm.load(address(target), bytes32(uint256(0)));
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
6 skills in this plugin
/forge-deploymentDeploy and verify smart contracts with Foundry. Use when deploying contracts, writing deployment scripts, verifying on block explorers, or managing multi-chain deployments./forge-fuzz-testingProperty-based testing with Foundry's fuzzer. Use when writing fuzz tests, invariant tests, or testing edge cases. Covers fuzz test structure, input constraints, fixtures, and invariant testing patterns./forge-signingSign messages with Foundry cheatcodes for testing signature verification. Use when testing EIP-712 signatures, Permit2, or any signed data verification./foundry-projectSet up and configure Foundry projects. Use when initializing new projects, configuring foundry.toml, managing dependencies, or structuring Solidity codebases./supersimLocal Multi-L2 Development Environment for simulating the Superchain. Use when testing cross-chain applications, OP Stack deployments, or L1/L2 message passing locally.foundry@cyotee is listed by cyotee/cyotee-claude-plugins — review the source before installing
npx claudepluginhub cyotee/cyotee-claude-plugins --plugin foundry