Logo van Solidity Style Guide

Solidity Style Guide

Community
Aboudjem
solidity-style-guide

Apply the Aboudjem/solidity-style-guide rules to Solidity code — review, rewrite, or audit for naming, layout, formatting, NatSpec, custom errors, ERC-7201 storage, gas patterns, and Foundry test structure. Trigger when the user asks to "review Solidity style", "apply the style guide", "format .sol file", or mentions Solhint / Prettier / Foundry conventions in a Solidity repo.

Overzicht

UitgeverAboudjem
Repositorysolidity-style-guide
Skillnaamsolidity-style-guide
Sterren
32
Forks
20
Meegeleverde bestanden
2
LicentieMIT
Links
  • Instructies in Markdown

    Een SKILL.md-bestand dat het model laadt wanneer nodig, zodat het alleen tokens kost als een verzoek er daadwerkelijk bij past.

  • Werkt met elk LLM

    AI-skills zijn gewone Markdown, geen aanbiederspecifieke code. Daardoor werken ze met GPT, Claude, Gemini, Grok of een lokaal model.

  • 2 meegeleverde bestanden

    Scripts, sjablonen en referentiemateriaal die het model tijdens het werken kan lezen. Bestanden zijn alleen-lezen en worden nooit uitgevoerd.

  • Open source

    Gepubliceerd door Aboudjem op GitHub. Lees de broninhoud voordat je de skill installeert.

Installatie

Installeer de AI-skill Solidity Style Guide in TypingMind om deze met elke LLM te gebruiken, of voeg de skill toe aan een andere agent die SKILL.md kan lezen.

1

Installeren in TypingMind

TypingMind installeert een skill rechtstreeks vanuit de GitHub-map — het leest SKILL.md, bundelt de bijbehorende bestanden en slaat het resultaat lokaal op.

  1. Open de app en ga naar Plug-ins → Skills.
  2. Kies "Installeren via GitHub".
  3. Plak de onderstaande URL van de skillmap en bevestig.
    https://github.com/Aboudjem/solidity-style-guide/tree/main/skill
  4. Schakel de skill in elke chat in waarin je deze beschikbaar wilt hebben.
Plug-ins → Skills → Nieuwe skill → Via GitHub-URL. Plak vervolgens de map-URL en druk op Doorgaan.
2

Installeren in een andere agent

Elke agent die het Agent Skills-formaat kan lezen, kan deze skill gebruiken — kopieer de map naar de skillmap van die agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Aboudjem/solidity-style-guide.git /tmp/solidity-style-guide
mkdir -p .claude/skills
cp -r /tmp/solidity-style-guide/skill .claude/skills/solidity-style-guide
Start Claude Code na het kopiëren opnieuw op, zodat de nieuwe skill wordt herkend.

Gebruik deze skill in TypingMind

Schakel Solidity Style Guide in een willekeurige chat in TypingMind in en het model doet de rest. De naam en beschrijving staan in de systeemprompt. Zodra een verzoek erbij past, laadt het model zelf de volledige instructies — je hoeft de skill nooit handmatig aan te roepen en deze kost pas tokens wanneer je de skill daadwerkelijk gebruikt.

Het model laadt Solidity Style Guide automatisch zodra een verzoek erbij past.

Werkt met elk AI-model

AI-skills zijn gewone Markdown-instructies in plaats van aanbiederspecifieke code. Daardoor is Solidity Style Guide niet gebonden aan het model waarvoor de skill is geschreven. Installeer de skill één keer in TypingMind en gebruik deze met GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama of een lokaal model dat je zelf draait — allemaal met je eigen API-sleutels.

  • Alleen geladen wanneer nodig

    De systeemprompt bevat alleen de naam en beschrijving. De instructies worden bij het eerste bijpassende verzoek opgehaald, dus een ongebruikte skill kost niets.

  • Wissel van model tijdens een chat

    Omdat de skill uit instructies bestaat en niet uit code, blijft deze werken als je van model wisselt — het volgende model leest hetzelfde SKILL.md-bestand.

Skillinstructies

Dit is de inhoud van SKILL.md die het model laadt. Lees deze vóór de installatie — een skill bestaat uit instructies die je model zal volgen.

Solidity Style Guide — Claude Code Skill

Use this skill whenever you are reviewing or writing Solidity, Foundry tests, or related configuration. It codifies the rules in Aboudjem/solidity-style-guide targeting Solidity 0.8.34.

