Skip to main content
skill CX Codex

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.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add pseudoyu/agent-skills --skill solidity-gas-optimization -a claude-code
Open on GitHub

What 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 processBatch following 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-code

2Manually: put the files in place

~/.claude/skills/solidity-gas-optimization/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/solidity-gas-optimization/

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.

Similar skills

All skills for Programming languages →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor