Agent skill

Immutable Constants

by ccashwell in ccashwell/evm-cortex

Proper use of immutable and constant variables for gas savings and correctness.

MITAuto-check passed

Install Immutable Constants

skills CLI
$ npx skills add ccashwell/evm-cortex --skill immutable-constants -a claude-code

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

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

At a glance

Proper use of immutable and constant variables for gas savings and correctness.

  • Deploying contracts with fixed configuration
  • SKILL.md covers When to Use Each, Constant Variables, Immutable Variables and Gas Comparison, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Deciding between constant

What it does

Immutable Constants is an agent skill from ccashwell/evm-cortex. Proper use of immutable and constant variables for gas savings and correctness. Use when deploying contracts with fixed configuration, optimizing gas, or deciding between constant, immutable, and storage variables.

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.

The repository describes itself as: Ethereum protocol engineering squad for AI coding assistants. The licence is MIT.

When your agent uses it

  • Deploying contracts with fixed configuration
  • Deciding between constant
  • Storage variables

Example prompts

  • “/immutable-constants”

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

Immutable Constants loads about 1.5k tokens when it runs. Until then it costs about 59 tokens; SKILL.md has 300 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~59
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). 300 words, ~1,531 tokens.

Download SKILL.mdSave it as .claude/skills/immutable-constants/SKILL.md (or your agent's skills folder).
name
immutable-constants
description
Proper use of immutable and constant variables for gas savings and correctness. Use when deploying contracts with fixed configuration, optimizing gas, or deciding between constant, immutable, and storage variables.

Immutable & Constant Variables

When to Use Each

TypeSet AtStored InSLOAD CostUse Case
constantCompile timeBytecode (inlined)0 gasKnown at write time: math constants, hashes, selectors
immutableDeploy time (constructor)Bytecode (appended)0 gasKnown at deploy: addresses, chain IDs, config
StorageRuntimeStorage slot2,100 cold / 100 warmMust change after deployment

Constant Variables

Must be known at compile time. Value is inlined everywhere it's used.

solidity
contract Constants {
    // Numeric constants
    uint256 public constant MAX_BPS = 10_000;
    uint256 public constant WAD = 1e18;
    uint256 public constant RAY = 1e27;
    uint256 public constant PRECISION = 1e18;

    // Hash constants — computed at compile time
    bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

    // EIP-712 type hashes
    bytes32 public constant PERMIT_TYPEHASH = keccak256(
        "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
    );

    // EIP-1967 slots
    bytes32 internal constant _IMPLEMENTATION_SLOT =
        bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1);

    // Selector constants
    bytes4 public constant TRANSFER_SELECTOR = IERC20.transfer.selector;
}
What Can Be Constant
  • Literal values (uint256, int256, bool, address, bytes1-bytes32)
  • keccak256() of literal values
  • Expressions evaluated at compile time
  • Cannot be constant: values depending on runtime state, block.timestamp, msg.sender

Immutable Variables

Set once in the constructor, stored in bytecode. Cannot be changed after deployment.

solidity
contract ImmutableConfig {
    address public immutable WETH;
    address public immutable FACTORY;
    address public immutable ORACLE;
    uint256 public immutable DEPLOYMENT_CHAIN_ID;
    uint256 public immutable CREATED_AT;
    uint8 public immutable UNDERLYING_DECIMALS;

    constructor(
        address weth,
        address factory,
        address oracle,
        address underlying
    ) {
        if (weth == address(0)) revert ZeroAddress();
        if (factory == address(0)) revert ZeroAddress();
        if (oracle == address(0)) revert ZeroAddress();

        WETH = weth;
        FACTORY = factory;
        ORACLE = oracle;
        DEPLOYMENT_CHAIN_ID = block.chainid;
        CREATED_AT = block.timestamp;
        UNDERLYING_DECIMALS = IERC20Metadata(underlying).decimals();
    }
}
Immutable Rules
  • Must be assigned in the constructor (or inline for simple expressions)
  • Cannot be assigned in any other function
  • Cannot be used in upgradeable contracts with initializers (no constructor runs)
  • Value types only: address, uint*, int*, bool, bytes1-bytes32
  • Cannot be immutable: string, bytes, arrays, structs, mappings

Gas Comparison

solidity
contract GasComparison {
    // Storage: 2,100 gas cold SLOAD, 100 gas warm SLOAD
    address public storageVar;

    // Immutable: 0 gas — loaded from bytecode via PUSH32
    address public immutable immutableVar;

    // Constant: 0 gas — inlined at every usage site
    uint256 public constant CONSTANT_VAR = 42;

    constructor(address _addr) {
        storageVar = _addr;
        immutableVar = _addr;
    }

    // Reading storageVar:   ~2,100 gas (cold) or ~100 gas (warm)
    // Reading immutableVar:     ~3 gas (PUSH32)
    // Reading CONSTANT_VAR:     ~3 gas (PUSH32, inlined)
}
Real-World Savings

For a function that reads an address 3 times:

  • Storage: 2,100 + 100 + 100 = 2,300 gas
  • Immutable: 3 + 3 + 3 = 9 gas (savings: 2,291 gas)

