custom-errors

custom-errors is a skill for Claude Code, Codex from zaryab2000/decipher-gas-optimizoor. It costs 97 tokens per session (1,284 once invoked), scanned A, original, MIT.

A Solidity review guide for replacing text-based failure messages with custom errors, a compact way for a contract to report why an operation failed.

In plain words
What is it for?
Use it when writing or reviewing require and revert statements, especially in Solidity 0.8.4 or newer contracts.
Why use it?
It helps reduce contract size and the cost of revert paths while keeping failure conditions identifiable.

Skill for Claude CodeCodex

Part of the decipher-gas-optimizoor plugin — 11 skills, 5 commands, 1 agent shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/zaryab2000/decipher-gas-optimizoor/custom-errors
Any agent
npx skills add zaryab2000/decipher-gas-optimizoor --skill custom-errors
Clone the repo
git clone --depth 1 https://github.com/zaryab2000/decipher-gas-optimizoor

Made for: Claude Code, Codex.

Or install decipher-gas-optimizoor, the plugin that ships this one along with the rest of its 11 skills, 5 commands, 1 agent.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for custom-errors

README.md
[![agentmods](https://agentmods.dev/badge/skills/zaryab2000/decipher-gas-optimizoor/custom-errors.svg)](https://agentmods.dev/skills/zaryab2000/decipher-gas-optimizoor/custom-errors)
Your own site
<a href="https://agentmods.dev/skills/zaryab2000/decipher-gas-optimizoor/custom-errors"><img src="https://agentmods.dev/badge/skills/zaryab2000/decipher-gas-optimizoor/custom-errors.svg" alt="Measured on agentmods" height="20"></a>
Per session 97 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,284 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00097 $0.01284
Opus 5 $0.00048 $0.00642
Sonnet 5 $0.00019 $0.00257
Haiku 4.5 $0.00010 $0.00128

Measured 5d ago against content hash 7994eeebffca, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

custom-errors scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/custom-errors/SKILL.md · 126 lines

How it starts

The opening of the file, as written. The whole thing — 126 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Purpose

Convert every string-based revert in a Solidity contract to a custom error. Custom errors (introduced in Solidity 0.8.4) use a 4-byte selector instead of a string, reducing bytecode size and runtime revert cost by ~15–50 gas per revert path.

When to Use This Skill

Use when:

  • Claude is writing any require(condition, "string") statement
  • Claude is writing any revert("string literal") statement
  • The user asks Claude to review revert logic in a contract
  • Claude is about to finalize any function that contains error conditions
  • A contract imports OpenZeppelin or other libraries that still use string reverts

Fire on every require(cond, "string") or revert("string") without exception.

When NOT to Use This Skill

Do NOT use for:

  • require(condition) with no message — no string to remove, nothing to convert
  • revert CustomError() — already a custom error, review only for CE-003 context
  • Contracts targeting Solidity < 0.8.4 — custom errors did not exist before 0.8.4
  • Third-party library code you do not control (flag but do not modify)
  • String-based reverts in test files where human-readable messages aid test output

Platform Detection

This skill applies when the following markers are present:

File extensions: *.sol Project markers: foundry.toml or hardhat.config.ts in project root Language markers:

  • pragma solidity ^0.8.x; (must be 0.8.4 or higher)
  • contract, library, or interface declarations
  • require(, revert( usage in function bodies

Do not apply to Vyper (.vy) or non-EVM languages.

Quick Reference

Pattern Fix Gas Saving
require(cond, "string") if (!cond) revert CustomError() ~15–50 gas runtime + bytecode reduction
revert("string") revert CustomError() ~15–50 gas runtime + bytecode reduction
revert CustomError() with no context Add typed params if useful Better debugging, minimal cost

Decision rule: If a quote mark appears inside a require() or revert(), this skill fires. No exceptions.

Read the full file on GitHub · 126 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 126 lines · 97 tokens per session scan A 7994eeebffca

Subscribe to this mod's changes

custom-errors is a skill published in the GitHub repository zaryab2000/decipher-gas-optimizoor (7 stars, last pushed 6mo ago), licensed MIT. It adds 97 tokens to every session and 1,284 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

solidity-gas-optimizer

Analyze and optimize gas consumption in Solidity smart contracts using proven patterns and best practices.

ZhouXiaoHong/binance-skills · 23 tokens

blockchain-expert

Expert-level blockchain, Web3, smart contracts, DeFi, and cryptocurrency development. Use when the user mentions Web3, smart contracts, DeFi, Ethereum, or Solidity, or when the task involves Blockchain Fundamentals, Web3 & DeFi, Smart Contract Security, or Gas Optimization.

personamanagmentlayer/pcl · 63 tokens

blockchain-application

Use this skill when asked about smart contract development, Solidity, Vyper, Rust smart contracts (Solana, NEAR, Polkadot), Haskell/Plutus (Cardano), Cairo/StarkNet, dApp backend development, Truffle, Hardhat, Foundry, Anchor, and blockchain application patterns. Languages: Solidity, Vyper, Rust, Haskell, Cairo, Move.…

j4flmao/agent-skills · 175 tokens

web3-expert

Build production-ready Web3 applications including smart contracts, dApps, DeFi protocols, and decentralized storage solutions. Use when the user mentions Web3, smart contracts or Solidity, dApps, DeFi protocols, ethers.js or web3.js, IPFS, or on-chain integration with Ethereum-compatible networks.

personamanagmentlayer/pcl · 66 tokens

ethereum-development

Production-grade Ethereum/EVM development workflow for smart contracts, dApps, transactions, clients, gas optimization, testing, security review, deployment, verification, monitoring, and incident response across Foundry, Hardhat, Solidity, TypeScript, viem, ethers, wagmi, and common EVM networks.

dirtybits/agent-skills · 64 tokens

pentagonal-clawd

Use when the user asks to create, generate, build, audit, fix, compile, or look up smart contracts and tokens. Pentagonal Clawd is a sovereign smart contract forge and token intelligence platform with AI-powered 8-agent security pen testing across Ethereum, Solana, Polygon, Base, Arbitrum, Optimism, and BSC.

Pentagonal-ai/pentagonal · 75 tokens