agentleFS
sablier-labssablier-labs/agent-skills/skills/cli-forge/SKILL.md

cli-forge

Skill9 starsChanged 51 days agoMITView on GitHub

Write Foundry-based tests and scripts. Trigger phrases - foundry testing, write test, fuzz test, fork test, invariant test, deploy script, gas benchmark, coverage, or when working in tests/ or scripts/ directories.

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 2 are distinctive, and 11 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 11

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Assert state AFTER action: - Check state changes after function executes

    line 51
  2. Very specific:

    Place all mocks in tests/mocks/

    line 57
  3. Very specific:

    Create fork with vm.createSelectFork("ethereum")

    line 92
  4. Very specific:

    Use deal() to give tokens to test users

    line 93
  5. Very specific:

    Use assumeNoBlacklisted() for USDC/USDT

    line 94
  6. Very specific:

    Use forceApprove() for non-standard tokens (USDT)

    line 95
  7. Very specific:

    Use env vars: ETH_FROM, MNEMONIC

    line 132
  8. Very specific:

    Check state with logs: - Add console2.log before reverts

    line 208
  9. Very specific:

    Isolate failures: - Run single test with --match-test

    line 209
  10. Very specific:

    Compare gas: - Use --gas-report to spot unexpected costs

    line 210
  11. Very specific:

    Snapshot comparisons: - Use vm.snapshot() / vm.revertTo() to isolate state changes

    line 211
  12. Very specific:

    Use constants from Defaults/Constants - never hardcode

    line 217
  13. Distinctive:

    Test this skill with these prompts:

    line 232

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Foundry Testing & Script Skill

Rules and patterns for Foundry tests. Find examples in the actual codebase.

Bundled References

ReferenceContentWhen to Read
./references/test-infrastructure.mdConstants, defaults, mocksWhen setting up tests
./references/cheat-codes.mdCommon cheatcode patternsWhen using vm cheatcodes
./references/invariant-patterns.mdHandlers, stores, invariantsWhen writing invariant tests
./references/formal-verification.mdHalmos, Certora, symbolic execWhen proving correctness
./references/deployment-scripts.mdScript patterns, verificationWhen writing deploy scripts
./references/deployment-checklist.mdPre-mainnet deployment stepsBefore deploying to production
./references/gas-benchmarking.mdSnapshot, profiling, CIWhen measuring gas performance
./references/sablier-conventions.mdSablier-specific patternsWhen working in Sablier repos

Test Types

