Agent skill

Error Handling

by ccashwell in ccashwell/evm-cortex

Custom error patterns and revert handling for Solidity. An agent skill from ccashwell/evm-cortex.

MITAuto-check passedBackend & APIs

Install Error Handling

skills CLI
$ npx skills add ccashwell/evm-cortex --skill error-handling -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ccashwell/evm-cortex error-handling --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ccashwell/evm-cortex.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/error-handling .claude/skills/error-handling && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
error-handling
GitHub stars
131
Token cost
~1.7k tokens
SKILL.md length
271 words
Files
1
Skills in repo
89
Repo updated
First seen
Licence
MIT

At a glance

Custom error patterns and revert handling for Solidity. An agent skill from ccashwell/evm-cortex.

  • Works in 6 steps: Encode useful context — include… → Use prefixed names — Module_ErrorName… → Keep parameter count reasonable — 1-3… → …
  • Designing error hierarchies
  • SKILL.md covers Custom Errors vs Require Strings, Error Hierarchy Design, Try/Catch for External Calls and Error Propagation, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Error Handling is an agent skill from ccashwell/evm-cortex. Custom error patterns and revert handling for Solidity. Use when designing error hierarchies, implementing try/catch for external calls, or establishing error conventions across a protocol. Covers custom errors, revert patterns, error propagation, and NatSpec documentation.

Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Backend & APIs, covering Error handling and Smart contracts. It works with Solidity. The repository describes itself as: Ethereum protocol engineering squad for AI coding assistants. The licence is MIT.

When your agent uses it

  • Designing error hierarchies
  • Implementing try/catch for external calls
  • Establishing error conventions across a protocol

Example prompts

  • “/error-handling”

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Encode useful context — include parameters that help diagnose the issue
  2. Use prefixed names — Module_ErrorName prevents selector collisions across large codebases
  3. Keep parameter count reasonable — 1-3 parameters; more wastes gas on revert
  4. Don't use errors for control flow — revert is not a return mechanism
  5. Group errors in interfaces — collect related errors for reuse across contracts
  6. Document trigger conditions — every error needs a @dev tag explaining when/why

What it can do on your machine

Read from SKILL.md and the folder at commit f8f3301. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are solidity and typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Error Handling loads about 1.7k tokens when it runs. Until then it costs about 72 tokens; SKILL.md has 271 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~72
When it runs · the whole SKILL.md, loaded when a task matches
~1.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ccashwell/evm-cortex at commit f8f3301, republished under its MIT licence (© ccashwell). 271 words, ~1,683 tokens.

