Logo di 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.

Panoramica

AutoreAboudjem
Repositorysolidity-style-guide
Nome della skillsolidity-style-guide
Stelle
32
Fork
20
File inclusi
2
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • 2 file inclusi

    Script, modelli di documento e riferimenti che il modello può leggere mentre lavora. I file sono di sola lettura e non vengono mai eseguiti.

  • Open source

    Pubblicata da Aboudjem su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Solidity Style Guide in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/Aboudjem/solidity-style-guide/tree/main/skill
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Nuova skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella nella cartella delle skill di quell'agente.

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
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Solidity Style Guide in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Solidity Style Guide non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Solidity Style Guide non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

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

File inclusi

Il modello legge questi file quando servono, mentre la skill è caricata. Sono accessibili in sola lettura e non vengono mai eseguiti.

Domande frequenti

Cosa fa la skill IA 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.

Perché usare Solidity Style Guide su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Solidity Style Guide è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Solidity Style Guide in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/Aboudjem/solidity-style-guide/tree/main/skill. TypingMind legge il file SKILL.md, include i file associati e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Solidity Style Guide?

Qualsiasi modello che colleghi in TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Solidity Style Guide?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Solidity Style Guide: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Solidity Style Guide è gratuita?

Sì. È pubblicata su GitHub da Aboudjem con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, modelli o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