Best use case
foundry is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Instructions for Foundry Development (test & deployment script)
Teams using foundry should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/foundry/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How foundry Compares
| Feature / Agent | foundry | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Instructions for Foundry Development (test & deployment script)
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
This file provides instructions for Claude Code when working with Foundry tests and deployment scripts in this project.
## Project Context
This is a Foundry-based Solidity project for CMTAT. The main contracts are located in `lib/CMTAT/contracts/`.
## Writing Foundry Tests
### File Structure
- Place test files in `test/` directory
- Name test files with `.t.sol` suffix (e.g., `MyModule.t.sol`)
- Use `HelperContract.sol` as base for shared utilities
### Test Contract Template
```solidity
//SPDX-License-Identifier: MPL-2.0
pragma solidity ^0.8.20;
import "./HelperContract.sol";
contract MyModuleTest is HelperContract {
function setUp() public {
_deployToken();
// Additional setup
}
function test_DescriptiveName() public {
// Test implementation
}
function test_RevertWhen_Condition() public {
vm.expectRevert();
// Call that should revert
}
}
```
### Test Naming Conventions
- `test_` prefix for standard tests
- `test_RevertWhen_` prefix for tests expecting reverts
- `testFuzz_` prefix for fuzz tests
- Use descriptive names: `test_AdminCanMint`, `test_RevertWhen_NonOwnerCalls`
### Key Cheatcodes
```solidity
// Change msg.sender for next call
vm.prank(address);
// Change msg.sender for all subsequent calls
vm.startPrank(address);
vm.stopPrank();
// Expect a revert
vm.expectRevert();
vm.expectRevert(CustomError.selector);
vm.expectRevert("Error message");
// Expect an event
vm.expectEmit(true, true, false, true);
emit ExpectedEvent(param1, param2, param3);
actualCall();
// Manipulate block properties
vm.warp(timestamp); // Set block.timestamp
vm.roll(blockNumber); // Set block.number
// Deal ETH or tokens
deal(address, amount);
deal(tokenAddress, recipient, amount);
// Environment variables
vm.envOr("VAR_NAME", defaultValue);
vm.envString("VAR_NAME");
```
### Assertions
```solidity
assertEq(actual, expected);
assertEq(actual, expected, "Error message");
assertTrue(condition);
assertFalse(condition);
assertGt(a, b); // a > b
assertGe(a, b); // a >= b
assertLt(a, b); // a < b
assertLe(a, b); // a <= b
assertApproxEqAbs(a, b, maxDelta);
assertApproxEqRel(a, b, maxPercentDelta);
```
### Testing Events
```solidity
// Declare event (copy from contract or interface)
event Transfer(address indexed from, address indexed to, uint256 value);
function test_EmitsTransferEvent() public {
vm.expectEmit(true, true, false, true);
emit Transfer(from, to, amount);
token.transfer(to, amount);
}
```
### Testing Access Control
```solidity
function test_RevertWhen_NonAdminCalls() public {
vm.prank(USER1); // USER1 is not admin
vm.expectRevert();
cmtat.adminOnlyFunction();
}
function test_AdminCanCall() public {
vm.prank(ADMIN);
cmtat.adminOnlyFunction();
// Assert expected state changes
}
```
### Available Test Addresses (from HelperContract)
```solidity
address constant ZERO_ADDRESS = address(0);
address constant ADMIN = address(1);
address constant USER1 = address(2);
address constant USER2 = address(3);
address constant USER3 = address(4);
```
### Available Roles (from HelperContract)
```solidity
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
bytes32 public constant ENFORCER_ROLE = keccak256("ENFORCER_ROLE");
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
```
## Writing Deployment Scripts
### File Structure
- Place scripts in `script/` directory
- Name script files with `.s.sol` suffix
- Use descriptive names: `DeployCMTATStandalone.s.sol`
### Deployment Script Template
```solidity
//SPDX-License-Identifier: MPL-2.0
pragma solidity ^0.8.20;
import "forge-std/Script.sol";
// Import contracts to deploy
contract DeployMyContract is Script {
function run() external returns (MyContract) {
// Read config from environment
address admin = vm.envOr("ADMIN_ADDRESS", msg.sender);
vm.startBroadcast();
MyContract deployed = new MyContract(admin);
vm.stopBroadcast();
return deployed;
}
}
```
### Environment Variables for Scripts
```solidity
// With default fallback
address admin = vm.envOr("ADMIN_ADDRESS", msg.sender);
uint256 amount = vm.envOr("AMOUNT", uint256(1000));
string memory name = vm.envOr("TOKEN_NAME", "Default");
// Required (reverts if not set)
address required = vm.envAddress("REQUIRED_ADDRESS");
```
### Running Scripts
```bash
# Dry run (simulation)
forge script script/Deploy.s.sol
# With RPC (simulation on fork)
forge script script/Deploy.s.sol --rpc-url $RPC_URL
# Broadcast to network
forge script script/Deploy.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
# With verification
forge script script/Deploy.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_API_KEY
```
### Multi-Chain Deployment
```solidity
function run() public {
vm.createSelectFork("mainnet");
vm.startBroadcast();
new MyContract();
vm.stopBroadcast();
vm.createSelectFork("polygon");
vm.startBroadcast();
new MyContract();
vm.stopBroadcast();
}
```
## Running Tests
```bash
# Run all tests
forge test
# Run with verbosity
forge test -vvv
# Run specific contract
forge test --match-contract BurnModuleTest
# Run specific test
forge test --match-test test_AdminCanBurn
# Run with gas report
forge test --gas-report
# Run with coverage
forge coverage
# Watch mode
forge test --watch
```
## Project-Specific Notes
### CMTAT Constructor Parameters
When deploying CMTATStandalone, these structs are required:
```solidity
ICMTATConstructor.ERC20Attributes memory erc20Attributes = ICMTATConstructor.ERC20Attributes({
name: "Token Name",
symbol: "SYM",
decimalsIrrevocable: 0
});
IERC1643CMTAT.DocumentInfo memory termsDoc = IERC1643CMTAT.DocumentInfo({
name: "Terms",
uri: "https://example.com/terms",
documentHash: bytes32(0)
});
ICMTATConstructor.ExtraInformationAttributes memory extraInfoAttributes = ICMTATConstructor.ExtraInformationAttributes({
tokenId: "TOKEN_ID",
terms: termsDoc,
information: "Token info"
});
ICMTATConstructor.Engine memory engines = ICMTATConstructor.Engine({
ruleEngine: IRuleEngine(address(0))
});
```
### Required Imports for CMTAT
```solidity
import "CMTAT/deployment/CMTATStandalone.sol";
import "CMTAT/interfaces/technical/ICMTATConstructor.sol";
import "CMTAT/interfaces/tokenization/draft-IERC1643CMTAT.sol";
```
## Code Style
- Use descriptive test names
- Group related tests with comments: `// ============ Section Name ============`
- Do NOT use `view` modifier on test functions that use assertionsRelated Skills
cmta
main concept behind cmta
testing
Instructions for writing and organizing Foundry tests in the RuleEngine project
erc173-ownership
ERC-173-A standard interface for ownership of contracts
microsoft-foundry
Deploy, evaluate, and manage Foundry agents end-to-end: Docker build, ACR push, hosted/prompt agent create, container start, batch eval, prompt optimization, prompt optimizer workflows, agent.yaml, dataset curation from traces. USE FOR: deploy agent to Foundry, hosted agent, create agent, invoke agent, evaluate agent, run batch eval, optimize prompt, improve prompt, prompt optimization, prompt optimizer, improve agent instructions, optimize agent instructions, optimize system prompt, deploy model, Foundry project, RBAC, role assignment, permissions, quota, capacity, region, troubleshoot agent, deployment failure, create dataset from traces, dataset versioning, eval trending, create AI Services, Cognitive Services, create Foundry resource, provision resource, knowledge index, agent monitoring, customize deployment, onboard, availability. DO NOT USE FOR: Azure Functions, App Service, general Azure deploy (use azure-deploy), general Azure prep (use azure-prepare).
foundry-framework
Expert usage of Foundry (Forge, Cast, Anvil, Chisel) for smart contract development, testing, and deployment. Includes fuzzing, gas reporting, local development, and deployment scripting capabilities.
microsoft-foundry
Expert knowledge for Microsoft Foundry (aka Azure AI Foundry) development including troubleshooting, best practices, decision making, architecture & design patterns, limits & quotas, security, configuration, integrations & coding patterns, and deployment. Use when building Foundry agents with Azure OpenAI, RAG/indexing, MCP/OpenAPI tools, eval workflows, or CI/CD deployments, and other Microsoft Foundry related development tasks. Not for Microsoft Foundry Classic (use microsoft-foundry-classic), Microsoft Foundry Local (use microsoft-foundry-local), Microsoft Foundry Tools (use microsoft-foundry-tools).
microsoft-foundry-tools
Expert knowledge for Microsoft Foundry Tools (aka Azure AI services, Azure Cognitive Services) development including best practices, decision making, architecture & design patterns, limits & quotas, security, configuration, and integrations & coding patterns. Use when using Content Moderator, Content Understanding analyzers, REST/.NET APIs, quotas, or secure Foundry setups, and other Microsoft Foundry Tools related development tasks. Not for Microsoft Foundry (use microsoft-foundry), Microsoft Foundry Classic (use microsoft-foundry-classic), Microsoft Foundry Local (use microsoft-foundry-local).
microsoft-foundry-local
Expert knowledge for Microsoft Foundry Local (aka Azure AI Foundry Local) development including troubleshooting, best practices, decision making, configuration, and integrations & coding patterns. Use when using Foundry Local CLI, REST/SDK APIs, OpenAI clients, LangChain/Open WebUI, or Olive model builds, and other Microsoft Foundry Local related development tasks. Not for Microsoft Foundry (use microsoft-foundry), Microsoft Foundry Classic (use microsoft-foundry-classic), Microsoft Foundry Tools (use microsoft-foundry-tools), Azure Local (use azure-local).
microsoft-foundry-classic
Expert knowledge for Microsoft Foundry Classic (aka Azure AI Foundry classic) development including troubleshooting, best practices, decision making, architecture & design patterns, limits & quotas, security, configuration, integrations & coding patterns, and deployment. Use when building Foundry agents, RAG/vector search, function calling, realtime audio, or fine-tuned Azure OpenAI models, and other Microsoft Foundry Classic related development tasks. Not for Microsoft Foundry (use microsoft-foundry), Microsoft Foundry Local (use microsoft-foundry-local), Microsoft Foundry Tools (use microsoft-foundry-tools).
microsoft-foundry
Use this skill to work with Microsoft Foundry (Azure AI Foundry) and tools from Foundry MCP server: deploy AI models, manage AI agents (create, deploy, invoke, run, troubleshoot Foundry Agents), manage RBAC permissions and role assignments, manage quotas and capacity, create Foundry resources. USE FOR: Microsoft Foundry, AI Foundry, create agent, deploy agent, debug agent, invoke agent, run agent, agent chat, evaluate agent, agent monitoring, deploy model, model catalog, knowledge index, create Foundry project, new Foundry project, set up Foundry, onboard to Foundry, create Foundry resource, create AI Services, AIServices kind, register resource provider, enable Cognitive Services, setup AI Services account, create resource group for Foundry, RBAC, role assignment, quota, capacity, TPM, deployment failure, QuotaExceeded. DO NOT USE FOR: Azure Functions (use azure-functions), App Service (use azure-create-app), generic Azure resource creation (use azure-create-app).
foundry
Foundry toolkit for Solidity development — forge (build/test), cast (chain interaction), anvil (local node), and chisel (REPL). Covers project setup, testing patterns (unit, fuzz, invariant, fork), deployment via forge script, contract verification, gas optimization, and debugging. Works on any EVM chain.
foundry
You are an expert in Foundry, the blazing-fast Ethereum development toolkit written in Rust. You help developers write, test, deploy, and debug Solidity smart contracts using Forge (testing), Cast (CLI interactions), Anvil (local node), and Chisel (Solidity REPL) — with native Solidity testing (no JavaScript), fuzz testing, gas optimization, and fork testing against mainnet state.