solidity-gas-optimization — Claude Code skill: cut Solidity gas costs
A skill packing 80+ Solidity gas optimization techniques from the RareSkills book. Useful when writing, reviewing or auditing contracts.
npx skills add pseudoyu/agent-skills --skill solidity-gas-optimization -a claude-codeWhat solidity-gas-optimization does
The skill hands your agent a rule set for saving gas in Solidity, split into 8 categories and ordered by impact and risk. Storage work sits at the top: skip zero-to-one writes, pack variables into fewer slots, cache storage reads, move values into constants and immutables. Below that come deployment, calldata, design patterns, cross-contract calls, compiler flags and assembly tricks.
Inside you get a priority table, short bad/good code samples, and pointers to references/solidity-gas-guidelines.md plus a references/rules/ folder with individual patterns per category. Lookup is plain grep over those rule files, by storage or assembly or struct.
Some techniques are flagged as unsafe for production: making every function payable, ignoring the return value of send(), branching on gasleft(). There is also a section on advice that no longer holds — the claim that external beats public is one of them. The skill tells you to benchmark both versions, since compiler behavior shifts with version and context, and --via-ir can make some tricks pointless.
What it helps with
- lower the deployment cost of a contract
- pack struct fields into fewer storage slots
- swap string revert messages for custom errors
- pick between ERC721 and ERC1155 for an NFT collection
- spot outdated gas advice in an existing contract
Example prompts for the agent
- Review this contract for gas savings and show what can be packed in storage
- Rewrite the loop in
processBatchfollowing the gas optimization rules - Compare ERC721 and ERC1155 gas costs for this collection
How to install solidity-gas-optimization
1Skills CLI (Vercel)
npx skills add pseudoyu/agent-skills --skill solidity-gas-optimization -a claude-code2Manually: put the files in place
~/.claude/skills/solidity-gas-optimization/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/solidity-gas-optimization/
1Skills CLI (Vercel)
npx skills add pseudoyu/agent-skills --skill solidity-gas-optimization -a codex2Manually: put the files in place
.agents/skills/solidity-gas-optimization/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add pseudoyu/agent-skills --skill solidity-gas-optimization -a cursor2Manually: put the files in place
.cursor/skills/solidity-gas-optimization/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install pseudoyu/agent-skills solidity-gas-optimization2Manually: put the files in place
.github/skills/solidity-gas-optimization/SKILL.md1Skills CLI (Vercel)
npx skills add pseudoyu/agent-skills --skill solidity-gas-optimization -a gemini-cli2Platform CLI
gemini skills install https://github.com/pseudoyu/agent-skills --path skills/solidity-gas-optimizationManually: put the files in place
.devin/skills/solidity-gas-optimization/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add pseudoyu/agent-skills --skill solidity-gas-optimization -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-gas-optimization
How do I install solidity-gas-optimization in Claude?
Run npx skills add pseudoyu/agent-skills --skill solidity-gas-optimization -a claude-code. The skill lands at ~/.claude/skills/solidity-gas-optimization/SKILL.md.
What does solidity-gas-optimization do?
It feeds the agent Solidity gas rules covering storage, deployment, calldata, design patterns, cross-contract calls, compiler options and assembly. Rules are ranked by impact and risk.
Which platforms support the skill?
Claude, Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode, each with its own install command from the pseudoyu/agent-skills repository.