solidity-style-guide
llms.txt32 starsChanged 8 months agoMITView on GitHub
A practical Solidity style guide for writing consistent, safe, and gas-aware smart contracts. Targets Solidity 0.8.34 with coverage of ERC-7201 namespaced storage, transient storage, custom errors in require, named imports, NatSpec, and Foundry testing conventions. The canonical source is README.md. This file is a machine-friendly index for LLMs.
In this repository3 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- solidity-style-guideSkill
The file
We split this llms.txt into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 27
Use the latest stable Solidity (0.8.34 at time of writing).
- Very specific: line 29
Use named imports: import {X} from "./X.sol";.
- Very specific: line 30
Use custom errors, including inside require(cond, CustomError()) (≥ 0.8.26).
- Very specific: line 32
Always write explicit types: uint256, not uint.
≈ “Common” is an estimate: at least 1 in 5 of the 1,484 llms.txt files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
# Solidity Style Guide
> A practical Solidity style guide for writing consistent, safe, and gas-aware smart contracts. Targets Solidity 0.8.34 with coverage of ERC-7201 namespaced storage, transient storage, custom errors in `require`, named imports, NatSpec, and Foundry testing conventions.
The canonical source is `README.md`. This file is a machine-friendly index for LLMs.
## Docs
- [README](https://raw.githubusercontent.com/Aboudjem/solidity-style-guide/main/README.md): full guide with ✅ / ❌ Solidity examples for every rule.
- [AGENTS.md](https://raw.githubusercontent.com/Aboudjem/solidity-style-guide/main/AGENTS.md): instructions for coding agents editing or applying the guide.
- [CLAUDE.md](https://raw.githubusercontent.com/Aboudjem/solidity-style-guide/main/CLAUDE.md): Claude Code–specific notes.
- [CONTRIBUTING](https://raw.githubusercontent.com/Aboudjem/solidity-style-guide/main/CONTRIBUTING.md): how to propose new rules.
- [SECURITY](https://raw.githubusercontent.com/Aboudjem/solidity-style-guide/main/SECURITY.md): disclosure policy.
## Tooling configs (copy-paste ready)
- [.solhint.json](https://raw.githubusercontent.com/Aboudjem/solidity-style-guide/main/.solhint.json): Solhint rules matching the guide.
- [.prettierrc](https://raw.githubusercontent.com/Aboudjem/solidity-style-guide/main/.prettierrc): prettier-plugin-solidity config (120 cols, 4 spaces, double quotes).
- [.editorconfig](https://raw.githubusercontent.com/Aboudjem/solidity-style-guide/main/.editorconfig): editor defaults.
## Skill package
- [skill/SKILL.md](https://raw.githubusercontent.com/Aboudjem/solidity-style-guide/main/skill/SKILL.md): Claude Code skill for applying the guide on any Solidity repo.
## Core rules (one-liners)
- Use the latest stable Solidity (**0.8.34** at time of writing).
- Pin `pragma solidity 0.8.34;` in deployable contracts; use `^0.8.20` in libraries.
- Use **named imports**: `import {X} from "./X.sol";`.
- Use **custom errors**, including inside `require(cond, CustomError())` (≥ 0.8.26).
- **ERC-7201 namespaced storage** for upgradeable contracts.
- Always write explicit types: `uint256`, not `uint`.
- Internal / private identifiers start with `_`.
- Constants `SNAKE_UPPER_CASE`, private constants `_SNAKE_UPPER_CASE`.
- Max line length 120, 4-space indent, LF, UTF-8.
- One contract / interface / library per file, name matching filename.
- Foundry test naming: `test_Description`, `testFuzz_Description`, `test_RevertWhen_Description`, `invariant_Property`.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

