Agent skill

Stateful Invariant Testing

by aviggiano in aviggiano/security

Build metric-driven Chimera/create-chimera-app stateful invariant testing campaigns for Solidity projects.

MITAuto-check passedSecurity

Install Stateful Invariant Testing

skills CLI
$ npx skills add aviggiano/security --skill stateful-invariant-testing -a claude-code

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

GitHub CLI
$ gh skill install aviggiano/security stateful-invariant-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/aviggiano/security.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/stateful-invariant-testing .claude/skills/stateful-invariant-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
stateful-invariant-testing
GitHub stars
144
Token cost
~2.8k tokens
SKILL.md length
1,314 words
Files
2
Skills in repo
10
Repo updated
First seen
Licence
MIT

At a glance

Build metric-driven Chimera/create-chimera-app stateful invariant testing campaigns for Solidity projects.

  • Works in 8 steps: Create or switch to the requested… → Inspect the project layout, Foundry… → Read the create-chimera-app and… → …
  • Codex needs a Recon-style invariant harness with Setup
  • SKILL.md covers Purpose, Goal Discipline, Ground Rules and Tooling References, plus 7 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Stateful Invariant Testing is an agent skill from aviggiano/security. Build metric-driven Chimera/create-chimera-app stateful invariant testing campaigns for Solidity projects. Use when Codex needs a Recon-style invariant harness with Setup, TargetFunctions, Properties, BeforeAfter, CryticTester, CryticToFoundry, actor and manager setup, Echidna/Medusa/recon-fuzzer smoke runs, and standardized Recon coverage gates.

Its SKILL.md is about 2.8k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files (for example `agents/openai.yaml`).

It sits in Security, covering Fuzzing and Smart contracts. It works with Solidity. The repository describes itself as: Security Reviews and Audit Checklists. The licence is MIT.

When your agent uses it

  • Codex needs a Recon-style invariant harness with Setup
  • TargetFunctions
  • CryticToFoundry
  • Actor and manager setup

Example prompts

  • “/stateful-invariant-testing”

Workflow steps

8 steps, taken from the first numbered list in SKILL.md.

  1. Create or switch to the requested worktree/branch.
  2. Inspect the project layout, Foundry config, remappings, interfaces, deploy scripts, existing tests, and instructions.
  3. Read the create-chimera-app and recon-magic references listed above.
  4. Bring in Chimera and helper libraries with repo-local remappings, usually @recon/=lib/chimera/src/.
  5. Generate or adapt the harness under the repo's test tree using the standard Chimera shape: Setup.sol, TargetFunctions.sol, Properties.sol…
  6. Progressively deploy contracts, assets, actors, managers, and tracked targets through setup helpers instead of hardcoding everything…
  7. Add fuzzer configs for recon-fuzzer, Echidna, and Medusa, adapting from create-chimera-app where possible.
  8. Run forge build and a short Foundry invariant or reproducer check before longer fuzzer runs.

What it can do on your machine

Read from SKILL.md and the folder at commit e18ce7d. 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.

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

  • Network

    Links to these hosts (documentation or services it may open):

    • github.com

    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

Stateful Invariant Testing loads about 2.8k tokens when it runs. Until then it costs about 94 tokens; SKILL.md has 1,314 words of instructions outside code blocks.

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

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 aviggiano/security at commit e18ce7d, republished under its MIT licence (© aviggiano). 1,314 words, ~2,848 tokens.

Download SKILL.mdSave it as .claude/skills/stateful-invariant-testing/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
stateful-invariant-testing
description
Build metric-driven Chimera/create-chimera-app stateful invariant testing campaigns for Solidity projects. Use when Codex needs a Recon-style invariant harness with Setup, TargetFunctions, Properties, BeforeAfter, CryticTester, CryticToFoundry, actor and manager setup, Echidna/Medusa/recon-fuzzer smoke runs, and standardized Recon coverage gates.

Stateful Invariant Testing

Purpose

Use this skill to create a real stateful invariant fuzzing campaign using the Recon Chimera style. In this context, stateful invariant testing is property-based testing over sequences of protocol actions, not a separate campaign type. The fuzzer should choose action sequences. The harness should expose protocol entrypoints with minimal preprocessing, track actors and state, and report bugs instead of papering over them.

Default to the create-chimera-app layout and adapt it to the target repo. Do not hand-roll a generic StdInvariant campaign, a single monolithic handler, or a differential-only state machine unless the user explicitly asks for that instead of Chimera.

Goal Discipline

For a full campaign, explicitly ask the user to run it as a Codex /goal if they did not already. Use a measurable objective such as:

text
/goal Build and validate a stateful invariant testing campaign with 5-minute smoke runs on recon-fuzzer, Echidna, and Medusa, no unclassified failures, and at least 90% standardized line coverage of core production contracts.

