Agent skill

Storage Layout

by ccashwell in ccashwell/evm-cortex

EVM storage layout expertise for struct packing, proxy storage patterns, and collision avoidance.

MITAuto-check passedBackend & APIs

Install Storage Layout

skills CLI
$ npx skills add ccashwell/evm-cortex --skill storage-layout -a claude-code

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

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

At a glance

EVM storage layout expertise for struct packing, proxy storage patterns, and collision avoidance.

  • Designing data structures
  • SKILL.md covers EVM Storage Fundamentals, Struct Packing, Storage Slot Calculation and Inspecting Storage Layout, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Working with upgradeable proxies

What it does

Storage Layout is an agent skill from ccashwell/evm-cortex. EVM storage layout expertise for struct packing, proxy storage patterns, and collision avoidance. Use when designing data structures, working with upgradeable proxies, optimizing storage costs, or debugging storage-related issues.

Its SKILL.md is about 1.6k 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. The repository describes itself as: Ethereum protocol engineering squad for AI coding assistants. The licence is MIT.

When your agent uses it

  • Designing data structures
  • Working with upgradeable proxies
  • Optimizing storage costs
  • Debugging storage-related issues

Example prompts

  • “/storage-layout”

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

    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

Storage Layout loads about 1.6k tokens when it runs. Until then it costs about 61 tokens; SKILL.md has 212 words of instructions outside code blocks.

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

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). 212 words, ~1,551 tokens.