When to invoke

Trigger automatically on:

  • .sol files in the workspace
  • foundry.toml, remappings.txt, .solhint.json present
  • User says: review my contract, clean up this Solidity, apply the style guide, is this gas-optimal?, make this audit-ready

Output contract

  1. Produce a checklist of violations grouped by category (layout → naming → formatting → NatSpec → best practices → tests → gas → security).
  2. Quote the offending snippet with file path and line number.
  3. Propose a minimal diff that makes it compliant. Preserve behavior; style changes only unless asked.
  4. Cite the rule inline, e.g., [§Best Practices > Using Custom Errors Over Require].
  5. Stop before applying unless the user asked for an auto-fix.

Hard rules (block the review on violation)

Files & layout

  • SPDX license identifier on every .sol file
  • One contract / interface / library per file; filename matches the core type
  • Top-level 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
  • Within each visibility group, put view then pure last

Imports

  • Named imports only: import {X} from "./X.sol";
  • Sort by path length within groups; blank line between external and internal
  • No wildcard imports

Pragma

  • Applications: pin to a single version — pragma solidity 0.8.34;
  • Libraries / mixins: open range — pragma solidity ^0.8.20;
  • Never ^0.8.0 ^0.9.0 or other multi-constraint forms

Types

  • Always explicit: uint256, int256, bytes1 — never uint, int, byte
  • bool booleans, not uint flags
  • Prefer bytes over string when non-human-readable

Naming

ElementStyleNotes
Contract / Library / InterfacePascalCaseInterfaces prefixed I
Struct / Event / Enum / custom ErrorPascalCaseEvents in past tense
Function / modifier / variable / argumentcamelCase
Public constantSNAKE_UPPER_CASE
Private / internal constant_SNAKE_UPPER_CASELeading _
Non-external fn / state var_leadingUnderscore
Avoidl, O, I single-letterVisually ambiguous

