solidity
Skill1 starsChanged 6 months agoMITView on GitHub
Create production grade smart contracts. Use this skill when the user asks to write smart contracts, specially if they are going to be deployed to production (to a mainnet, or used in a mainnet script).
3 other projects use a version of this.
Adopted by
Most recently taken up by
- G1Joshi/Agent-Skillstheir own version, first seen Oct 13, 2026
- Mindrally/skillstheir own version, first seen Oct 8, 2026
- 0xSero/claude-skill-dirtheir own version, first seen Nov 15, 2025
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- Mindrally/skills★ 275same name
- G1Joshi/Agent-Skills★ 15same name
- 0xSero/claude-skill-dir★ 4same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository16 other files it gives its agents.
- audit-contractSkill
- auditSkill
- enosys-contractsSkill
- enosys-dex-v3Skill
- flare-dapp-pitfallsSkill
- flare-fassetsSkill
- flare-fdcSkill
- flare-ftsoSkill
- flare-generalSkill
- flare-networkSkill
- flare-securitySkill
- flare-smart-accountsSkill
- gas-optimizeSkill
- flare-builders-toolkitSkill
- test-foundrySkill
- test-hardhatSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
27 rules. 0 are common, 18 are distinctive, and 9 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
18
Distinctive
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 28
Prefer revert over require, with custom errors that are prefix'd with the contract name and 2 underscores.
- Distinctive: line 103
Use the branching tree technique when creating tests Credit for this to Paul R Berg
- Very specific: line 107
Create a .tree file
- Distinctive: line 108
Consider all possible execution paths
- Distinctive: line 109
Consider what contract state leads to what path
- Distinctive: line 110
Consider what function params lead to what paths
- Distinctive: line 162
Prefer strict pragma versions for contracts, and floating pragma versions for tests, libraries, abstract contracts, interfaces, and scripts.
- Distinctive: line 164
Add a security contact to the natspec at the top of your contracts
- Distinctive: line 175
NEVER. EVER. NEVER. Have private keys be in plain text.
- Distinctive: line 181
Don't initialize variables to default values
- Distinctive: line 193
Prefer using named return variables if this can omit declaring local variables
- Very specific: line 208
Prefer calldata instead of memory for read-only function inputs
- Very specific: line 210
Don't cache calldata array length
- Very specific: line 225
Use msg.sender instead of owner inside onlyOwner functions
- Very specific: line 227
Use SafeTransferLib::safeTransferETH instead of Solidity call() to send ETH
- Very specific: line 231
Use nonReentrant modifier before other modifiers
- Very specific: line 233
Use ReentrancyGuardTransient for faster nonReentrant modifiers
- Very specific: line 235
Prefer Ownable2Step instead of Ownable
- Distinctive: line 237
Don't copy an entire struct from storage to memory if only a few slots are required
- Distinctive: line 239
Remove unnecessary "context" structs and/or remove unnecessary variables from context structs
- Distinctive: line 241
When declaring storage and structs, align the order of declarations to pack variables into the minimum number of storage slots.
- Distinctive: line 247
If modifiers perform identical storage reads as the function body, refactor modifiers to internal functions to prevent identical storage …
- Distinctive: line 249
Use Foundry's encrypted secure private key storage instead of plaintext environment variables
- Distinctive: line 261
Use safe-utils or equivalent tooling for governance proposals.
- Distinctive: line 263
Write fork tests that verify expected protocol state after governance proposals execute.
- Distinctive: line 285
Every project should have a minimum CI pipeline running in parallel (use a matrix strategy).
- Distinctive: line 290
Before committing code that you think is done, be sure to run aderyn and/or slither on the codebase and inspect the output.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Solidity Development Standards
Instructions for how to write solidity code, from the Cyfrin security team.
Philosophy
- Everything will be attacked - Assume that any code you write will be attacked and write it defensively.
Code Quality and Style
- Absolute and named imports only — no relative (
..) paths
// good
import {MyContract} from "contracts/MyContract.sol";
// bad
import "../MyContract.sol";- Prefer
revertoverrequire, with custom errors that are prefix'd with the contract name and 2 underscores.
error ContractName__MyError();
// Good
myBool = true;
if (myBool) {
revert ContractName__MyError();
}
// bad
require(myBool, "MyError");- In tests, prefer stateless fuzz tests over unit tests
// good - using foundry's built in stateless fuzzer
function testMyTest(uint256 randomNumber) { }
// bad
function testMyTest() {
uint256 randomNumber = 0;
}Additionally, write invariant (stateful) fuzz tests for core protocol properties. Use invariant-driven development: identify O(1) properties that must always hold and encode them directly into core functions (FREI-PI pattern). Use a multi-fuzzing setup like Chimera to run the same invariant suite across Foundry, Echidna, and Medusa — different fuzzers find different bugs.
- Functions should be grouped according to their visibility and ordered:
constructor
receive function (if exists)
fallback function (if exists)
user-facing state-changing functions
(external or public, not view or pure)
user-facing read-only functions
(external or public, view or pure)
internal state-changing functions
(internal or private, not view or pure)
internal read-only functions
(internal or private, view or pure)- Headers should look like this:
/*//////////////////////////////////////////////////////////////
INTERNAL STATE-CHANGING FUNCTIONS
//////////////////////////////////////////////////////////////*/- Layout of file
Pragma statements
Import statements
Events
Errors
Interfaces
Libraries
ContractsLayout of contract:
Type declarations
State variables
Events
Errors
Modifiers
Functions- Use the branching tree technique when creating tests Credit for this to Paul R Berg
- Target a function
- Create a
.treefile - Consider all possible execution paths
- Consider what contract state leads to what path
- Consider what function params lead to what paths
- Define "given state is x" nodes
- Define "when parameter is x" node
- Define final "it should" tests
Example:
├── when the id references a null stream
│ └── it should revert
└── when the id does not reference a null stream
├── given assets have been fully withdrawn
│ └── it should return DEPLETED
└── given assets have not been fully withdrawn
├── given the stream has been canceled
│ └── it should return CANCELED
└── given the stream has not been canceled
├── given the start time is in the future
│ └── it should return PENDING
└── given the start time is not in the future
├── given the refundable amount is zero
│ └── it should return SETTLED
└── given the refundable amount is not zero
└── it should return STREAMINGExample:
function test_RevertWhen_Null() external {
uint256 nullStreamId = 1729;
vm.expectRevert(abi.encodeWithSelector(Errors.SablierV2Lockup_Null.selector, nullStreamId));
lockup.statusOf(nullStreamId);
}
modifier whenNotNull() {
defaultStreamId = createDefaultStream();
_;
}
function test_StatusOf()
external
whenNotNull
givenAssetsNotFullyWithdrawn
givenStreamNotCanceled
givenStartTimeNotInFuture
givenRefundableAmountNotZero
{
LockupLinear.Status actualStatus = lockup.statusOf(defaultStreamId);
LockupLinear.Status expectedStatus = LockupLinear.Status.STREAMING;
assertEq(actualStatus, expectedStatus);
}- Prefer strict pragma versions for contracts, and floating pragma versions for tests, libraries, abstract contracts, interfaces, and scripts.
- Add a security contact to the natspec at the top of your contracts
/**
* @custom:security-contact mycontact@example.com
* @custom:security-contact see https://mysite.com/ipfs-hash
*/ - Remind people to get an audit if they are deploying to mainnet, or trying to deploy to mainnet
- NEVER. EVER. NEVER. Have private keys be in plain text. The only exception to this rule is when using a default key from something like anvil, and it must be marked as such.
- This includes in your deploy scripts. We should always use
forge script <path> --account $ACCOUNT --sender $SENDERfor our deploy scripts, and never usevm.envUnit()in our scripts. - For hardhat, you want to use hardhat encrypted keystores
- This includes in your deploy scripts. We should always use
- Whenever a smart contract is deployed that is ownable or has admin properties (like,
onlyOwner), the admin must be a multisig from the very first deployment — never use the deployer EOA as admin (testnet is the only acceptable exception). See Trail of Bits: Maturing Your Smart Contracts Beyond Private Key Risk — "Layer 1" (single EOA) governance is no longer acceptable for DeFi. - Don't initialize variables to default values
// good
uint256 x;
bool y;
// bad
uint256 x = 0;
bool y = false;- Prefer using named return variables if this can omit declaring local variables
// good
function getBalance() external view returns (uint256 balance) {
balance = balances[msg.sender];
}
// bad
function getBalance() external view returns (uint256) {
uint256 balance = balances[msg.sender];
return balance;
}- Prefer
calldatainstead ofmemoryfor read-only function inputs - Don't cache
calldataarray length
// good — calldata length is cheap to read
for (uint256 i; i < items.length; ++i) { }
// bad — unnecessary caching for calldata
uint256 len = items.length;
for (uint256 i; i < len; ++i) { }- Reading from storage is expensive — prevent identical storage reads by caching unchanging storage slots and passing/using cached values
- Revert as quickly as possible; perform input checks before checks which require storage reads or external calls
- Use
msg.senderinstead ofownerinsideonlyOwnerfunctions - Use
SafeTransferLib::safeTransferETHinstead of Soliditycall()to send ETH - Modify input variables instead of declaring an additional local variable when an input variable's value doesn't need to be preserved
- Use
nonReentrantmodifier before other modifiers - Use
ReentrancyGuardTransientfor fasternonReentrantmodifiers - Prefer
Ownable2Stepinstead ofOwnable - Don't copy an entire struct from storage to memory if only a few slots are required
- Remove unnecessary "context" structs and/or remove unnecessary variables from context structs
- When declaring storage and structs, align the order of declarations to pack variables into the minimum number of storage slots. If variables are frequently read or written together, pack them in the same slot if possible
- For non-upgradeable contracts, declare variables as
immutableif they are only set once in the constructor - Enable the optimizer in
foundry.toml - If modifiers perform identical storage reads as the function body, refactor modifiers to internal functions to prevent identical storage reads
- Use Foundry's encrypted secure private key storage instead of plaintext environment variables
- Upgrades: When upgrading smart contracts, do not change the order or type of existing variables, and do not remove them. This can lead to storage collisions. Also write tests for any upgrades.
Deployment
Use Foundry scripts (forge script) for both production deployments and test setup. This ensures the same deployment logic runs in development and on mainnet, making deployments more auditable and reducing the gap between test and production environments. Avoid custom test-only setup code that diverges from real deployment paths. Ideally, your deploy scripts are audited as well.
Example: use a shared base script that both tests and production inherit from, like this BaseTest using scripts pattern.
Governance
Use safe-utils or equivalent tooling for governance proposals. This makes multisig interactions testable, auditable, and reproducible through Foundry scripts rather than manual UI clicks. If you must use a UI, it's preferred to keep your transactions private, using a UI like localsafe.eth.
Write fork tests that verify expected protocol state after governance proposals execute. Fork testing against mainnet state catches misconfigurations that unit tests miss — for example, the Moonwell price feed misconfiguration would have been caught by a fork test asserting correct oracle state post-proposal.
// good - fork test verifying governance proposal outcome
function testGovernanceProposal_UpdatesPriceFeed() public {
vm.createSelectFork(vm.envString("MAINNET_RPC_URL"));
// Execute the governance proposal
_executeProposal(proposalId);
// Verify expected state after proposal
address newFeed = oracle.priceFeed(market);
assertEq(newFeed, EXPECTED_CHAINLINK_FEED);
// Verify the feed returns sane values
(, int256 price,,,) = AggregatorV3Interface(newFeed).latestRoundData();
assertGt(price, 0);
}CI
Every project should have a minimum CI pipeline running in parallel (use a matrix strategy). Suggested minimum:
solhint— Solidity linter for style and security rulesforge build --sizes— verify contract sizes are under the 24KB deployment limitslitheroraderyn— static analysis for common vulnerability patterns- Before committing code that you think is done, be sure to run aderyn and/or slither on the codebase and inspect the output. Even warnings may lead you to find issues in the codebase.
- Fuzz/invariant testing — run Echidna, Medusa, or Foundry invariant tests with a reasonable time budget (~10 min per tool, in parallel via matrix)
Tool updates
Foundry
To install foundry dependencies, you don't need the --no-commit flag anymore.
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
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.

