Gas optimization analysis and implementation for Solidity contracts. Triggers on weasel gas, weasel optimize, or weasel efficiency.
View on GitHubSelect agents to install to:
npx add-skill https://github.com/slvDev/weasel/blob/main/weasel/skills/weasel-gas/SKILL.md -a claude-code --skill weasel-gasInstallation paths:
.claude/skills/weasel-gas/# Weasel Gas Optimizer
Expert in identifying and implementing gas optimizations for Solidity smart contracts.
## When to Activate
- User wants to optimize gas usage
- User asks about efficiency
- User mentions gas costs
## Workflow
1. **Detect Chain** - CRITICAL: Identify target chain BEFORE analysis
2. **Scan** - Run `weasel_analyze` with severity: "Gas"
3. **Filter** - Remove findings irrelevant to target chain
4. **Summarize** - Quick count by impact level (chain-adjusted)
5. **Ask** - "Fix high impact? Medium? All? Pick specific?"
6. **Fix** - Implement directly in code
7. **Verify** - Run tests
## Step 1: Chain Detection (CRITICAL - DO NOT SKIP)
**Before any gas analysis, determine the target chain.**
### Detection Methods
1. **Config files** (most reliable):
```
hardhat.config.js/ts → networks: { mainnet, arbitrum, optimism, polygon, bsc }
foundry.toml → [rpc_endpoints] or comments
truffle-config.js → networks section
```
2. **README.md** - Look for deployment targets, chain mentions
3. **Dependencies/Files**:
- `foundry.toml`, `hardhat.config.*`, `truffle-config.js` → **EVM (Supported)**
- `@arbitrum/*` → Arbitrum L2
- `@eth-optimism/*` → Optimism L2
- `Anchor.toml`, `*.rs` → Solana (NOT SUPPORTED)
- `Move.toml`, `*.move` → Move (NOT SUPPORTED)
- `tronbox`, `tronweb` → Tron (NOT SUPPORTED)
- No `.sol` files → NOT SUPPORTED
4. **Ask user if unclear**: "Which EVM chain is this for? (Ethereum/Arbitrum/Optimism/Polygon/BSC/Other)"
- If user says non-EVM (Tron, Solana, etc.) → Not supported, stop.
### Chain Categories
| Category | Chains | Supported |
|----------|--------|-----------|
| **EVM L1** | Ethereum mainnet | ✓ Full |
| **EVM L2** | Arbitrum, Optimism, Base, zkSync, Scroll | ✓ Filtered |
| **EVM L1 (cheap)** | Polygon, BSC, Avalanche, Fantom | ✓ Filtered |
| **Non-EVM** | Tron, Solana, Aptos, Sui, CosmWasm, TON, etc. | ❌ NO |
**Weasel supports Solidity on EVM chains only.**
## Chain-Specific Rules
##