Formatting

  • 4-space indent, spaces (no tabs)
  • Max line length 120 chars
  • Strings in double quotes
  • One space around binary operators; no space inside parens / brackets
  • mapping(K => V) — no space after mapping
  • uint[] — no space before []
  • Braces on same line as declaration; else on the same line as the closing brace
  • Long signature: each arg on its own line, closing ) and { on their own lines

Best practices

  • Prefer custom errors. Use require(cond, CustomError(arg1, arg2)) when on Solidity ≥ 0.8.26 (via-ir) or ≥ 0.8.27 (legacy). Otherwise if (!cond) revert CustomError(...);.
  • If a require string message is unavoidable, keep it under 32 bytes.
  • calldata for read-only array / struct params on external functions.
  • Cache .length before the loop header.
  • Prefer named returns for functions with ≥ 2 return values.
  • Prefer named arguments in calls, events, errors with ≥ 3 parameters.
  • Named parameters in mappings: mapping(address user => mapping(address asset => uint256 amount)).
  • Interact with external contracts through typed interfaces; if using call, use abi.encodeWithSelector.
  • For upgradeable contracts, use ERC-7201 namespaced storage with @custom:storage-location erc7201:<namespace>.
  • Events in past tense: OwnerUpdated, FundsDeposited.
  • Avoid inline assembly unless there is no high-level alternative; when used, document every opcode.
  • Prefer composition over inheritance.

NatSpec

  • @title, @author, @notice, @dev, @param, @return on every public / external function
  • Internal / library functions used by other devs: also NatSpec

Foundry testing conventions

  • File naming: MyContract.sol ↔ MyContract.t.sol; split large: MyContract.owner.t.sol, MyContract.deposits.t.sol
  • Test names: test_Description, testFuzz_Description, test_RevertWhen_Condition, test_RevertIf_Condition, testFork_Description, testForkFuzz_RevertIf_Condition
  • Invariants: invariant_Property (e.g., invariant_TotalSupplyEqualsSumOfBalances)
  • No assertions inside setUp; use a dedicated test_SetUpState
  • Verbose assertion messages: assertEq(x, y, "Invariant violated: …")

Gas patterns

  • Mark values set once as immutable; mark compile-time values as constant
  • Prefer uint256 over smaller ints unless packing is intentional
  • Hoist array length out of loops; use unchecked { ++i; } where safe (Solidity ≥ 0.8.22 already optimizes simple ++i increments, but unchecked still helps for custom counters)
  • Use transient storage (tstore / tload, EIP-1153) for per-transaction flags like reentrancy locks when the EVM target supports it (Cancun+). Solidity 0.8.34 default EVM is Prague.

Security

  • Checks → Effects → Interactions
  • Reentrancy guard (mutex) around any external call that precedes state writes
  • call{value: x}("") for Ether transfers; always check the returned bool
  • No tx.origin for authorization
  • Pull over push payment patterns where feasible

Invocation recipes

/solidity-style-guide:review

Scan the repo, produce a categorised violations report, do not edit.

/solidity-style-guide:review --fix

Apply the minimal formatting and naming diffs (no logic changes) and print a summary. Behavior-changing rewrites remain advisory.

/solidity-style-guide:apply-config

Copy the .solhint.json, .prettierrc, .editorconfig, and .prettierignore from this repo into the current project (do not overwrite if present without asking).

References

Meegeleverde bestanden

Het model leest deze bestanden wanneer nodig terwijl de skill geladen is. Ze worden beschikbaar gesteld als leesbare bestanden en worden nooit uitgevoerd.

Veelgestelde vragen

Wat doet de AI-skill Solidity Style Guide?

Apply the Aboudjem/solidity-style-guide rules to Solidity code — review, rewrite, or audit for naming, layout, formatting, NatSpec, custom errors, ERC-7201 storage, gas patterns, and Foundry test structure. Trigger when the user asks to "review Solidity style", "apply the style guide", "format .sol file", or mentions Solhint / Prettier / Foundry conventions in a Solidity repo.

Waarom Solidity Style Guide gebruiken in TypingMind?

Omdat je deze skill één keer installeert en met elk model kunt gebruiken. Solidity Style Guide bestaat uit gewone Markdown in plaats van aanbiederspecifieke code. Dezelfde skill werkt dus met GPT-5, Claude, Gemini, Grok of een lokaal model, en je kunt midden in een chat van model wisselen zonder dat de skill niet meer werkt. TypingMind werkt met je eigen API-sleutels, dus je betaalt aanbieders rechtstreeks in plaats van een abonnement per gebruikersplek. Je skills en chats blijven in je eigen opslag.

Hoe installeer ik Solidity Style Guide in TypingMind?

Open Plug-ins → Skills → Installeren vanaf GitHub in TypingMind en plak https://github.com/Aboudjem/solidity-style-guide/tree/main/skill. TypingMind leest het bestand SKILL.md, bundelt de bijbehorende bestanden en installeert het geheel als een skill die je per chat kunt inschakelen.

Welke AI-modellen kunnen Solidity Style Guide gebruiken?

Elk model dat je in TypingMind koppelt. AI-skills bestaan uit gewone Markdown-instructies in plaats van aanbiederspecifieke code. GPT, Claude, Gemini, Grok en lokale modellen kunnen deze skill dus allemaal laden wanneer een verzoek erbij past.

Hoeveel AI-modellen kan ik met Solidity Style Guide gebruiken?

Zoveel als je wilt. Zolang een model skills ondersteunt, kun je Solidity Style Guide ermee gebruiken: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama en meer. Allemaal in TypingMind met je eigen API-sleutels.

Is de AI-skill Solidity Style Guide gratis?

Ja. Deze skill is door Aboudjem op GitHub gepubliceerd onder de licentie MIT. Je betaalt alleen je eigen AI-aanbieder voor de tokens die je gebruikt.

Wat zijn AI-skills?

Een AI-skill is een herbruikbare bundel instructies die een AI-model leert hoe het één specifieke taak moet uitvoeren. Deze volgt het open Agent Skills-formaat: een bestand met de naam SKILL.md met een naam en beschrijving, plus eventuele scripts, sjablonen of referentiebestanden die het model nodig heeft. Het model leest de instructies alleen als je verzoek bij de skill past. Een geïnstalleerde skill kost dus niets zolang deze niet wordt gebruikt.

Waarin verschillen AI-skills van plug-ins of MCP-servers?

Een plug-in of MCP-server geeft een model nieuwe tools om aan te roepen: code die ergens wordt uitgevoerd en een resultaat teruggeeft. Een AI-skill geeft het model juist kennis en een werkwijze: hoe het een taak moet aanpakken, welke stappen het moet volgen en hoe goede uitvoer eruitziet. Skills bestaan uit gewone Markdown en hebben dus geen server, API-sleutel of runtime nodig. Ze werken met elk model.

Toon alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