Agent skill

Integer Overflow

by ccashwell in ccashwell/evm-cortex

Integer safety patterns for Solidity 0.8+. An agent skill from ccashwell/evm-cortex.

MITAuto-check passedBackend & APIs

Install Integer Overflow

skills CLI
$ npx skills add ccashwell/evm-cortex --skill integer-overflow -a claude-code

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

GitHub CLI
$ gh skill install ccashwell/evm-cortex integer-overflow --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/integer-overflow .claude/skills/integer-overflow && 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
integer-overflow
GitHub stars
131
Token cost
~1.5k tokens
SKILL.md length
149 words
Files
1
Skills in repo
89
Repo updated
First seen
Licence
MIT

At a glance

Integer safety patterns for Solidity 0.8+. An agent skill from ccashwell/evm-cortex.

  • Working with unchecked blocks
  • SKILL.md covers Solidity 0.8+ Automatic Checks, Unchecked Blocks, Phantom Overflow and Safe Casting, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Intermediate calculation overflow risks

What it does

Integer Overflow is an agent skill from ccashwell/evm-cortex. Integer safety patterns for Solidity 0.8+. Use when working with unchecked blocks, safe casting, or intermediate calculation overflow risks. Covers automatic checks, intentional overflow, phantom overflow, and safe math patterns.

Its SKILL.md is about 1.5k 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 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

  • Working with unchecked blocks
  • Intermediate calculation overflow risks

Example prompts

  • “/integer-overflow”

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).

    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

Integer Overflow loads about 1.5k tokens when it runs. Until then it costs about 62 tokens; SKILL.md has 149 words of instructions outside code blocks.

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

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). 149 words, ~1,526 tokens.

