web3-testing
Skill1 starsChanged 8 months agoMITView on GitHub
Production-grade smart contract testing with Foundry (primary) and Hardhat 3. Covers unit tests, parameterized fuzzing, stateful invariants with handlers and actor patterns, mainnet forking and impersonation, static analysis (Slither, Aderyn), property testing (Echidna, Medusa), symbolic execution (Halmos, Kontrol), gas snapshots, coverage, mutation testing, storage-layout upgrade safety, ERC-4337 testing, and CI integration. Use when writing or reviewing Solidity tests, designing test suites, chasing flaky tests, adding invariants, setting up Foundry or Hardhat, wiring CI for contracts, or when the user mentions forge, foundry, hardhat, cheatcodes, vm.prank, vm.expectRevert, invariant testing, fuzz testing, fork testing, Slither, Echidna, Medusa, Halmos, Kontrol, forge coverage, or forge snapshot.
6 other projects use a version of this.
Adopted by
Most recently taken up by
- xfstudio/skillstheir own version, first seen Oct 13, 2026
- sunshineluyao/Moss-Mcp-Transactiontheir own version, first seen Oct 13, 2026
- Samueladewole/claude-skillstheir own version, first seen Oct 13, 2026
- ai4brands-design/claude-skillstheir own version, first seen Mar 22, 2026
- CodeWithBehnam/cc-docstheir own version, first seen Mar 15, 2026
- whatthehackinsg/agent-auctiontheir own version, first seen Mar 7, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- xfstudio/skills★ 9same name
- ai4brands-design/claude-skills★ 2same name
- CodeWithBehnam/cc-docs★ 2same name
- whatthehackinsg/agent-auction★ 2same name
- sunshineluyao/Moss-Mcp-Transaction★ 1same name
- Samueladewole/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository33 other files it gives its agents.
- argocdSkill
- c-cpp-compilersSkill
- coding-guidelinesSkill
- devops-iac-engineerSkill
- dag-flowdSkill
- flowd-rules-authorSkill
- frontend-designSkill
- ghSkill
- grafana-dashboardsSkill
- helmSkill
- kustomizeSkill
- legalizerSkill
- lua-projectsSkill
- markdown-documentationSkill
- mermaid-diagramsSkill
- meta-cognition-parallelSkill
- podmasterSkill
- practical-haskellSkill
- rcaSkill
- researcherSkill
- security-auditSkill
- solidity-securitySkill
- svg-genSkill
- tdd-red-green-refactorSkill
- tmux-masterySkill
- tokenomics-designSkill
- ultimate-dbSkill
- ultimate-nixosSkill
- ultimate-rustSkill
- ultimate-web3Skill
- web3-frontendSkill
- web3-whitepaperSkill
- ziglangSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Read these before doing anything else.
- Distinctive: line 15
Read at most 2 reference files per turn: Use the routing table to pick.
- Very specific: line 44
Fuzz everything that takes user input: Every public function with numeric, address, or byte inputs gets at least one fuzz test with …
- Very specific: line 48
Test access control exhaustively: Every onlyRole/onlyOwner path needs a negative test proving unauthorized callers revert.
- Distinctive: line 65
If the user explicitly chose another stack, do not argue.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Web3 Testing (Foundry primary, Hardhat 3 supported)
Routing-first skill. The body is intentionally thin; depth lives in reference/. Open only the files you actually need.
Token economy rules for the agent
Read these before doing anything else. They cut answer cost without losing quality.
- Do not paste the user's contract back at them. Reference function names and line ranges; write only the test harness or the diff.
- Read at most 2 reference files per turn. Use the routing table to pick.
- Never reproduce
forge-stdinternals. Reference them by name (Test,StdInvariant,StdCheats) and assume the user hasforge-stdinstalled. - Default to Foundry in examples. Only show Hardhat when the user says Hardhat or already has a Hardhat project.
- Prefer tables over prose for cheatcode catalogs, option matrices, or revert-parsing rules.
- Verify version-specific APIs via Context7 for Foundry, Hardhat, OpenZeppelin, Slither, Echidna, Halmos, and ethers/viem. Foundry and Hardhat both moved fast through 2024-2026; treat any pre-2026 snippet in your training as suspect -- especially
testFail*, ethers v5, Goerli, and Hardhat 2 ESM assumptions.
Routing table
| Task | File |
foundry.toml, profiles, remappings, forge init hygiene | reference/setup-foundry.md |
| Hardhat 3 with viem, Node test runner, legacy Hardhat 2 escape hatch | reference/setup-hardhat.md |
describe/it style vs Foundry tests, expectRevert, expectEmit, cheatcodes | reference/unit-testing.md |
Parameterized fuzzing, vm.assume, bound, typed generators | reference/fuzzing.md |
Stateful invariants, handlers, targetContract, actor-based patterns | reference/invariants.md |
Mainnet fork, block pinning, vm.createSelectFork, impersonation | reference/forking.md |
| Slither, Aderyn, Echidna, Medusa integration | reference/static-and-property.md |
forge snapshot, forge coverage, LCOV, mutation testing (necessist) | reference/gas-and-coverage.md |
| GitHub Actions for Foundry/Hardhat, caching, slither gate, matrix | reference/ci.md |
| Symbolic execution (Halmos, Kontrol), upgrade safety, ERC-4337 tests | reference/advanced.md |
Footguns: flaky tests, testFail, timestamp coupling, hardcoded blocks | reference/anti-patterns.md |
Golden rules (non-negotiable)
These prevent the failures that actually matter in production.
- Test against custom errors, not strings.
vm.expectRevert(MyErr.selector)andrevertedWithCustomErrorfor Hardhat.revertedWith("...")is brittle and breaks under Solidity optimizer changes. - Never use Foundry's
testFail*prefix. It masks unrelated reverts. Always usevm.expectRevertwith an explicit reason or selector. - Pin the fork block. Unpinned forks are the #1 source of "passes locally, fails in CI" flakiness.
- Fuzz everything that takes user input. Every public function with numeric, address, or byte inputs gets at least one fuzz test with
bound(...)to constrain to the domain. - Invariants for protocols, not unit tests. Any system with accumulating state (lending, vaults, AMMs, staking, governance) needs a
StdInvariant-based harness with handlers. Pure unit tests cannot find state-space bugs. - Run
forge snapshotin CI and fail on regressions. Silent gas bloat is a deployment-blocking problem you can only catch mechanically. - Pair tests with at least one static analyzer (Slither or Aderyn). Tests find behavioral bugs; static analysis finds class-of-bug issues (reentrancy, tx.origin, unchecked-low-level-call) in patterns tests cannot exhaustively cover.
- Test access control exhaustively. Every
onlyRole/onlyOwnerpath needs a negative test proving unauthorized callers revert. - Never
vm.skip()or disable a test without a tracked issue. Skipped tests are permanent dead code. - Coverage is a floor, not a ceiling. Aim for >90% line AND branch, but stop measuring coverage once a suite has solid invariants and fuzz tests -- they find bugs coverage metrics never will.
Default stack (one choice, one escape hatch)
| Concern | Default | Escape hatch |
| Unit + fuzz + invariant framework | Foundry (forge test) | Hardhat 3 when the user already uses TypeScript-heavy tooling or off-chain integration is primary |
| Static analysis | Slither | Aderyn (Rust, faster) as a second opinion; run both in CI when budget allows |
| Property testing | Echidna | Medusa (Go, faster on complex state) |
| Symbolic execution | Halmos (Foundry-compatible) | Kontrol for K-framework-grade rigor |
| Mainnet fork | Foundry --fork-url with pinned --fork-block-number | Hardhat network fork for TS-heavy suites |
| Gas reporting | forge snapshot committed to repo | hardhat-gas-reporter |
| Coverage | forge coverage --report lcov | hardhat-coverage via solidity-coverage |
| Mutation testing | necessist | Slither's slither-mutate |
If the user explicitly chose another stack, do not argue; help them with what they have.
Decision matrix: what kind of test does this bug need?
| Bug class | Test type |
| Known revert path with fixed inputs | Unit test with vm.expectRevert |
| Arithmetic edge cases across input domain | Parameterized fuzz test with bound |
| State-space bugs (accounting drift, double-spend) | Stateful invariant with handler |
| Attack against specific mainnet state | Block-pinned fork test |
| Protocol-level safety property ("no user can withdraw more than deposited") | Invariant + Echidna/Medusa property |
| Class-of-bug (reentrancy, delegatecall misuse) | Slither/Aderyn + unit test for the specific pattern |
| Algorithmic proof (upper bounds, absence of overflow) | Halmos / Kontrol symbolic execution |
| Storage layout breakage after upgrade | forge inspect storageLayout diff + OZ upgrades validator |
When NOT to apply this skill
- Writing the contracts themselves or architecting new protocols -> use
ultimate-web3. - Solidity patterns, secure fixes, and audit preparation -> use
solidity-security. - A codebase audit, pen test, or findings report -> use
security-audit. - dApp frontend testing (component, E2E) -> that is frontend testing, not contract testing.
Companion skills
solidity-security-- vulnerability patterns and secure codingultimate-web3-- protocol architecturesecurity-audit-- coverage-led codebase audit and findings reportweb3-frontend-- dApp frontend patterns (wagmi, viem, Next.js)gh-- CI authoring, GitHub Actions hygiene
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

