Solidity Coding Practices
Application skill for official Solidity style + Solcurity (archived awesome-guidelines capsules). Project-specific guides override when stricter.
Core Principle
Solidity quality is consistent layout + documented public API + security-aware effects ordering, CapWords types, mixedCase members, visibility ladder, CEI on value paths.
When to Use / NOT
- Smart contracts (Foundry/Hardhat/Truffle), libraries, interfaces, upgradeable proxies.
- Setting up
forge fmt, NatSpec, Slither, fuzz tests, named imports.
NOT when:
- Vyper/Move/Cairo, different language guides.
- Generated ABI bindings only, validate generators, not hand-style rules.
Workflow
- Formatting, indent, wraps, braces (
solidity-style-formatting-layout.md).
- Naming/NatSpec, CapWords/mixedCase, public docs (
solidity-style-naming-natspec.md).
- Structure, file/contract order, visibility ladder (
solidity-style-contract-structure.md).
- Security, Solcurity CEI/calls/events (
solidity-style-security-verify.md).
- Verify,
forge fmt/forge test, Slither on changed contracts.
Red Flags
- Tab characters or mixed tab/space
- Lines >120 without wrap
- Imports mid-file or wildcard-only imports
- Missing SPDX license identifier
- Contract filename mismatch (lowercase file, CapWords type)
- Wrong function order (externals before constructor)
- Modifier order wrong (
override view vs view override)
mapping (uint => uint) or uint [] spacing
- Single-quoted strings by default
else on new line after if block
- Alignment padding around
=
- Space inside
receive () / fallback ()
- Missing
_ on internal/private helpers
- External function promoted from internal without call-site review
- Missing NatSpec on new public/external API
- Storage update after external call (CEI violation)
tx.origin for authorization
transfer/send for ETH payouts
- Unchecked ERC20 return values
assert for user-input validation
- Unbounded loop over user-controlled length
- Modifier with storage writes (except reentrancy lock) or external calls
- Dynamic type indexed in events
- Deep inheritance diamond without documented reason
- Spot AMM price used as oracle
- Bug fix without unit/fuzz regression
- Slither findings ignored without documented rationale
Verification
forge fmt --check (or prettier-plugin-solidity) on changed .sol
forge test / project test runner on touched contracts
- NatSpec coverage spot-check on new externals
- Visibility-order and import-group walk
- Slither (or Solhint) on PR diff
- Capsule checklist: CEI on value-moving functions
References
awesome-guidelines/references/solidity-style-learning-note.md
awesome-guidelines/references/solidity-style-formatting-layout.md
awesome-guidelines/references/solidity-style-naming-natspec.md
awesome-guidelines/references/solidity-style-contract-structure.md
awesome-guidelines/references/solidity-style-security-verify.md
1---2name: solidity-coding-practices3description: Use when authoring or reviewing Solidity, official layout/naming, NatSpec ABI docs, contract structure, Solcurity CEI/external-call checks, forge fmt/test and Slither in CI.4---56# Solidity Coding Practices78Application skill for official Solidity style + Solcurity (archived `awesome-guidelines` capsules). Project-specific guides override when stricter.910## Core Principle1112Solidity quality is **consistent layout + documented public API + security-aware effects ordering**, CapWords types, mixedCase members, visibility ladder, CEI on value paths.1314## When to Use / NOT1516- Smart contracts (Foundry/Hardhat/Truffle), libraries, interfaces, upgradeable proxies.17- Setting up `forge fmt`, NatSpec, Slither, fuzz tests, named imports.1819**NOT when:**2021- Vyper/Move/Cairo, different language guides.22- Generated ABI bindings only, validate generators, not hand-style rules.2324## Workflow25261. **Formatting**, indent, wraps, braces (`solidity-style-formatting-layout.md`).272. **Naming/NatSpec**, CapWords/mixedCase, public docs (`solidity-style-naming-natspec.md`).283. **Structure**, file/contract order, visibility ladder (`solidity-style-contract-structure.md`).294. **Security**, Solcurity CEI/calls/events (`solidity-style-security-verify.md`).305. **Verify**, `forge fmt`/`forge test`, Slither on changed contracts.3132## Red Flags3334- Tab characters or mixed tab/space35- Lines >120 without wrap36- Imports mid-file or wildcard-only imports37- Missing SPDX license identifier38- Contract filename mismatch (lowercase file, CapWords type)39- Wrong function order (externals before constructor)40- Modifier order wrong (`override view` vs `view override`)41- `mapping (uint => uint)` or `uint []` spacing42- Single-quoted strings by default43- `else` on new line after `if` block44- Alignment padding around `=`45- Space inside `receive ()` / `fallback ()`46- Missing `_` on internal/private helpers47- External function promoted from internal without call-site review48- Missing NatSpec on new public/external API49- Storage update after external call (CEI violation)50- `tx.origin` for authorization51- `transfer`/`send` for ETH payouts52- Unchecked ERC20 return values53- `assert` for user-input validation54- Unbounded loop over user-controlled length55- Modifier with storage writes (except reentrancy lock) or external calls56- Dynamic type indexed in events57- Deep inheritance diamond without documented reason58- Spot AMM price used as oracle59- Bug fix without unit/fuzz regression60- Slither findings ignored without documented rationale6162## Verification6364- `forge fmt --check` (or prettier-plugin-solidity) on changed `.sol`65- `forge test` / project test runner on touched contracts66- NatSpec coverage spot-check on new externals67- Visibility-order and import-group walk68- Slither (or Solhint) on PR diff69- Capsule checklist: CEI on value-moving functions707172## References7374- `awesome-guidelines/references/solidity-style-learning-note.md`75- `awesome-guidelines/references/solidity-style-formatting-layout.md`76- `awesome-guidelines/references/solidity-style-naming-natspec.md`77- `awesome-guidelines/references/solidity-style-contract-structure.md`78- `awesome-guidelines/references/solidity-style-security-verify.md`