solidity-security
Skill4 starsChanged 9 months agoMITView on GitHub
[AUTO-INVOKE] MUST be invoked BEFORE writing or modifying any Solidity contract (.sol files). Covers private key handling, access control, reentrancy prevention, gas safety, and pre-audit checklists. Trigger: any task involving creating, editing, or reviewing .sol source files.
- Reads credentials
7 other projects use a version of this.
Adopted by
Most recently taken up by
- dorian-akhs/skillstheir own version, first seen Sep 1, 2026
- ai4brands-design/claude-skillstheir own version, first seen Mar 22, 2026
- CodeWithBehnam/cc-docstheir own version, first seen Mar 15, 2026
- whatthehackinsg/agent-auctiontheir own version, first seen Mar 7, 2026
- suhailkakar/web3-godmode-configtheir own version, first seen Feb 12, 2026
- wpank/aitheir own version, first seen Feb 10, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- wpank/ai★ 11same name
- xfstudio/skills★ 9same name
- ai4brands-design/claude-skills★ 2same name
- CodeWithBehnam/cc-docs★ 2same name
- whatthehackinsg/agent-auction★ 2same name
- suhailkakar/web3-godmode-config★ 1same name
- dorian-akhs/skills★ 0same 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 repository10 other files it gives its agents.
- claude-code-usageSkill
- defi-securitySkill
- git-workflowSkill
- solidity-auditSkill
- solidity-checklistSkill
- solidity-codingSkill
- solidity-debugSkill
- solidity-deploySkill
- solidity-testingSkill
- token-antiflashSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. 0 are common, 7 are distinctive, and 8 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
7
Distinctive
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Always respond in the same language the user is using: If the user asks in Chinese, respond in Chinese.
- Distinctive: line 14
Before an on-chain write, let the developer choose a signing method:
- Very specific: line 15
Foundry Keystore (recommended): import with cast wallet import <NAME> --interactive and use --account <NAME>.
- Distinctive: line 17
Never expose private keys in logs, screenshots, conversations, or commits
- Very specific: line 19
Add .env to .gitignore — verify with git status before every commit
- Very specific: line 20
Never read or print a developer's .env.
- Distinctive: line 24
When writing or reviewing Solidity code, apply these rules:
- Very specific: line 48
All contracts with external calls: inherit ReentrancyGuard, add nonReentrant modifier
- Very specific: line 49
Import: @openzeppelin/contracts/security/ReentrancyGuard.sol (OZ 4.9.x)
- Very specific: line 50
Always apply CEI pattern even with ReentrancyGuard:
- Distinctive: line 67
Avoid unbounded loops over dynamic arrays — use pagination or pull patterns
- Distinctive: line 71
Before submitting code for review or audit, verify:
- Very specific: line 125
When slither MCP is configured, prefer it over the CLI for structured analysis:
- Distinctive: line 134
Recommended: Use slither MCP when working with AI agents (results are structured and actionable).
- Very specific: line 136
Graceful degradation: If neither slither MCP nor slither CLI is available, rely on the Pre-Audit Checklist above and forge test --fuzz-runs …
“Common” is measured: kept by at least 6 in 10 of the 5 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 Security Standards
Language Rule
- Always respond in the same language the user is using. If the user asks in Chinese, respond in Chinese. If in English, respond in English.
Private Key Protection
- Before an on-chain write, let the developer choose a signing method:
- Foundry Keystore (recommended): import with
cast wallet import <NAME> --interactiveand use--account <NAME>. - Environment file: store
PRIVATE_KEYin.env, load it withsource .env, and reference"$PRIVATE_KEY"; never paste the literal value into a command.
- Foundry Keystore (recommended): import with
- Never expose private keys in logs, screenshots, conversations, or commits
- Provide
.env.examplewith placeholder values for team reference - Add
.envto.gitignore— verify withgit statusbefore every commit - Never read or print a developer's
.env; only provide commands for the developer to run
Security Decision Rules
When writing or reviewing Solidity code, apply these rules:
| Situation | Required Action |
| External ETH/token transfer | Use ReentrancyGuard + Checks-Effects-Interactions (CEI) pattern |
| ERC20 token interaction | Use SafeERC20 — call safeTransfer / safeTransferFrom, never raw transfer / transferFrom |
| Owner-only function | Inherit Ownable2Step (preferred) or Ownable from OZ 4.9.x — Ownable2Step prevents accidental owner loss |
| Multi-role access | Use AccessControl from @openzeppelin/contracts/access/AccessControl.sol |
| Token approval | Use safeIncreaseAllowance / safeDecreaseAllowance from SafeERC20 — never raw approve |
| Price data needed | Use Chainlink AggregatorV3Interface if feed exists; otherwise TWAP with min-liquidity check — never use spot pool price directly |
| Upgradeable contract | Prefer UUPS (UUPSUpgradeable) over TransparentProxy; always use Initializable |
| Solidity version < 0.8.0 | Must use SafeMath — but strongly prefer upgrading to 0.8.20+ |
| Emergency scenario | Inherit Pausable, add whenNotPaused to user-facing functions; keep admin/emergency functions unpaused |
| Whitelist / airdrop | Use MerkleProof for gas-efficient verification — never store full address lists on-chain |
| Signature-based auth | Use ECDSA + EIP712 — never roll custom signature verification |
| Signature content | Signature must bind chainId + nonce + msg.sender + deadline — prevent replay and cross-chain reuse |
| Cross-chain bridge / third-party dependency | Audit all inherited third-party contract code — never assume dependencies are safe |
| Deprecated / legacy contracts | Permanently pause or selfdestruct deprecated contracts — never leave unused contracts callable on-chain |
| UUPS upgrade pattern | _authorizeUpgrade must have onlyOwner; implementation constructor calls _disableInitializers(); retain onlyProxy on upgradeTo — EVMbench/basin H-01 |
| Multi-contract trust boundary | Router/Registry relay calls must verify source contract authorization; never trust caller identity inside flash loan callbacks — EVMbench/noya H-08 |
| Counter/ID + external call | All counter increments and ID assignments must complete before external calls; ETH refunds must be last — EVMbench/phi H-06 |
Reentrancy Protection
- All contracts with external calls: inherit
ReentrancyGuard, addnonReentrantmodifier- Import:
@openzeppelin/contracts/security/ReentrancyGuard.sol(OZ 4.9.x)
- Import:
- Always apply CEI pattern even with
ReentrancyGuard:- Checks — validate all conditions (
require) - Effects — update state variables
- Interactions — external calls last
- Checks — validate all conditions (
Input Validation
- Reject
address(0)for all address parameters - Reject zero amounts for fund transfers
- Validate array lengths match when processing paired arrays
- Bound numeric inputs to reasonable ranges (prevent dust attacks, gas griefing)
Gas Control
- Deployment commands must include
--gas-limit(recommended >= 3,000,000) - Monitor gas with
forge test --gas-report— review before every PR - Configure optimizer in
foundry.toml:optimizer = true,optimizer_runs = 200 - Avoid unbounded loops over dynamic arrays — use pagination or pull patterns
Pre-Audit Checklist
Before submitting code for review or audit, verify:
Access & Control:
- All external/public functions have
nonReentrantwhere applicable - No
tx.originused for authentication (usemsg.sender) - No
delegatecallto untrusted addresses - Owner transfer uses
Ownable2Step(notOwnable) to prevent accidental loss - Contracts with user-facing functions inherit
Pausablewithpause()/unpause() - UUPS
_authorizeUpgradehasonlyOwnermodifier — EVMbench/basin H-01 - Implementation constructor calls
_disableInitializers()— EVMbench/basin H-01 - Router/Registry relay operations verify source contract authorization — EVMbench/noya H-08
Token & Fund Safety:
- All ERC20 interactions use
SafeERC20(safeTransfer/safeTransferFrom) - No raw
token.transfer()orrequire(token.transfer())patterns - Token approvals use
safeIncreaseAllowance, not rawapprove - All
external callreturn values checked
Code Quality:
- Events emitted for every state change
- No hardcoded addresses — use config or constructor params
.envis in.gitignore
Oracle & Price (if applicable):
- Price data sourced from Chainlink feed or TWAP — never raw spot price
- Oracle has minimum liquidity check — revert if pool reserves too low
- Price deviation circuit breaker in place
Testing:
forge testpasses with zero failuresforge coverageshows adequate coverage on security-critical paths- Fuzz tests cover arithmetic edge cases (zero, max uint, boundary values)
Security Verification Commands
# Run all tests with gas report
forge test --gas-report
# Fuzz testing with higher runs for critical functions
forge test --fuzz-runs 10000
# Check test coverage
forge coverage
# Dry-run deployment to verify no runtime errors
forge script script/Deploy.s.sol --fork-url $RPC_URL -vvvv
# Static analysis (if slither installed locally)
slither src/Slither MCP Integration (if available)
When slither MCP is configured, prefer it over the CLI for structured analysis:
| Approach | When to Use |
slither src/ (CLI) | Quick local scan, raw terminal output |
slither MCP get_detector_results | Structured results with impact/confidence filtering, AI can parse and reason about findings |
slither MCP get_contract_metadata | Understanding contract structure before reviewing code |
slither MCP get_function_source | Locating exact function implementations faster than grep |
Recommended: Use slither MCP when working with AI agents (results are structured and actionable). Use CLI for quick local checks during development.
Graceful degradation: If neither slither MCP nor slither CLI is available, rely on the Pre-Audit Checklist above and forge test --fuzz-runs 10000 for coverage.
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.

