Solidity Style Guide logo

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.

Overview

PublisherAboudjem
Repositorysolidity-style-guide
Skill namesolidity-style-guide
Stars
32
Forks
20
Bundled files
2
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by Aboudjem on GitHub. Read the source before you install it.

Installation

Install the Solidity Style Guide AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Aboudjem/solidity-style-guide/tree/main/skill
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

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
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Solidity Style Guide in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Solidity Style Guide on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Solidity Style Guide is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Solidity Style Guide AI skill do?

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.

Why use Solidity Style Guide on TypingMind?

Because you install it once and use it with any model. Solidity Style Guide is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Solidity Style Guide in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Aboudjem/solidity-style-guide/tree/main/skill. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Solidity Style Guide?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Solidity Style Guide?

As many as you like. As long as a model supports skills, you can use Solidity Style Guide with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Solidity Style Guide AI skill free?

Yes. It is published on GitHub by Aboudjem under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