invariant-writer

invariant-writer is an agent for Claude Code from omermaksutii/RugProof. It costs 35 tokens per session (1,040 once invoked), scanned A, original, MIT.

A tool that finds rules which should always remain true in blockchain protocols and writes Foundry tests to try to break them. Foundry is a toolkit for testing Solidity smart contracts.

In plain words
What is it for?
Use it to identify and test accounting, solvency, transfer, pricing, borrowing, lending, and liquidation rules in token, vault, exchange, and lending contracts.
Why use it?
Ordinary tests check selected examples, while invariant tests repeatedly explore actions to find states that violate an important rule.

Agent for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: model in frontmatter.

Part of the rugproof plugin — 35 commands, 23 agents shipped together

Good fit Use it to identify and test accounting, solvency, transfer, pricing, borrowing, lending, and liquidation rules in token, vault, exchange, and lending contracts.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/omermaksutii/rugproof/invariant-writer
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.

Clone the repo
git clone --depth 1 https://github.com/omermaksutii/RugProof

Made for: Claude Code.

Or install rugproof, the plugin that ships this one along with the rest of its 35 commands, 23 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for invariant-writer

README.md
[![agentmods](https://agentmods.dev/badge/agents/omermaksutii/rugproof/invariant-writer/github.svg)](https://agentmods.dev/agents/omermaksutii/rugproof/invariant-writer)
Your own site
<a href="https://agentmods.dev/agents/omermaksutii/rugproof/invariant-writer"><img src="https://agentmods.dev/badge/agents/omermaksutii/rugproof/invariant-writer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for invariant-writer

Your own site · 80×15
<a href="https://agentmods.dev/agents/omermaksutii/rugproof/invariant-writer"><img src="https://agentmods.dev/badge/agents/omermaksutii/rugproof/invariant-writer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 35 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,040 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00035 $0.01040
Opus 5 $0.00017 $0.00520
Sonnet 5 $0.00007 $0.00208
Haiku 4.5 $0.00003 $0.00104

Measured 9d ago against content hash 66bd6b98e431, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

invariant-writer 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 9d 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.

agents/invariant-writer.md · 129 lines

How it starts

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

You identify what must always be true about a protocol and write Foundry invariant tests that try to break it.

Method

Step 1 — Identify invariants

Read the contract. For each protocol type, candidate invariants:

ERC-20 / token:

  • totalSupply() == sum_over(addresses, balanceOf(a)) (no minting outside accounted paths)
  • forall a: balanceOf(a) <= totalSupply()
  • Transfers conserve sum-of-balances

ERC-4626 vault:

  • totalAssets() >= sum_over(holders, convertToAssets(balanceOf(h))) — solvency
  • previewDeposit(a) then deposit gives at least previewDeposit(a) shares
  • previewWithdraw(a) then withdraw burns at most previewWithdraw(a) shares
  • totalSupply() == 0 ⇒ totalAssets() == 0 (or only virtual)
  • Rounding favors the vault (down on deposit, up on withdraw)

AMM:

  • K = reserve0 * reserve1 non-decreasing after fee-paying swap
  • LP_supply proportional to sqrt(r0 * r1) over time
  • Mint + immediate burn returns at most what was put in

Lending:

  • sumDebt(asset) ≤ sumCollateralValue(asset, oraclePrice) * MAX_LTV + badDebt
  • borrow + repay is value-preserving (ignoring fees)
  • Liquidations can't extract more collateral than the seize-ratio allows

Governance:

  • Vote weight at execution ≤ vote weight at proposal-creation snapshot
  • Timelock delay always elapses
  • Quorum check is monotone (can't decrease retroactively)

Step 2 — Generate the Handler

A Foundry invariant Handler is a "fuzzer-friendly" contract that has the same API as the target with bounded inputs:

contract Handler is Test {
    Vault vault;
    address[] public actors;

    constructor(Vault v) {
        vault = v;
        for (uint i; i < 5; ++i) actors.push(makeAddr(string(abi.encode(i))));
    }

    function deposit(uint256 actorSeed, uint256 amount) public {
        address actor = actors[actorSeed % actors.length];
        amount = bound(amount, 1, 1e24);
        vm.deal(actor, amount);
        vm.prank(actor);
        vault.deposit{value: amount}();
    }

    function withdraw(uint256 actorSeed, uint256 shares) public {
        address actor = actors[actorSeed % actors.length];
        uint256 bal = vault.balanceOf(actor);
        if (bal == 0) return;
        shares = bound(shares, 1, bal);
        vm.prank(actor);
        vault.redeem(shares, actor, actor);
    }

    function getActors() external view returns (address[] memory) { return actors; }
}

Read the full file on GitHub · 129 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. 9d ago First seen · 129 lines · 35 tokens per session scan A 66bd6b98e431

Subscribe to this mod's changes

invariant-writer is an agent published in the GitHub repository omermaksutii/RugProof (9 stars, last pushed 1mo ago), licensed MIT. It adds 35 tokens to every session and 1,040 once invoked, about $0.0002 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 agents, from other repositories

chainaware-gamefi-screener

Screens wallets connecting to a Web3 game or P2E (Play-to-Earn) platform using ChainAware's Behavioral Prediction MCP. Detects bot farms, multi-account cheaters, and reward abusers, then classifies legitimate players into experience tiers for matchmaking and calculates their P2E reward eligibility. Use this agent…

ChainAware/behavioral-prediction-mcp · 247 tokens

chainaware-lending-risk-assessor

Assesses borrower risk for DeFi lending by combining fraud probability, on-chain experience, and risk appetite from ChainAware's Behavioral Prediction MCP. Returns a Borrower Risk Grade (A–F), a recommended collateral ratio, and an interest rate tier — so lending protocols can price risk per wallet rather than…

ChainAware/behavioral-prediction-mcp · 249 tokens

chainaware-marketing-director

Full-cycle marketing campaign orchestrator for Web3 platforms. Takes a wallet list (or single wallet), a plain-text platform description, and a campaign goal — then orchestrates ChainAware's specialist subagents to produce a complete Marketing Campaign Brief: segmented audience, prioritized leads, whale roster…

ChainAware/behavioral-prediction-mcp · 244 tokens

chainaware-portfolio-risk-advisor

Assesses the rug pull risk and community health of a token portfolio using ChainAware's Behavioral Prediction MCP. Scans every token in the portfolio through predictiverugpull (works for all contracts on ETH, BNB, BASE, HAQQ), enriches with community rank data from tokenranksingle where available (pre-calculated index…

ChainAware/behavioral-prediction-mcp · 290 tokens

chainaware-rwa-investor-screener

Screens wallets seeking to invest in tokenized Real World Assets (RWA) using ChainAware's Behavioral Prediction MCP. Assesses AML compliance, fraud risk, on-chain experience (proxy for investor sophistication), and risk profile alignment against the RWA's risk tier — then returns an investor Suitability Tier…

ChainAware/behavioral-prediction-mcp · 318 tokens

chainaware-airdrop-screener

Batch screens wallets for airdrop eligibility using ChainAware's Behavioral Prediction MCP. Automatically filters out bots, new addresses, and high-fraud wallets, then ranks the remaining eligible wallets by reputation score for fair, merit-based token allocation. Use this agent PROACTIVELY whenever a user provides a…

ChainAware/behavioral-prediction-mcp · 207 tokens