Use 90% standardized line coverage as the default initial target. The user may choose a higher target or a different production scope.

Ground Rules

  • Read AGENTS.md, repo testing docs, and existing Foundry test patterns before editing.
  • If the user asks for a separate worktree, create and work inside one. Keep production contracts/ or src/ unchanged unless the user explicitly asks for contract fixes.
  • In benchmark or clean-room tasks, do not read sibling worktrees, previous generated harnesses, old commits, archived sessions, or copied candidate diffs as implementation sources unless the user explicitly permits it. Use the current checkout plus public upstream references.
  • Install missing dependencies as needed, but prefer repo-local or worktree-local setup.
  • Use Recon-Fuzz/create-chimera-app and Recon-Fuzz/chimera as the normative scaffold for new campaigns. Treat repo-local fixture helpers as inputs to Setup, not as a reason to abandon the Chimera file structure.
  • Keep target functions close to public protocol actions. Avoid "surface", "sweep", or "coverage" handlers whose main purpose is to execute lines.
  • Do not use broad try/catch to force artificial coverage. Let expected reverts be explored naturally by fuzzing unless the call is an intentional quote-then-execute or setup boundary.
  • Prefer asActor and actor-manager helpers over direct vm.prank(actor) in target functions. Explicit pranks belong in deterministic setup or narrow shortcut scenarios.
  • Treat failing invariants as findings. Classify them before changing tests. Do not weaken assertions or hide production bugs.

Tooling References

Use these repositories as implementation references for every new Chimera campaign:

Before the first edit, read the current create-chimera-app AGENT.md or README.md, its test/recon skeleton, and the relevant recon-magic prompts for scout, setup, properties, and coverage. If local clones exist, prefer them; otherwise fetch the public upstream files. Summarize the scaffold and command choices in the first implementation update.

If create-chimera-app or recon-magic-framework exists as a local checkout in the workspace or home directory, use those local references. Helpful files include:

  • <create-chimera-app>/AGENT.md
  • <create-chimera-app>/test/recon/Setup.sol
  • <create-chimera-app>/test/recon/TargetFunctions.sol
  • <create-chimera-app>/test/recon/Properties.sol
  • <create-chimera-app>/test/recon/BeforeAfter.sol
  • <create-chimera-app>/test/recon/CryticTester.sol
  • <create-chimera-app>/test/recon/CryticToFoundry.sol
  • <recon-magic-framework>/prompts/agent/scout-v2-phase-0.md
  • <recon-magic-framework>/prompts/agent/setup-v2-phase-0.md
  • <recon-magic-framework>/prompts/agent/properties-v4-phase-0.md
  • <recon-magic-framework>/prompts/agent/coverage-phase-0.md
  • <recon-magic-framework>/prompts/agent/chimera-test-linter.md

Setup Workflow

  1. Create or switch to the requested worktree/branch.
  2. Inspect the project layout, Foundry config, remappings, interfaces, deploy scripts, existing tests, and instructions.
  3. Read the create-chimera-app and recon-magic references listed above.
  4. Bring in Chimera and helper libraries with repo-local remappings, usually @recon/=lib/chimera/src/.
  5. Generate or adapt the harness under the repo's test tree using the standard Chimera shape: Setup.sol, TargetFunctions.sol, Properties.sol, BeforeAfter.sol, CryticTester.sol, and CryticToFoundry.sol.
  6. Progressively deploy contracts, assets, actors, managers, and tracked targets through setup helpers instead of hardcoding everything inside target functions.
  7. Add fuzzer configs for recon-fuzzer, Echidna, and Medusa, adapting from create-chimera-app where possible.
  8. Run forge build and a short Foundry invariant or reproducer check before longer fuzzer runs.

The fuzzer entrypoint should normally be CryticTester. The Foundry debug entrypoint should normally be CryticToFoundry.

Prefer assertion mode for Chimera campaigns: properties should use Chimera assertions such as t, eq, gte, or lte through CryticAsserts/FoundryAsserts. Use echidna_ property mode only when the local toolchain or repo convention clearly requires it.