Download SKILL.mdSave it as .claude/skills/storage-layout/SKILL.md (or your agent's skills folder).
name
storage-layout
description
EVM storage layout expertise for struct packing, proxy storage patterns, and collision avoidance. Use when designing data structures, working with upgradeable proxies, optimizing storage costs, or debugging storage-related issues.

Storage Layout

EVM Storage Fundamentals

Each storage slot is 32 bytes (256 bits). State variables are assigned slots sequentially starting at slot 0. Multiple variables smaller than 32 bytes are packed into a single slot when possible.

solidity
// Slot 0: addr (20 bytes) + isActive (1 byte) + role (1 byte) = 22 bytes — fits one slot
// Slot 1: balance (32 bytes) — full slot
// Slot 2: lastUpdate (8 bytes) — new slot (won't pack with previous full slot)
contract Packed {
    address addr;       // 20 bytes  | slot 0
    bool isActive;      // 1 byte    | slot 0
    uint8 role;         // 1 byte    | slot 0
    uint256 balance;    // 32 bytes  | slot 1
    uint64 lastUpdate;  // 8 bytes   | slot 2
}

Struct Packing

Order fields from largest to smallest alignment, grouping sub-32-byte fields together.

solidity
// BAD: 4 slots (128 bytes)
struct UserBad {
    bool isActive;      // 1 byte   | slot 0 (31 bytes wasted)
    uint256 balance;    // 32 bytes | slot 1
    address wallet;     // 20 bytes | slot 2 (12 bytes wasted)
    uint256 rewards;    // 32 bytes | slot 3
}

// GOOD: 3 slots (96 bytes)
struct UserGood {
    uint256 balance;    // 32 bytes | slot 0
    uint256 rewards;    // 32 bytes | slot 1
    address wallet;     // 20 bytes | slot 2
    bool isActive;      // 1 byte   | slot 2 (packed with wallet)
}
Aggressive Packing Example
solidity
// 1 slot (32 bytes) for a position record
struct Position {
    address owner;      // 20 bytes
    uint48 openedAt;    // 6 bytes  (good until year 8.9M)
    uint40 collateral;  // 5 bytes  (up to ~1.1T with scaling)
    bool isLong;        // 1 byte
}
// Total: 20 + 6 + 5 + 1 = 32 bytes = 1 slot
Timestamp Sizing Guide
TypeBytesMax ValueOverflow Date
uint3244.29BFeb 2106
uint4051.1TYear ~36812
uint486281TYear ~8.9M

Use uint48 for timestamps in most protocol designs. uint32 overflows in 2106.

Storage Slot Calculation

solidity
// Fixed-size variables: sequential slots starting at 0
// Mappings: keccak256(key . slot)
// Dynamic arrays: length at slot, elements at keccak256(slot) + index
// Nested mappings: keccak256(innerKey . keccak256(outerKey . slot))

// Example: mapping(address => mapping(uint256 => uint256)) at slot 5
// Value at [addr][id] is stored at:
// keccak256(abi.encode(id, keccak256(abi.encode(addr, 5))))

Inspecting Storage Layout

bash
# Forge: inspect storage layout
forge inspect src/MyContract.sol:MyContract storage-layout --pretty

# Output shows slot, offset, type, and variable name
# Use this to verify packing and detect collisions before deployment

Proxy Storage Patterns

EIP-1967 Standard Slots
solidity
// Implementation slot
bytes32 internal constant _IMPLEMENTATION_SLOT =
    0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
    // bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)

// Admin slot
bytes32 internal constant _ADMIN_SLOT =
    0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
    // bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)

// Beacon slot
bytes32 internal constant _BEACON_SLOT =
    0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
    // bytes32(uint256(keccak256("eip1967.proxy.beacon")) - 1)
Storage Gaps for Upgradeable Contracts
solidity
abstract contract StorageGapExample {
    uint256 public value1;
    address public admin;

    // Reserve 48 slots for future storage variables
    // When adding new variables, reduce the gap size accordingly
    uint256[48] private __gap;
}

// In V2, adding a new variable:
abstract contract StorageGapExampleV2 {
    uint256 public value1;
    address public admin;
    uint256 public newValue;  // added in V2

    uint256[47] private __gap;  // reduced from 48 to 47
}
Unstructured Storage (Diamond/EIP-2535)
solidity
library LibDiamond {
    bytes32 constant DIAMOND_STORAGE_POSITION =
        keccak256("diamond.standard.diamond.storage");

    struct DiamondStorage {
        mapping(bytes4 => address) selectorToFacet;
        mapping(bytes4 => uint96) selectorToSlotPosition;
        bytes4[] selectors;
        mapping(bytes4 => bool) supportedInterfaces;
        address contractOwner;
    }

    function diamondStorage() internal pure returns (DiamondStorage storage ds) {
        bytes32 position = DIAMOND_STORAGE_POSITION;
        assembly {
            ds.slot := position
        }
    }
}

Namespace Storage Pattern (ERC-7201)

solidity
/// @custom:storage-location erc7201:myprotocol.storage.vault
struct VaultStorage {
    mapping(address => uint256) balances;
    uint256 totalDeposited;
    bool paused;
}

// keccak256(abi.encode(uint256(keccak256("myprotocol.storage.vault")) - 1))
//   & ~bytes32(uint256(0xff))
bytes32 private constant VAULT_STORAGE_LOCATION =
    0x...;

function _getVaultStorage() private pure returns (VaultStorage storage $) {
    assembly {
        $.slot := VAULT_STORAGE_LOCATION
    }
}

Common Mistakes

  • Reordering variables in an upgradeable contract (shifts all subsequent slots)
  • Forgetting to reduce __gap when adding variables
  • Changing variable types (e.g., uint128 to uint256 shifts layout)
  • Inheriting in different order between proxy versions
  • Not running forge inspect before deploying upgrades

Storage Layout Verification Checklist

  • Run forge inspect --storage-layout on both old and new versions
  • Diff the layouts to verify no slot collisions
  • New variables only appended (never inserted)
  • __gap reduced by exactly the number of new slots used
  • Inheritance order unchanged between versions
  • Use EIP-7201 namespaced storage for new diamond/modular patterns
  • Struct field order optimized for packing

© 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/storage-layout of ccashwell/evm-cortex.

Open the folder on GitHubat commit f8f3301

Compare with similar skills

Storage Layout 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.

Storage Layout compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Storage Layout this skillccashwell/evm-cortex131—~1.6kAutomated safety check: PassMIT
Squash BugbotLFDT-Lineth/lineth-monorepo126—~3.3kAutomated safety check: PassApache-2.0
Auditsablier-labs/evm-monorepo353—~1.8kAutomated safety check: PassCustom licence
near-kit for NEAR Protocolinternet-court/internet-court-skill6.4k1 repos~2kAutomated safety check: PassCustom licence
Trustless Agentsinternet-court/internet-court-skill6.4k1 repos~510Automated safety check: PassMIT
Foundry Reference Modelaviggiano/security144—~516Automated safety check: PassMIT

Similar skills

  • Squash Bugbot

    LFDT-Lineth/lineth-monorepo

    Triage unresolved bot review comments on a GitHub PR. An agent skill from LFDT-Lineth/lineth-monorepo.

    126 GitHub stars~3.3k tokensUpdated today
    Backend & APIsAuto-check passed
  • Audit

    sablier-labs/evm-monorepo

    Security audit and code review for Solidity smart contracts.

    353 GitHub stars~1.8k tokensUpdated today
    Backend & APIsAuto-check passed
  • near-kit for NEAR Protocol

    internet-court/internet-court-skill

    Covers the near-kit TypeScript library for NEAR: reading contracts, sending tokens, transaction building, typed contracts, wallets, React hooks and sandbox testing.

    6.4k GitHub starsUsed in 1 repo~2k tokens
    Backend & APIsAuto-check passed
  • Trustless Agents

    internet-court/internet-court-skill

    ERC-8004 Trustless Agents — on-chain agent identity + reputation.

    6.4k GitHub starsUsed in 1 repo~510 tokens
    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
  • Validate Docs Section

    Nethereum/Nethereum

    Validate and perfect a Nethereum documentation section end-to-end.

    2.3k GitHub stars~15k tokensUpdated 2 days 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

Questions about Storage Layout

What does Storage Layout do?

EVM storage layout expertise for struct packing, proxy storage patterns, and collision avoidance. Storage Layout is an agent skill from ccashwell/evm-cortex. EVM storage layout expertise for struct packing, proxy storage patterns, and collision avoidance.

When should I use Storage Layout?

Storage Layout fits situations like: designing data structures; working with upgradeable proxies; optimizing storage costs; debugging storage-related issues.

How do I install Storage Layout in Claude Code?

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

How do I install Storage Layout in Codex?

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

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

What does Storage Layout need to run?

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

Does Storage Layout 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 Storage Layout 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 Storage Layout use?

Storage Layout 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 Storage Layout use?

About 1.6k tokens (SKILL.md is roughly 6.2k 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 Storage Layout?

Skills that share tags, products or a category with Storage Layout: Squash Bugbot (LFDT-Lineth/lineth-monorepo, 126 stars), Audit (sablier-labs/evm-monorepo, 353 stars), near-kit for NEAR Protocol (internet-court/internet-court-skill, 6.4k stars) and Trustless Agents (internet-court/internet-court-skill, 6.4k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Storage Layout?

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.