TypeDirectoryNamingPurpose
Integrationtests/integration/concrete/*.t.solBTT-based concrete tests
Fuzztests/integration/fuzz/*.t.solProperty-based testing
Forktests/fork/*.t.solMainnet state testing
Invarianttests/invariant/Invariant*.t.solStateful protocol properties
Scriptsscripts/solidity/*.s.solDeployment/initialization

1. Integration Tests (Concrete)

Naming Convention

PatternUsage
test_RevertWhen_{Condition}Revert on input
test_RevertGiven_{State}Revert on state
test_When_{Condition}Success path

Rules

  1. Stack modifiers to document BTT path (modifiers are often empty - just document the path)
  2. Expect events BEFORE action - vm.expectEmit() then call function
  3. Assert state AFTER action - Check state changes after function executes
  4. Use revert helpers for common patterns (expectRevert_DelegateCall, expectRevert_Null)
  5. Named parameters in assertions - assertEq(actual, expected, "description")

Mock Rules

  1. Place all mocks in tests/mocks/
  2. One mock per scenario (not one mega-mock)
  3. Naming: *Good, *Reverting, *InvalidSelector, *Reentrant

2. Fuzz Tests

Naming Convention

testFuzz_{FunctionName}_{Scenario}

Rules

  1. Bound before assume - _bound() is more efficient than vm.assume()
  2. Bound in dependency order - Independent params first, then dependent
  3. Never hardcode params with validation constraints
  4. Document fuzzed scenarios in NatSpec

Bounding Pattern

// 1. Bound independent params first
cliffDuration = boundUint40(cliffDuration, 0, MAX - 1);

// 2. Bound dependent params based on constraints
totalDuration = boundUint40(totalDuration, cliffDuration + 1, MAX);

3. Fork Tests

Rules

  1. Create fork with vm.createSelectFork("ethereum")
  2. Use deal() to give tokens to test users
  3. Use assumeNoBlacklisted() for USDC/USDT
  4. Use forceApprove() for non-standard tokens (USDT)

Token Quirks

TokenIssueSolution
USDC/USDTBlacklistassumeNoBlacklisted()
USDTNon-standardforceApprove()
Fee-on-transferBalance diffCheck actual received amount

4. Invariant Tests

Architecture

tests/invariant/
├── handlers/     # State manipulation (call functions with bounded params)
├── stores/       # State tracking (record totals, IDs)
└── Invariant.t.sol

Rules

  1. Target handlers only - targetContract(address(handler))
  2. Exclude protocol contracts - excludeSender(address(vault))
  3. Use stores to track totals for invariant assertions
  4. Early return in handlers if preconditions not met

5. Solidity Scripts

Rules

  1. Inherit from BaseScript with broadcast modifier
  2. Use env vars: ETH_FROM, MNEMONIC
  3. Simulation first, then broadcast

Commands

# Simulation
forge script scripts/Deploy.s.sol --sig "run(...)" ARGS --rpc-url $RPC

# Broadcast
forge script scripts/Deploy.s.sol --sig "run(...)" ARGS --rpc-url $RPC --broadcast --verify

Running Tests

# By type
forge test --match-path "tests/integration/concrete/**"
forge test --match-path "tests/fork/**"
forge test --match-contract Invariant_Test

# Specific test
forge test --match-test test_WhenCallerRecipient -vvvv

# Fuzz with more runs
forge test --match-test testFuzz_ --fuzz-runs 1000

# Coverage
forge coverage --report lcov

Debugging

Verbosity Levels

FlagShows
-vLogs for failing tests
-vvLogs for all tests
-vvvStack traces for failures
-vvvvStack traces + setup traces
-vvvvvFull execution traces

Console Logging

import { console2 } from "forge-std/console2.sol";

console2.log("value:", someValue);
console2.log("address:", someAddress);
console2.logBytes32(someBytes32);

Debugging Commands

# Trace specific failing test
forge test --match-test test_MyTest -vvvv

# Gas report for a test
forge test --match-test test_MyTest --gas-report

# Debug in interactive debugger
forge debug --debug tests/MyTest.t.sol --sig "test_MyTest()"

# Inspect storage layout
forge inspect MyContract storage-layout

Debugging Tips

  1. Label addresses - vm.label(addr, "Recipient") for readable traces
  2. Check state with logs - Add console2.log before reverts
  3. Isolate failures - Run single test with --match-test
  4. Compare gas - Use --gas-report to spot unexpected costs
  5. Snapshot comparisons - Use vm.snapshot() / vm.revertTo() to isolate state changes

Best Practices Summary

  1. Use constants from Defaults/Constants - never hardcode
  2. Specialized mocks - one per scenario, all in tests/mocks/
  3. Modifiers in Modifiers.sol - centralize BTT path modifiers
  4. Label addresses with vm.label() for traces
  5. Events before actions - vm.expectEmit() then call
  6. Bound before assume - more efficient

External References


Example Invocations

Test this skill with these prompts:

  1. Integration test: "Write a concrete test for withdraw that expects Errors.Flow_Overdraw when amount exceeds balance"
  2. Fuzz test: "Create a fuzz test for deposit that bounds amount between 1 and type(uint128).max"
  3. Fork test: "Write a fork test for USDC deposits on mainnet with blacklist handling"
  4. Invariant test: "Create an invariant handler for the deposit and withdraw functions"
  5. Deploy script: "Write a deployment script for SablierFlow with verification"

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.