solidity — Claude Code skill: secure contracts and gas
A skill for writing and reviewing Solidity contracts: reentrancy defenses, gas optimization, testing, and React frontend wiring.
npx skills add Mindrally/skills --skill solidity -a claude-codeWhat solidity does
The skill hands your agent a rulebook for Solidity work. Code structure and security come first: explicit visibility modifiers, NatSpec docs, the Checks-Effects-Interactions pattern, ReentrancyGuard, SafeERC20, OpenZeppelin's AccessControl, Solidity 0.8.0+ for overflow protection, Pausable circuit breakers, timelocks and multisig for sensitive calls.
Gas gets its own section. immutable for constructor-set values, custom errors instead of revert strings, tight storage packing. Static analysis runs through Slither and Mythril, while Hardhat covers testing and development, with pre-commit linting on top. Advanced patterns are listed too: Chainlink VRF for randomness, state machines, ERC20Snapshot, ERC20Permit and ERC20Votes.
On the frontend side the skill wants contract calls typed from ABIs (TypeChain or wagmi/viem codegen), wallet and chain state modeled explicitly, and the transaction lifecycle surfaced from submitted through confirmed. It advises simulating with eth_call and gas estimation before asking for a signature. If your contracts sit below 0.8.0, the overflow guidance won't apply — worth checking your compiler version.
What it helps with
- harden a contract against reentrancy
- cut gas on deployment and at runtime
- wire Slither and Mythril into CI
- generate TypeScript types from ABIs
- show transaction status from submit to confirmation in the UI
Example prompts for the agent
- review this contract for reentrancy and access control bugs
- optimize gas here using immutable variables and custom errors
- generate types from the ABI and wire the contract call into React
How to install solidity
1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill solidity -a claude-code2Manually: put the files in place
~/.claude/skills/solidity/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/solidity/
1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill solidity -a codex2Manually: put the files in place
.agents/skills/solidity/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill solidity -a cursor2Manually: put the files in place
.cursor/skills/solidity/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install Mindrally/skills solidity2Manually: put the files in place
.github/skills/solidity/SKILL.md1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill solidity -a gemini-cli2Platform CLI
gemini skills install https://github.com/Mindrally/skills --path solidityManually: put the files in place
.devin/skills/solidity/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add Mindrally/skills --skill solidity -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about solidity
How do I install the solidity skill in Claude?
Run npx skills add Mindrally/skills --skill solidity -a claude-code. The skill file then lives at ~/.claude/skills/solidity/SKILL.md.
What does the solidity skill do?
It gives the agent rules for Solidity development and review: security patterns, gas optimization, testing, and Web3 frontend integration.
What tools does it rely on?
The guidance names Slither and Mythril for static analysis, Hardhat for testing and development, OpenZeppelin for contracts, Chainlink VRF for randomness, and TypeChain or wagmi/viem for frontend types.
Source text
SKILL.md · Apache-2.0
--- name: solidity description: "Best practices for secure, gas-efficient Solidity smart contract development and Web3 frontend integration. Use when writing or reviewing Solidity contracts, hardening against reentrancy and access-control bugs, optimizing gas usage, setting up Hardhat/Foundry testing and static analysis, or wiring a React frontend to wallets, providers, and on-chain transactions." metadata: maintainer: Mindrally source: https://github.com/Mindrally/skills --- # Solidity This skill covers best practices for Solidity smart contract development, including security patterns, gas optimization, testing/tooling, and integrating contracts with a Web3 React frontend. ## Core Principles - Cut the fluff. Code or detailed explanations only - Maintain brevity while prioritizing accuracy and depth - Answer first, explain later when needed ## Code Structure & Security - Use explicit visibility modifiers and NatSpec documentation - Apply function modifiers to reduce redundancy - Follow naming conventions: - CamelCase for contracts - PascalCase for interfaces (prefix with "I") - Implement Interface Segregation Principle - Use proxy patterns for upgradeable contracts - Emit comprehensive events for state changes - Follow Checks-Effects-Interactions pattern against reentrancy ## Security Best Practices - Use OpenZeppelin's AccessControl for permissions - Require Solidity 0.8.0+ for overflow/underflow protection - Use Pausable pattern for circuit breakers - Implement ReentrancyGuard for additional protection - Use SafeERC20 for token interactions - Employ pull-over-push payment patterns - Implement timelocks and multisig controls for sensitive operations ## Gas Optimization - Optimize gas consumption (deployment and runtime) - Use immutable variables for constructor-set values - Use custom errors instead of revert strings - Pack storage variables efficiently - Use appropriate data types ## Tools & Analysis - Integrate Slither and Mythril for static analysis - Leverage Hardhat's testing and development environment - Implement robust CI/CD pipelines - Use pre-commit linting tools ## Advanced Patterns - Chainlink VRF for randomness - Strategic assembly use with extensive documentation - State machine patterns for complex logic - ERC20Snapshot, ERC20Permit, and ERC20Votes for specialized tokens ## Testing & Quality - Comprehensive unit, integration, and end-to-end testing - Property-based testing approaches - High coverage targets - Regular security audits ## Web3 Frontend Integration - Keep frontend code that talks to contracts type-safe and explicit — generate TypeScript types from ABIs (e.g. via TypeChain or wagmi/viem codegen) rather than hand-writing contract call signatures - Treat wallet connection, chain/network state, and transaction status as explicit, typed state (connected/connecting/wrong-network/error), not implicit booleans - Surface transaction lifecycle clearly in the UI: submitted, pending confirmation, confirmed, reverted — never assume a submitted transaction succeeded - Validate and simulate transactions (e.g. `eth_call`/gas estimation) before prompting the user to sign, to catch reverts early - Never trust client-side reads of contract state for authorization decisions — always re-verify on-chain in the contract itself - Handle provider/RPC failures and user rejection of signature requests as expected, recoverable error states
© Mindrally · Apache-2.0 · Mindrally/skills