Download SKILL.mdSave it as .claude/skills/integer-overflow/SKILL.md (or your agent's skills folder).
name
integer-overflow
description
Integer safety patterns for Solidity 0.8+. Use when working with unchecked blocks, safe casting, or intermediate calculation overflow risks. Covers automatic checks, intentional overflow, phantom overflow, and safe math patterns.

Integer Safety

Solidity 0.8+ Automatic Checks

Since Solidity 0.8, arithmetic operations revert on overflow/underflow by default. This eliminates the need for SafeMath but introduces new considerations.

solidity
// These all revert automatically on overflow (Solidity 0.8+)
uint256 a = type(uint256).max;
uint256 b = a + 1;  // reverts: arithmetic overflow

uint256 c = 0;
uint256 d = c - 1;  // reverts: arithmetic underflow

uint8 e = 255;
uint8 f = e + 1;    // reverts: arithmetic overflow

Unchecked Blocks

Use unchecked when overflow is mathematically impossible and gas savings matter.

solidity
// SAFE: loop counter cannot overflow (bounded by array length)
for (uint256 i; i < arr.length;) {
    processItem(arr[i]);
    unchecked { ++i; }
}

// SAFE: subtraction will not underflow (checked by prior condition)
function withdraw(uint256 amount) external {
    uint256 balance = balances[msg.sender];
    if (balance < amount) revert InsufficientBalance();

    unchecked {
        balances[msg.sender] = balance - amount; // balance >= amount guaranteed
    }
}

// SAFE: hash computation (intentional wrapping)
unchecked {
    uint256 hash = uint256(keccak256(abi.encodePacked(a))) + nonce;
}
When Unchecked Is Dangerous
solidity
// DANGEROUS: user-controlled values in unchecked
unchecked {
    uint256 result = userInput1 + userInput2; // could overflow silently
}

// DANGEROUS: complex arithmetic with multiple operations
unchecked {
    uint256 result = (a * b + c) / d; // any step could overflow
}

Phantom Overflow

Intermediate calculations can overflow even when the final result fits.

solidity
// VULNERABLE: a * b can overflow even if (a * b) / c fits in uint256
function mulDiv(uint256 a, uint256 b, uint256 c) internal pure returns (uint256) {
    return a * b / c; // reverts if a * b > type(uint256).max
}

// Example: mulDiv(2e18, 3e18, 1e18) should return 6e18
// But 2e18 * 3e18 = 6e36, which overflows uint256? No, 6e36 < 2^256
// But mulDiv(type(uint128).max, type(uint128).max, 1) WILL overflow

// FIXED: use Solmate's FixedPointMathLib which handles phantom overflow
import {FixedPointMathLib} from "solmate/utils/FixedPointMathLib.sol";

function mulDiv(uint256 a, uint256 b, uint256 c) internal pure returns (uint256) {
    return FixedPointMathLib.mulDiv(a, b, c); // assembly-based, no phantom overflow
}
mulDiv Implementation Concept
solidity
// FixedPointMathLib.mulDiv uses 512-bit intermediate math in assembly:
// 1. Compute full 512-bit product of a * b
// 2. Divide the 512-bit result by c
// 3. Return the 256-bit quotient (reverts if it doesn't fit)

Safe Casting

Narrowing casts can silently truncate in Solidity. Always use explicit safe casting.

solidity
// VULNERABLE: silent truncation
uint256 bigNumber = 300;
uint8 small = uint8(bigNumber); // small = 44 (300 % 256), NO revert!

// SAFE: explicit overflow check
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
using SafeCast for uint256;

uint256 bigNumber = 300;
uint8 small = bigNumber.toUint8(); // reverts: SafeCast: value doesn't fit in 8 bits
Common Safe Cast Operations
solidity
using SafeCast for uint256;
using SafeCast for int256;

uint256 value = 1000;

uint128 a = value.toUint128();  // reverts if > type(uint128).max
uint96 b = value.toUint96();    // reverts if > type(uint96).max
uint64 c = value.toUint64();    // reverts if > type(uint64).max
uint48 d = value.toUint48();    // reverts if > type(uint48).max
uint32 e = value.toUint32();    // reverts if > type(uint32).max

int256 signed = int256(value);  // reverts if > type(int256).max

Type Boundaries

solidity
// Know your type limits
type(uint8).max    == 255
type(uint16).max   == 65_535
type(uint32).max   == 4_294_967_295
type(uint48).max   == 281_474_976_710_655
type(uint64).max   == 18_446_744_073_709_551_615
type(uint96).max   == 79_228_162_514_264_337_593_543_950_335
type(uint128).max  == 340_282_366_920_938_463_463_374_607_431_768_211_455
type(uint256).max  == 2^256 - 1

type(int256).min   == -(2^255)
type(int256).max   == 2^255 - 1

Signed Integer Gotchas

solidity
// Negation overflow: -type(int256).min overflows
int256 minValue = type(int256).min;
int256 negated = -minValue; // REVERTS: overflow (no positive equivalent)

// Division edge case
int256 result = type(int256).min / (-1); // REVERTS: same as negation overflow

// Abs function must handle min value
function abs(int256 x) internal pure returns (uint256) {
    if (x == type(int256).min) revert AbsOverflow();
    return uint256(x >= 0 ? x : -x);
}

Accumulator Overflow

For accounting that accumulates over time, consider if the accumulator can overflow.

solidity
// Reward accumulator pattern
// rewardPerTokenStored grows continuously — can it overflow uint256?
// With 1e18 precision and 1e18 rewards/sec for 100 years:
// 1e18 * 1e18 * 100 * 365 * 86400 ≈ 3.15e33, well under 2^256 ≈ 1.15e77
// Safe for practical purposes, but document the assumption

uint256 public rewardPerTokenStored;

function rewardPerToken() public view returns (uint256) {
    if (totalSupply == 0) return rewardPerTokenStored;
    return rewardPerTokenStored + (
        (lastRewardTime() - lastUpdateTime) * rewardRate * PRECISION / totalSupply
    );
}

Integer Safety Checklist

  • unchecked only used where overflow is mathematically impossible
  • Comment explaining why overflow is impossible for each unchecked block
  • No silent narrowing casts — use SafeCast
  • mulDiv from Solmate for multiplication followed by division
  • Accumulator overflow analyzed for worst-case scenarios
  • Signed integer edge cases handled (type(int256).min)
  • Type boundaries documented for packed struct fields

© 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/integer-overflow of ccashwell/evm-cortex.

Open the folder on GitHubat commit f8f3301

Compare with similar skills

Integer Overflow 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.

Integer Overflow compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Integer Overflow this skillccashwell/evm-cortex131—~1.5kAutomated safety check: PassMIT
Fizz Convertpashov/skills1.2k2 repos~3.7kAutomated safety check: PassMIT
Feynman Auditor0xiehnnkta/nemesis-auditor2441 repos~11kAutomated safety check: PassMIT
Smart Contract Auditgreatpie/smart-contract-audit-skill101—~1.1kAutomated safety check: PassNone
RadarAuditware/radar154—~2.1kAutomated safety check: PassGPL-3.0
Solidity AuditorGabson0x/bountyforge443—~3.7kAutomated safety check: PassNone

Similar skills

  • 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
  • Radar

    Auditware/radar

    Use radar for smart contract security analysis, AST generation, and detection template development.

    154 GitHub stars~2.1k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • Solidity Auditor

    Gabson0x/bountyforge

    Security audit of Solidity code while you develop. An agent skill from Gabson0x/bountyforge.

    443 GitHub stars~3.7k tokensUpdated 21 days ago
    Backend & APIsAuto-check passed
  • Add Explorer

    lidofinance/diffyscan

    Adds or repairs Diffyscan explorer API routing and response adapters for a new host, chain or payload format.

    142 GitHub stars~1k tokensUpdated yesterday
    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

Categories

Questions about Integer Overflow

What does Integer Overflow do?

Integer safety patterns for Solidity 0.8+. An agent skill from ccashwell/evm-cortex. Integer Overflow is an agent skill from ccashwell/evm-cortex.8+.

When should I use Integer Overflow?

Integer Overflow fits situations like: working with unchecked blocks; intermediate calculation overflow risks.

How do I install Integer Overflow in Claude Code?

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

How do I install Integer Overflow in Codex?

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

Can I use Integer Overflow 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 integer-overflow -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/integer-overflow, .gemini/skills/integer-overflow, .github/skills/integer-overflow and .opencode/skills/integer-overflow in your project.

What does Integer Overflow need to run?

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

Does Integer Overflow 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 Integer Overflow 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 Integer Overflow use?

Integer Overflow 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 Integer Overflow use?

About 1.5k tokens (SKILL.md is roughly 6.1k 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 Integer Overflow?

Skills that share tags, products or a category with Integer Overflow: Fizz Convert (pashov/skills, 1.2k stars), Feynman Auditor (0xiehnnkta/nemesis-auditor, 244 stars), Smart Contract Audit (greatpie/smart-contract-audit-skill, 101 stars) and Radar (Auditware/radar, 154 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Integer Overflow?

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.