---
name: "foundry-forge-invariant-testing"
description: "Write blazing-fast property-based fuzz tests and invariant checks in native Solidity."
metadata:
  author: "Foundry"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "write foundry invariant test"
  - "run forge test fuzzing"
  - "create handler based fuzzing foundry"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Foundry Forge Invariant Tests & Fuzzing

Tests smart contracts using Foundry Forge: forge test, parameterized fuzzing, invariant target selectors, handler-based fuzzing architecture, and execution gas profiling.

## When to Invoke
Invoke this skill whenever you need to:
- write foundry invariant test
- run forge test fuzzing
- create handler based fuzzing foundry

## Execution SOP & Rules
1. Write tests directly in Solidity inside test/ directory extending Test.
2. Structure invariant tests using invariant_* naming conventions.
3. Use targetContract() and targetSelector() in setUp() to guide the fuzzer to valid call targets.
4. Run forge test -vvvv to inspect failure stack traces and counter-example inputs.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