Bytes32 vs String for Constants

solidity
// BAD: string constant — still uses dynamic encoding
string public constant NAME = "MyProtocol";

// GOOD: bytes32 constant — fixed size, cheaper to read and compare
bytes32 public constant NAME = "MyProtocol";

// Converting bytes32 to string (offchain or in rare onchain cases)
function nameAsString() external pure returns (string memory) {
    return string(abi.encodePacked(NAME));
}

Naming Conventions

solidity
// Constants: UPPER_SNAKE_CASE
uint256 public constant MAX_SUPPLY = 1_000_000e18;

// Immutables: UPPER_SNAKE_CASE (they're functionally constant post-deploy)
address public immutable TREASURY;

// Storage variables: camelCase
uint256 public totalDeposited;

Immutables in Upgradeable Contracts

Immutables are stored in bytecode, not storage. In upgradeable proxies, the proxy reads the implementation's bytecode. This means immutables can be used in implementations — they're set in the implementation's constructor (which runs at deployment, not through the proxy).

solidity
contract VaultImplementation is Initializable {
    // These are set when the implementation contract is deployed
    address public immutable WETH;
    address public immutable FACTORY;

    constructor(address weth, address factory) {
        WETH = weth;
        FACTORY = factory;
        _disableInitializers();
    }

    function initialize(address admin) external initializer {
        // Storage variables set here (via proxy's storage)
        __Ownable_init(admin);
    }
}

Checklist

  • All values known at compile time are constant
  • All values known at deploy time (but not compile time) are immutable
  • Only values that change post-deployment use storage
  • Constructor validates all immutable values (zero-address checks)
  • UPPER_SNAKE_CASE naming for both constant and immutable
  • bytes32 preferred over string for short constant strings
  • Immutables in upgradeable contracts are in the implementation constructor

© 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/immutable-constants of ccashwell/evm-cortex.

Open the folder on GitHubat commit f8f3301

Compare with similar skills

Immutable Constants 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.

Immutable Constants compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Immutable Constants this skillccashwell/evm-cortex131—~1.5kAutomated safety check: PassMIT
Correctcursor/plugins10k3 repos~612Automated safety check: PassNone
CorrectionNxcoreAI/EverRoom3k—~290Automated safety check: PassCustom licence
Immutable Patternsthedaviddias/Front-End-Checklist74k—~505Automated safety check: PassMIT
Context Savegarrytan/gstack136k—~9.7kAutomated safety check: NotesMIT
Save As PDFasgeirtj/system_prompts_leaks69k—~2.3kAutomated safety check: PassCC0-1.0

Similar skills

  • Correct

    cursor/plugins

    Official

    Find the mistakes agents keep repeating in this repo and make each one impossible.

    10k GitHub starsUsed in 3 repos~612 tokens
    Auto-check passed
  • Correction

    NxcoreAI/EverRoom

    Compute Room overview corrections—citation corrections as per-claim edits and general corrections as a single proposal.

    3k GitHub stars~290 tokensUpdated yesterday
    Research & ScienceAuto-check passed
  • Immutable Patterns

    thedaviddias/Front-End-Checklist

    A skill your agent uses when reviewing scripts, client components, bundles, or runtime behavior related to Prefer immutable data patterns.

    74k GitHub stars~505 tokensUpdated yesterday
    Auto-check passed
  • Context Save

    garrytan/gstack

    Captures git state, decisions made and remaining work so that a later session can resume the task without losing context.

    136k GitHub stars~9.7k tokensUpdated today
    Agent WorkflowsAuto-check: notes
  • Save As PDF

    asgeirtj/system_prompts_leaks

    Print-ready PDF export

    69k GitHub stars~2.3k tokensUpdated yesterday
    Documents & OfficeAuto-check passed
  • Save to Obsidian Vault

    AgriciDaniel/claude-obsidian

    Files a specific answer, decision or insight you point to in a conversation as one reviewed note in your Obsidian vault, and only when you ask for it.

    15k GitHub stars~1.3k tokensUpdated 26 days ago
    Knowledge ManagementAuto-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 7 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 7 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 7 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 7 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 7 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 7 days ago
    Auto-check passed

Questions about Immutable Constants

What does Immutable Constants do?

Proper use of immutable and constant variables for gas savings and correctness. Immutable Constants is an agent skill from ccashwell/evm-cortex. Proper use of immutable and constant variables for gas savings and correctness.

When should I use Immutable Constants?

Immutable Constants fits situations like: deploying contracts with fixed configuration; deciding between constant; storage variables.

How do I install Immutable Constants in Claude Code?

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

How do I install Immutable Constants in Codex?

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

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

What does Immutable Constants need to run?

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

Does Immutable Constants 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 Immutable Constants 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 Immutable Constants use?

Immutable Constants 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 Immutable Constants 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 Immutable Constants?

Skills that share tags, products or a category with Immutable Constants: Correct (cursor/plugins, 10k stars), Correction (NxcoreAI/EverRoom, 3k stars), Immutable Patterns (thedaviddias/Front-End-Checklist, 74k stars) and Context Save (garrytan/gstack, 136k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Immutable Constants?

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.