Stateful Harness Guidelines

  1. Separate setup from exploration. Deploy contracts, create baseline actors, mint/fund assets, and grant baseline approvals in setup, not inside target functions.
  2. Model actors and assets explicitly. Let the fuzzer switch actors, markets, tokens, managers, vaults, or positions through manager helpers rather than scripting fixed stories.
  3. Expose one natural state transition per target when possible: deposit, withdraw, borrow, repay, place order, cancel, liquidate, claim, deploy, register, approve.
  4. Bound only enough to keep inputs in meaningful protocol domains. Avoid pre-checking every success condition; invalid states and reverts are part of stateful fuzzing.
  5. Let validation and revert branches be reached naturally. Do not add handlers whose purpose is to force require lines, impossible states, or intentionally invalid payloads.
  6. Track created objects and select from tracked state. For example, place-order targets should record live orders, while cancel/decrease targets should choose from those tracked orders.
  7. Split large lifecycle bundles into separate target functions unless the sequence itself is the behavior under test.
  8. Define a shortcut as a target or scenario that intentionally composes multiple actions into one entrypoint because the exact sequence is hard to discover or is the property being tested. Use shortcuts sparingly, name them clearly, and document why they must be atomic.
  9. Accept shortcuts for flows like approve-followed-by-deposit, quote-followed-by-execute, permit-followed-by-transfer, or a force-liquidation scenario such as snapshot_liquidate that performs supply_1, supply_2, borrow_1, change_price, and liquidate_2 with different actors.
  10. Do not add handlers solely to cover pure/view functions; the standard Recon coverage-generation path excludes ABI view/pure functions before covg_eval analyzes recon-coverage.json. Keep important read-only behavior as focused invariant checks or no-revert canaries, and move introspection sweeps, intentionally invalid calls, and revert-branch exercises out of primary stateful targets.

Good targets look like public user actions. Suspicious targets look like scripts that force a protocol story from start to finish.

Show full SKILL.md (376 more words)Show less

Coverage

Use standardized coverage from recon-magic-framework/tools/covg_eval, not ad hoc line counts. The goal is not complete until the covg_eval-style number meets the requested target for the requested production scope.

Prefer recon-fuzzer for coverage iteration because it is usually faster than Echidna. Use recon-fuzzer LCOV/corpus output to decide which real actions to add or split. Do not chase coverage with handlers whose only value is forcing lines through setup.

Track:

  • fuzzer command
  • elapsed time
  • corpus path
  • LCOV path
  • standardized covered/total lines and percent
  • any broken invariant, failing target, or harness defect

CryticToFoundry Reproducers

When a fuzzer finds a broken invariant or property violation, create a deterministic CryticToFoundry reproducer, following the pattern of hardcoded failing sequences in examples like rheo-xyz/rheo-solidity's CryticToFoundry.t.sol.

The reproducer should:

  • live in the repo's invariant or Foundry test tree using the local naming convention
  • hardcode the exact fuzzer-generated sequence and calldata/arguments
  • avoid fuzz parameters
  • fail deterministically before the production fix
  • stay in git as a regression test after the bug is fixed
  • include enough comments or test names for a developer to connect it to the fuzzer finding

Validation Gate

For an end-to-end request, do not stop at "it compiles." A normal completion gate is:

  • forge build passes.
  • Short Foundry invariant smoke passes.
  • recon-fuzzer runs for the requested smoke duration, often 5 minutes.
  • Echidna runs for the requested smoke duration, often 5 minutes.
  • Medusa runs for the requested smoke duration, often 5 minutes.
  • Standardized coverage meets the requested threshold.
  • No failing invariant remains unclassified.

If a fuzzer exits because a wrapper timeout stops it after the requested duration but it wrote corpus/LCOV and reports passing invariants, record that clearly rather than treating it as an unexplained failure.

Failure Triage

When a smoke run or regression test fails:

  • Reproduce with the narrowest command and high verbosity.
  • Use a subagent for independent root-cause analysis when available.
  • Classify as harness defect, production bug, spec mismatch, reference bug, or unknown.
  • Keep production-bug regression tests failing if the user asks to preserve the finding and not edit production contracts.
  • Use root-cause wording in commit messages for regression commits.

Final Report

End with the files changed, commands run, fuzzer results, coverage numbers, remaining classified findings, and whether the requested campaign gate is complete. Mention any untouched dirty worktree changes separately.

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

Files

SKILL.md and 1 other file in skills/stateful-invariant-testing of aviggiano/security.

  • SKILL.md
  • agents/openai.yaml

Open the folder on GitHubat commit e18ce7d

Compare with similar skills

Stateful Invariant 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.

Stateful Invariant Testing compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Stateful Invariant Testing this skillaviggiano/security144—~2.8kAutomated safety check: PassMIT
Property Based Testingtrailofbits/skills7.5k—~1.1kAutomated safety check: PassCC-BY-SA-4.0
Fizzpashov/skills1.2k2 repos~11kAutomated safety check: PassMIT
Fizz Convertpashov/skills1.2k2 repos~3.7kAutomated safety check: PassMIT
Fuzz Generatoralt-research2/SolidityGuard104—~763Automated safety check: NotesCustom licence
Fuzzing Patternsccashwell/evm-cortex131—~1.6kAutomated safety check: PassMIT

