/hermes:hermesfrom Hermes
Optimises Solidity gas usage with a fail-closed Foundry loop that measures savings, re-runs behaviour tests, checks storage layouts and method identifiers, and demands differential or property evidence for state-sensitive unchecked arithmetic.
Ships in Hermes. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Hermes owns its own gas-optimisation evidence frontier, not Hexaemeron's delivery or Solidity frontier. Its version, held target, next job, and maturity state live in EVOLUTION.md. Do not recommend or run another frontier pass after that ledger becomes mature.
Hermes measures one named Solidity gas optimisation class at a time and rejects the candidate unless every Foundry, behaviour, layout, selector, and arithmetic gate clears.
Current frontier. Hermes's twelve optimisation classes name 62 of the corpus's 120 rules, so 58 documented rules cannot be selected as candidates.
Hermes alone owns Solidity gas optimisation. Metron handles measured performance in every other unit. Pandects can supply economic laws a candidate must preserve, Janus can constrain hook effects, and the Pashov suite can audit the resulting contracts. None of them can replace Hermes's sealed baseline or accept a gas candidate on its behalf.
A Synkrisis comparison may point a person towards a repeated run pattern, but it cannot replace Hermes's controlled before-and-after evidence. A Synkrisis finding is an inferred relation between named events, never a measurement.
The ideas are cheap. The evidence is the job.
Use scripts/hermes.py for every run. It owns the order, seals the baseline, writes the evidence, and exits non-zero at the first bad gate. Every candidate names a rule from references/gas-rule-corpus.json, the pinned corpus of 120 rules, 28 rejected universal rules and 40 citations transcribed from one source document. Use references/optimisation-catalogue.md to read the twelve classes those rules map onto.
Check the corpus before a run and read what it holds:
python3 "$HERMES_PY" corpus --validate
python3 "$HERMES_PY" corpus --validate --json
62 of the 120 rules name a class and can be selected. The other 58 constrain how a run is conducted, or they are architecture; the harness refuses them as candidates and says so rather than measuring something they do not describe.
Developers. A gas change shaves a few hundred units off a hot path and nobody can say whether behaviour moved with it. Run Hermes on that one optimisation class and the review arrives with the snapshot diff, both fuzz passes, the storage layout comparison and a result.json, rather than a number and an assurance.
Security and audit. A gas change arrives from outside the team. Instead of reading it for intent, put it through Gate 5 to see whether any protected contract's storage layout or method identifiers moved, and Gate 6 for unchecked arithmetic that reaches persistent state.
foundry.toml under build/, pass build/ as --repo.delegatecall, clones, factories, hooks, role providers, and contracts called by them. Treat doubt as frozen layout.--gas-target is a regular expression and must contain a measured saving.Set HERMES_PY to this skill's scripts/hermes.py path. Keep the run directory printed by Gate 1; every later command uses it.
List every hook, role provider, proxied implementation, facet, factory-sensitive contract, and other frozen layout with --protected-contract. Use a qualified path:Contract identifier when names collide.
python3 "$HERMES_PY" baseline \
--repo "<foundry-root>" \
--fuzz-seed 0x5EED \
--no-match-path "test/Fork.t.sol" \
--protected-contract "Market=src/Market.sol:Market" \
--protected-contract "Hooks=src/Hooks.sol:Hooks"
Repeat --no-match-path and --protected-contract as needed. Omit exclusions that the repository does not need.
If no frozen contract is in scope, say so explicitly:
python3 "$HERMES_PY" baseline \
--repo "<foundry-root>" \
--fuzz-seed 0x5EED \
--assert-no-protected-contracts
Add --layout-contract "Label=path:Contract" for a non-frozen contract whose layout still needs recording. This is useful for a deliberate packing change.
Gate 1 runs forge snapshot and then forge test, in that order. It records the snapshot, green test result, Forge version, canonical Foundry config, Git revision, Solidity sources, storage layouts, method identifiers, and the rule corpus with its digest. A corpus that fails its own schema ends the run here, so a candidate is never judged under advice nobody checked. A dirty tree, red suite, missing snapshot, failed inspect, or invalid JSON ends the run.
Every verify names one corpus rule with --rule. The rule decides the class, so a declared
--optimisation-class that disagrees with it is refused. Gate 2 refuses before Gate 3
spends a Forge run, and result.json carries a refusal field naming which condition failed:
corpus/unknown-rule: no rule of that idcorpus/myth-selected: a rejected universal rule named as a candidate, answered with its correctioncorpus/myth-cited: a rationale or obligation answer citing a rejected rule as its justificationcorpus/rule-names-no-class: a rule that constrains the run or is architecture, so no candidate implements itcorpus/class-disagreement: the declared class is not the rule's classcorpus/out-of-scope: the target's compiler, fork or pipeline is outside the rule's declared scopecorpus/scope-unresolved: the target pins no readable solc, or names a fork the corpus does not ordercorpus/obligation-unanswered: an obligation the rule's own statement makes has no substantive answercorpus/obligation-malformed: an --obligation argument is not <n>=<answer>, or names an index the rule lackscorpus/digest-moved: the corpus changed after the baseline sealed itcorpus/invalid: the corpus does not pass its own schemaAnswer each of the rule's obligations with --obligation "<n>=<answer>", one per obligation, indexed
from one. Those answers are recorded judgement rather than measurement, and result.json marks them
as such. The six gates below do not move because of them.
Then choose that rule's class and make only that kind of source change. Do not mix cleanup, compiler settings, test edits, or a second gas idea into the candidate.
Review candidate.solidity.diff before attesting. The harness rejects Solidity file additions or removals, test-source edits, an empty candidate, added unchecked outside unchecked-arithmetic, and added assembly outside assembly. The attestation remains a judgement: read the diff and confirm that every hunk belongs to the declared class.
If the required property test is absent, add it in a preparatory change, get green, and take a fresh baseline. The optimisation candidate uses the existing fuzz suite rather than changing its own oracle.
For an ordinary candidate:
python3 "$HERMES_PY" verify \
--run-dir "<run-dir>" \
--rule STO-09 \
--obligation "1=The cache is loaded after the last write and every use sits inside one call frame." \
--optimisation-class storage-load-caching \
--attest-single-class \
--gas-target 'LedgerTest:test_update' \
--gas-target 'LedgerTest:test_batch' \
--no-sensitive-unchecked
For unchecked arithmetic outside state-sensitive code, add a real explanation:
--no-sensitive-unchecked \
--non-sensitive-rationale "The loop counter is bounded by the in-memory array length and cannot affect persistent state, asset balances, external call parameters, or rounding."
For unchecked arithmetic that can affect persistent state, asset accounting, external calls, permissions, or rounding, run the existing targeted differential or property test:
python3 "$HERMES_PY" verify \
--run-dir "<run-dir>" \
--rule CTL-05 \
--obligation "1=Every intermediate is bounded by the array length checked at the loop head." \
--obligation "2=The unchecked region is three lines and the bound is stated beside it." \
--optimisation-class unchecked-arithmetic \
--attest-single-class \
--gas-target 'LedgerTest:test_update' \
--sensitive-unchecked \
--targeted-match-path 'test/StateDifferential.t.sol' \
--targeted-match-test 'testFuzz_diff_stateTransition' \
--property-proof "Compare the checked reference and candidate across the complete reachable input domain; assert equal state transitions and equal overflow reverts at the arithmetic boundaries."
Run forge snapshot --diff <baseline> and capture a candidate snapshot. Reject a positive deterministic delta anywhere, a changed measurement set, a target with no match, or a target with no saving. Then run forge test --gas-report.
Historical Foundry snapshots also contain fuzz statistics whose sampled inputs can change when the compiled bytecode changes. Hermes records their baseline and candidate means and medians, but does not call those aggregates a gas regression or saving. It still rejects a changed fuzz-test set or run count. Foundry invariant_callSummary() rows are stricter: their test set, run count, call count, and revert count must stay identical.
Run the full forge test suite with the pinned seed, followed by a full unpinned run. Any failure rejects the candidate.
Re-run forge inspect <C> storageLayout --json --force and methodIdentifiers for every recorded contract. The layout comparison canonicalises solc's compilation-local AST IDs, while retaining raw inspector output in evidence; it hard-aborts on any structural protected-layout difference or method-selector difference. A declared layout change is allowed only for an unprotected contract under the rules below.
When --sensitive-unchecked applies, run the named targeted differential or property test and record its oracle. Otherwise, record why the candidate does not introduce or rely on state-sensitive unchecked arithmetic.
Only storage-packing and constants-immutables may declare one. The contract must have been listed with --layout-contract, never --protected-contract.
--allow-unprotected-layout-change \
--layout-change-rationale "No proxy, hook, role provider, delegate call, deployed factory instance, storage-reading test, or indexer consumes this layout."
Hermes records the diff. It rejects an undeclared difference, a declared difference that never occurred, or any difference on the frozen set.
Before accepting the Gate 6 result, inspect the named test and confirm all of the following:
0, 1, maxima, time deltas, input bounds, balance bounds, rounding boundaries, plus the exact safe and unsafe arithmetic edges.bound() or assumption that removes the dangerous region.test/Fuzz.t.sol, with the baseline seed recorded in the command.A comment explaining why arithmetic looks safe is useful review context. It is not Gate 6 evidence.
Exit 0 plus result.json status accepted is the acceptance signal. Exit codes identify the rejected gate: 10, 20, 30, 40, 50, or 60. result.json, the command logs, gas comparison, source diff, layouts, and method maps stay together in the run directory.
Stop after any rejection. Do not tweak tolerances, alter the target set after seeing the result, weaken a test, or add another optimisation to cover the loss. Remove only the candidate changes, return to the last green state, and begin again at Gate 1.
After acceptance, promote the candidate snapshot deliberately:
python3 "$HERMES_PY" promote --run-dir "<run-dir>"
That accepted state becomes the baseline for the next class. Never run two classes through one Hermes record.
forge is unavailable, report that no gas result can be measured.baseline seals a green, clean Foundry baseline with the named gas measurements, configuration, seed, source revision, protected layouts, method identifiers and the validated rule corpus with its digest.refusal field on any rejection.solc_version and evm_version where the scope cannot be resolved, or add the missing rule to the corpus in separate work before starting a new run.verify with result.json status accepted establishes measured savings for every named target, no deterministic regression, passing pinned and unpinned behaviour suites, preserved protected layouts and selectors, and the required unchecked-arithmetic evidence for one declared class, under one named corpus rule whose scope the target satisfies.result.json.promote advances the Hermes baseline only to the exact candidate already accepted by the same run record.result.json, matching run directory, candidate snapshot and promotion command result.DEMONSTRATION.md (opens in a new tab)EVOLUTION.md (opens in a new tab)agents/openai.yaml (opens in a new tab)references/gas-rule-corpus.json (opens in a new tab)references/gas-rule-corpus.schema.json (opens in a new tab)references/optimisation-catalogue.md (opens in a new tab)scripts/hermes.py (opens in a new tab)scripts/test_hermes.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub wildcat-finance/skills --plugin hermesOther plugins' skills for the same job