@aboudjem/solidity-style-guide
AAGENTS.md
Install
agr install @aboudjem/solidity-style-guide --target claudeWrites 1 file into .claude/skills/, pinned to git-9effb5e6.
- .claude/skills/solidity-style-guide/AGENTS.md
Document
AGENTS.md
A short context file for coding agents (Claude Code, Cursor, Codex, Aider, etc.) working in this repository. For humans: see README.md. The full rule catalog lives in the README; this file is the short version for coding agents.
What this repo is
A Solidity style guide: conventions, formatting, best practices, testing, gas, and security rules for modern Solidity (≥ 0.8.20, targeting 0.8.34). It is documentation, not deployable code.
Ground rules for agents editing this repo
- No emojis in code examples. Emojis are fine in READMEs when they aid scanning, but avoid adding them where none exist.
- Do not shorten the guide. Each rule is load-bearing; prefer adding a new rule section over collapsing two.
- Every rule must have a ✅ Yes / ❌ No Solidity example. Single-example rules are incomplete.
- Max line length 120 (Solidity and Markdown prose). Indent Solidity with 4 spaces.
- Pragma in examples: use
^0.8.20for libraries and0.8.34(pinned) for application contracts, unless the rule is specifically about version pragmas. - Prefer named imports.
import {X} from "./X.sol";. Never use bareimport "./X.sol";. - Prefer custom errors over
requirestrings. Userequire(cond, CustomError())(Solidity ≥ 0.8.26) orrevert CustomError(). - When in doubt, cite a source in the rule (Solidity docs, EIP, Foundry book, RareSkills, Coinbase guide).
When asked to apply the style guide to a codebase
Treat the following as hard rules (block the PR on violation):
- SPDX license identifier present on every
.solfile - Single contract / interface / library per file
- Layout order: pragmas → imports → events → errors → interfaces → libraries → contracts
- Inside a contract: type declarations → state vars → events → errors → modifiers → functions
- Function order: constructor → receive → fallback → external → public → internal → private (view/pure last in each group)
- Interfaces prefixed
I(e.g.,IToken) - Constants
SNAKE_UPPER_CASE, private constants_SNAKE_UPPER_CASE - Internal / private identifiers prefixed with
_ - No
uint/int/byte— always explicituint256,int256,bytes1 - Use
calldatafor read-only array/struct parameters on external functions - Cache
.lengthoutside the loop header - For upgradeable contracts, use ERC-7201 namespaced storage
Treat the following as warnings (suggest, don't block):
- Prefer named returns
- Prefer named arguments for calls with ≥ 3 args
- Named parameters in nested mappings
Commands agents can run
This repo is docs-only, so there's no compile step. Quality gates:
# Verify Markdown
npx markdownlint-cli2 "**/*.md" "#node_modules"
# Verify formatting
npx prettier --check .
# Check links in top-level docs
npx markdown-link-check README.md AGENTS.md CONTRIBUTING.md SECURITY.md
# Everything
npm run check
File map
/README.md Main guide (SEO-optimised, animated banner)
/AGENTS.md This file
/CLAUDE.md Claude Code specific instructions
/llms.txt LLM discovery index
/.cursorrules Cursor IDE rules mirror
/SECURITY.md Disclosure policy
/CONTRIBUTING.md PR workflow
/CODE_OF_CONDUCT.md Community standards
/.solhint.json Linter config matching this guide
/.prettierrc Formatter config matching this guide
/.editorconfig Editor-level defaults
/assets/banner.svg Animated hero banner
/skill/ Claude Code skill package (solidity-style-guide)
/.github/ Issue / PR templates and CI
Style for edits to this guide
- Add a new rule? Match the existing pattern:
#### Rule Name→ short rationale →**✅ Yes:**/**❌ No:**Solidity blocks →> [!TIP|NOTE|IMPORTANT|WARNING|CAUTION]callout. - Update the table of contents if you add an
H3/H4. - Keep the tone practical. Cite the relevant EIP, Solidity release note, or audit finding where possible.
Non-goals
- This repo does not ship example contracts to deploy.
- No Solidity toolchain (Foundry / Hardhat) is installed here — examples compile conceptually, not in CI.
- No breaking of the core doc into a docs site generator. Keep
README.mdas the canonical source.
Trustgrade A
- passBody integrity
Whether the stored document is plausibly the kind of file the artifact declares, rather than something fetched by mistake.
- passType matchnot applicable to this artifact type
Whether the artifact is really the kind of thing its metadata claims it is.
- passFreshness
How long since the source repository was last pushed to.
- passPrompt injection
Scans the artifact's own text for instructions aimed at your agent rather than at you.
- passLicense
Whether the source repository declares an SPDX license permissive enough to redistribute.
How the grade is calculated
Each check contributes 0 points when it passes, 1 when it warns, and 2 when it fails. The total maps to a letter:
- Aevery check passed
- Bone warning
- Ctwo warnings
- Dprompt injection or body integrity failed, or three warnings
- Fone of those failed, and something else is wrong
These are automated hygiene checks, not a security audit, and not a dependency or vulnerability scan. A grade of A means nothing was flagged — not that the artifact is safe.
Versions
git-9effb5e63b1b2026-08-04