Download SKILL.mdSave it as .claude/skills/error-handling/SKILL.md (or your agent's skills folder).
name
error-handling
description
Custom error patterns and revert handling for Solidity. Use when designing error hierarchies, implementing try/catch for external calls, or establishing error conventions across a protocol. Covers custom errors, revert patterns, error propagation, and NatSpec documentation.

Error Handling

Custom Errors vs Require Strings

Custom errors are cheaper and more expressive. Always prefer them.

solidity
// BAD: require with string (~200 gas more per revert, larger bytecode)
require(amount > 0, "Amount must be greater than zero");
require(msg.sender == owner, "Not authorized");

// GOOD: custom errors
error ZeroAmount();
error Unauthorized(address caller, address required);

if (amount == 0) revert ZeroAmount();
if (msg.sender != owner) revert Unauthorized(msg.sender, owner);
Gas Comparison
PatternDeploy CostRevert Cost
require("string")+~200 bytes~2,400 gas
revert CustomError()+~4 bytes~2,200 gas
revert CustomError(param)+~4 bytes~2,300 gas

Error Hierarchy Design

Organize errors by domain for large protocols. Prefix with the contract or module name for clarity in offchain decoding.

solidity
// errors/VaultErrors.sol
interface VaultErrors {
    error Vault_InsufficientBalance(address user, uint256 available, uint256 requested);
    error Vault_DepositCapExceeded(uint256 cap, uint256 attempted);
    error Vault_WithdrawalPaused();
    error Vault_InvalidToken(address token);
    error Vault_SlippageExceeded(uint256 expected, uint256 actual);
}

// errors/OracleErrors.sol
interface OracleErrors {
    error Oracle_StalePrice(address feed, uint256 updatedAt, uint256 threshold);
    error Oracle_InvalidRound(uint80 roundId);
    error Oracle_NegativePrice(int256 price);
    error Oracle_ZeroPrice();
}

// Inherit in implementation
contract Vault is VaultErrors, OracleErrors {
    function withdraw(uint256 amount) external {
        uint256 balance = balances[msg.sender];
        if (balance < amount) {
            revert Vault_InsufficientBalance(msg.sender, balance, amount);
        }
        // ...
    }
}

Try/Catch for External Calls

Use try/catch when you need to handle failures from external contract calls gracefully.

solidity
interface IPriceFeed {
    function latestRoundData() external view returns (
        uint80 roundId, int256 answer, uint256 startedAt,
        uint256 updatedAt, uint80 answeredInRound
    );
}

function getPrice(IPriceFeed feed) internal view returns (uint256) {
    try feed.latestRoundData() returns (
        uint80, int256 answer, uint256, uint256 updatedAt, uint80
    ) {
        if (answer <= 0) revert Oracle_NegativePrice(answer);
        if (block.timestamp - updatedAt > STALENESS_THRESHOLD) {
            revert Oracle_StalePrice(address(feed), updatedAt, STALENESS_THRESHOLD);
        }
        return uint256(answer);
    } catch Error(string memory reason) {
        // Catches require() / revert("string") failures
        revert OracleCallFailed(reason);
    } catch (bytes memory lowLevelData) {
        // Catches custom errors, panics, or out-of-gas
        revert OracleCallFailedBytes(lowLevelData);
    }
}
Try/Catch Limitations
  • Only works on external function calls and contract creation
  • Cannot catch out-of-gas in the calling context (only in the callee)
  • catch Panic(uint256 code) catches arithmetic overflow, division by zero, etc.
solidity
try target.someFunction() returns (uint256 result) {
    return result;
} catch Panic(uint256 code) {
    // code 0x01: assert failure
    // code 0x11: arithmetic overflow
    // code 0x12: division by zero
    // code 0x32: array out of bounds
    emit PanicCaught(code);
    return 0;
} catch Error(string memory reason) {
    emit ErrorCaught(reason);
    return 0;
} catch (bytes memory) {
    // Low-level or custom error
    return 0;
}

Error Propagation

Bubble up errors from low-level calls preserving the original revert reason.

solidity
function execute(address target, bytes calldata data) external returns (bytes memory) {
    (bool success, bytes memory returndata) = target.call(data);

    if (!success) {
        // If there's revert data, bubble it up
        if (returndata.length > 0) {
            assembly {
                revert(add(returndata, 32), mload(returndata))
            }
        }
        revert ExecutionFailed(target);
    }

    return returndata;
}

Decoding Custom Errors Offchain

typescript
import { ethers } from "ethers";

const iface = new ethers.Interface([
  "error Vault_InsufficientBalance(address user, uint256 available, uint256 requested)",
]);

try {
  await vault.withdraw(amount);
} catch (err: any) {
  const decoded = iface.parseError(err.data);
  if (decoded?.name === "Vault_InsufficientBalance") {
    const [user, available, requested] = decoded.args;
    console.log(`${user} has ${available}, needs ${requested}`);
  }
}

NatSpec for Errors

Document every custom error with @dev explaining when it triggers.

solidity
/// @dev Thrown when a user attempts to withdraw more than their balance.
/// @param user The address attempting the withdrawal.
/// @param available The user's current balance.
/// @param requested The amount requested.
error Vault_InsufficientBalance(address user, uint256 available, uint256 requested);

/// @dev Thrown when the oracle price feed returns stale data.
/// @param feed The address of the price feed.
/// @param updatedAt The timestamp of the last update.
/// @param threshold The maximum allowed staleness in seconds.
error Oracle_StalePrice(address feed, uint256 updatedAt, uint256 threshold);

Error Design Guidelines

  1. Encode useful context — include parameters that help diagnose the issue
  2. Use prefixed names — Module_ErrorName prevents selector collisions across large codebases
  3. Keep parameter count reasonable — 1-3 parameters; more wastes gas on revert
  4. Don't use errors for control flow — revert is not a return mechanism
  5. Group errors in interfaces — collect related errors for reuse across contracts
  6. Document trigger conditions — every error needs a @dev tag explaining when/why

Error Handling Checklist

  • All require() converted to custom errors
  • Errors organized by domain in separate interfaces
  • Error names prefixed with module name
  • NatSpec @dev on every custom error
  • External calls wrapped in try/catch where graceful degradation is needed
  • Low-level calls bubble up revert reasons
  • Offchain tooling can decode all custom errors (ABI includes error definitions)

© ccashwell, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/error-handling of ccashwell/evm-cortex.

Open the folder on GitHubat commit f8f3301

Compare with similar skills

Error Handling next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Error Handling compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Error Handling this skillccashwell/evm-cortex131—~1.7kAutomated safety check: PassMIT
Error HandlingNethereum/Nethereum2.3k—~1.1kAutomated safety check: PassMIT
Auditsablier-labs/evm-monorepo353—~1.8kAutomated safety check: PassCustom licence
Foundry Reference Modelaviggiano/security144—~516Automated safety check: PassMIT
Fizz Convertpashov/skills1.2k2 repos~3.7kAutomated safety check: PassMIT
Feynman Auditor0xiehnnkta/nemesis-auditor2441 repos~11kAutomated safety check: PassMIT

Similar skills

  • Error Handling

    Nethereum/Nethereum

    Handle smart contract reverts and decode custom error types using Nethereum (.NET).

    2.3k GitHub stars~1.1k tokensUpdated 2 days ago
    Backend & APIsAuto-check passed
  • Audit

    sablier-labs/evm-monorepo

    Security audit and code review for Solidity smart contracts.

    353 GitHub stars~1.8k tokensUpdated 13 days ago
    Backend & APIsAuto-check passed
  • Foundry Reference Model

    aviggiano/security

    Build a simple independent Solidity reference implementation for Foundry tests.

    144 GitHub stars~516 tokensUpdated 22 days ago
    Backend & APIsAuto-check passed
  • Fizz Convert

    pashov/skills

    Convert English-language properties in PROPERTIES.md (produced by the Fizz skill) into Solidity assertions inside the existing fuzz harness, then flip their checkboxes.

    1.2k GitHub starsUsed in 2 repos~3.7k tokens
    Backend & APIsAuto-check passed
  • Feynman Auditor

    0xiehnnkta/nemesis-auditor

    Deep business logic bug finder using the Feynman technique. An agent skill from 0xiehnnkta/nemesis-auditor.

    244 GitHub starsUsed in 1 repo~11k tokens
    Backend & APIsAuto-check passed
  • Smart Contract Audit

    greatpie/smart-contract-audit-skill

    Script-backed, out-of-box auditing workflow for Solidity/EVM repositories based on EVMbench detect/patch/exploit methodology.

    101 GitHub stars~1.1k tokensUpdated 7 mo ago
    Backend & APIsAuto-check passed

More from ccashwell/evm-cortex

All 89 skills in this repo
  • Xray Pre Audit

    ccashwell/evm-cortex

    A skill your agent uses when preparing for a security audit, performing reconnaissance on a new codebase, or creating a protocol overview.

    131 GitHub stars~25k tokensUpdated 8 days ago
    Auto-check passed
  • Aave Integration

    ccashwell/evm-cortex

    A skill your agent uses when integrating with Aave V3 for lending, borrowing, flash loans, or building on top of Aave markets.

    131 GitHub stars~1.3k tokensUpdated 8 days ago
    Auto-check passed
  • Access Control Patterns

    ccashwell/evm-cortex

    Access control design patterns for Solidity protocols. An agent skill from ccashwell/evm-cortex.

    131 GitHub stars~1.8k tokensUpdated 8 days ago
    Auto-check passed
  • Anvil Patterns

    ccashwell/evm-cortex

    A skill your agent uses when running a local Ethereum node with Anvil.

    131 GitHub stars~1.3k tokensUpdated 8 days ago
    Auto-check passed
  • Audit Breadth Scan

    ccashwell/evm-cortex

    A skill your agent uses when performing systematic breadth-first review of all contracts during a security audit.

    131 GitHub stars~1.4k tokensUpdated 8 days ago
    Auto-check passed
  • Audit Depth Analysis

    ccashwell/evm-cortex

    A skill your agent uses when performing deep analysis of specific findings or high-risk areas during a security audit.

    131 GitHub stars~1.6k tokensUpdated 8 days ago
    Auto-check passed

Works with

Questions about Error Handling

What does Error Handling do?

Custom error patterns and revert handling for Solidity. An agent skill from ccashwell/evm-cortex. Error Handling is an agent skill from ccashwell/evm-cortex. Custom error patterns and revert handling for Solidity.

When should I use Error Handling?

Error Handling fits situations like: designing error hierarchies; implementing try/catch for external calls; establishing error conventions across a protocol.

How do I install Error Handling in Claude Code?

Run `npx skills add ccashwell/evm-cortex --skill error-handling -a claude-code`. Or copy the skill folder (skills/error-handling in ccashwell/evm-cortex) into .claude/skills/error-handling in your project. Claude Code loads it when a task matches its description.

How do I install Error Handling in Codex?

Run `npx skills add ccashwell/evm-cortex --skill error-handling -a codex`. Or copy the skill folder (skills/error-handling in ccashwell/evm-cortex) into .agents/skills/error-handling in your project. Codex loads it when a task matches its description.

Can I use Error Handling in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ccashwell/evm-cortex --skill error-handling -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/error-handling, .gemini/skills/error-handling, .github/skills/error-handling and .opencode/skills/error-handling in your project.

What does Error Handling need to run?

SKILL.md names no scripts, command-line tools or credentials: Error Handling is instructions for the agent only.

Does Error Handling access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Error Handling safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Error Handling use?

Error Handling is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Error Handling use?

About 1.7k tokens (SKILL.md is roughly 6.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Error Handling?

Skills that share tags, products or a category with Error Handling: Error Handling (Nethereum/Nethereum, 2.3k stars), Audit (sablier-labs/evm-monorepo, 353 stars), Foundry Reference Model (aviggiano/security, 144 stars) and Fizz Convert (pashov/skills, 1.2k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Error Handling?

ccashwell (a GitHub user) maintains it in ccashwell/evm-cortex, which has 131 GitHub stars. The repository holds 89 skills in this directory. The repository was last updated on September 30, 2026.

Source: ccashwell/evm-cortex on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.