Similar skills

  • Property Based Testing

    trailofbits/skills

    Official

    Writes, reviews, and debugs property-based tests — Hypothesis, fast-check, proptest, jqwik, rapid, and Echidna or Medusa for Solidity invariants.

    7.5k GitHub stars~1.1k tokensUpdated today
    SecurityAuto-check passed
  • Fizz

    pashov/skills

    Generate Echidna/Medusa-compatible Solidity fuzz suites from Foundry or Hardhat projects.

    1.2k GitHub starsUsed in 2 repos~11k tokens
    SecurityAuto-check passed
  • 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
  • Fuzz Generator

    alt-research2/SolidityGuard

    Generates Foundry invariant tests and Echidna property-based fuzz tests for Solidity contracts.

    104 GitHub stars~763 tokensUpdated 3 mo ago
    Backend & APIsAuto-check: notes
  • Fuzzing Patterns

    ccashwell/evm-cortex

    A skill your agent uses when writing fuzz tests for Solidity contracts.

    131 GitHub stars~1.6k tokensUpdated 10 days ago
    SecurityAuto-check passed
  • Flounder

    adshao/flounder

    Operates Flounder, an autonomous white-hat security auditor.

    518 GitHub stars~9.2k tokensUpdated 4 days ago
    SecurityAuto-check passed

More from aviggiano/security

All 10 skills in this repo
  • Foundry Deploy Fixtures

    aviggiano/security

    Create or refactor Foundry deployment fixtures for Solidity tests.

    144 GitHub stars~634 tokensUpdated 25 days ago
    Auto-check passed
  • Foundry Fuzz Mirrors

    aviggiano/security

    Create Foundry fuzz tests from deterministic unit tests. An agent skill from aviggiano/security.

    144 GitHub stars~584 tokensUpdated 25 days ago
    Auto-check passed
  • Foundry Spec Properties

    aviggiano/security

    Turn whitepapers, protocol specs, and public documentation into Foundry property tests.

    144 GitHub stars~489 tokensUpdated 25 days ago
    Auto-check passed
  • Foundry Test Campaign

    aviggiano/security

    Master skill for running an end-to-end multi-pass Foundry testing campaign for Solidity projects.

    144 GitHub stars~1.6k tokensUpdated 25 days ago
    Auto-check passed
  • Foundry Differential Tests

    aviggiano/security

    Create Foundry differential tests comparing production Solidity contracts against an independent reference model.

    144 GitHub stars~613 tokensUpdated 25 days ago
    Auto-check passed
  • Foundry Failure Triage

    aviggiano/security

    Classify failing Foundry fuzz, property, invariant, and differential tests.

    144 GitHub stars~637 tokensUpdated 25 days ago
    Auto-check passed

Works with

Questions about Stateful Invariant Testing

What does Stateful Invariant Testing do?

Build metric-driven Chimera/create-chimera-app stateful invariant testing campaigns for Solidity projects. Stateful Invariant Testing is an agent skill from aviggiano/security. Build metric-driven Chimera/create-chimera-app stateful invariant testing campaigns for Solidity projects.

When should I use Stateful Invariant Testing?

Stateful Invariant Testing fits situations like: Codex needs a Recon-style invariant harness with Setup; targetFunctions; cryticToFoundry; actor and manager setup.

How do I install Stateful Invariant Testing in Claude Code?

Run `npx skills add aviggiano/security --skill stateful-invariant-testing -a claude-code`. Or copy the skill folder (skills/stateful-invariant-testing in aviggiano/security) into .claude/skills/stateful-invariant-testing in your project. Claude Code loads it when a task matches its description.

How do I install Stateful Invariant Testing in Codex?

Run `npx skills add aviggiano/security --skill stateful-invariant-testing -a codex`. Or copy the skill folder (skills/stateful-invariant-testing in aviggiano/security) into .agents/skills/stateful-invariant-testing in your project. Codex loads it when a task matches its description.

Can I use Stateful Invariant 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 aviggiano/security --skill stateful-invariant-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/stateful-invariant-testing, .gemini/skills/stateful-invariant-testing, .github/skills/stateful-invariant-testing and .opencode/skills/stateful-invariant-testing in your project.

What does Stateful Invariant Testing need to run?

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

Does Stateful Invariant Testing access the network?

SKILL.md names 1 domain. As links in the text: github.com. This is read from the text; nothing was executed.

Is Stateful Invariant 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 Stateful Invariant Testing use?

Stateful Invariant 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 Stateful Invariant Testing use?

About 2.8k tokens (SKILL.md is roughly 11k 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 Stateful Invariant Testing?

Skills that share tags, products or a category with Stateful Invariant Testing: Property Based Testing (trailofbits/skills, 7.5k stars), Fizz (pashov/skills, 1.2k stars), Fizz Convert (pashov/skills, 1.2k stars) and Fuzz Generator (alt-research2/SolidityGuard, 104 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Stateful Invariant Testing?

aviggiano (a GitHub user) maintains it in aviggiano/security, which has 144 GitHub stars. The repository holds 10 skills in this directory. The repository was last updated on September 15, 2026.

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