solidity

solidity is a cursor rule for Cursor from sanjeed5/awesome-cursor-rules-mdc. It costs 2,142 tokens per session, scanned A, original, CC0-1.0.

A set of coding rules for Solidity, the programming language used to write smart contracts on blockchains. It emphasizes secure, readable, maintainable, and gas-efficient contract code.

In plain words
What is it for?
Use it when writing or reviewing Solidity contracts, including compiler declarations, formatting, file structure, and security-focused implementation.
Why use it?
It helps reduce avoidable contract bugs, unclear compiler behavior, and wasted blockchain transaction fees.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it when writing or reviewing Solidity contracts, including compiler declarations, formatting, file structure, and security-focused implementation.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/sanjeed5/awesome-cursor-rules-mdc/solidity
About the project

awesome-cursor-rules-mdc is a generator that creates Cursor MDC rule files from structured library information, using semantic search and language models to gather and organize guidance. Developers use it to produce reusable rules for libraries in Cursor, and the catalogue includes 200 of those rules.

sanjeed5/awesome-cursor-rules-mdc · 3,571 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/sanjeed5/awesome-cursor-rules-mdc

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for solidity

README.md
[![agentmods](https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/solidity.svg)](https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/solidity)
Your own site
<a href="https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/solidity"><img src="https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/solidity.svg" alt="Measured on agentmods" height="20"></a>
Per session 2,142 This file is loaded in full into every session.
When invoked 2,142 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.02142 $0.02142
Opus 5 $0.01071 $0.01071
Sonnet 5 $0.00428 $0.00428
Haiku 4.5 $0.00214 $0.00214

Measured 3d ago against content hash ae279d747770, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

solidity scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules-mdc/solidity.mdc · 309 lines

How it starts

The opening of the file, as written. The whole thing — 309 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Solidity Best Practices

This guide outlines the definitive best practices for writing Solidity smart contracts, ensuring security, readability, and efficiency. Adhere to these rules for all new and refactored code.

1. Code Organization & Structure

1.1 File Header

Every Solidity file MUST start with an SPDX license identifier and a precise pragma statement. Pin to a specific, audited compiler version.

❌ BAD

pragma solidity ^0.8.0; // Vague pragma, allows minor version bumps
// No license
contract MyContract {}

✅ GOOD

// SPDX-License-Identifier: MIT
pragma solidity 0.8.29; // Pin to specific, audited compiler version
contract MyContract {}

1.2 Indentation & Whitespace

Use 4 spaces for indentation. Never use tabs. Maintain consistent spacing around operators and within control structures.

❌ BAD

function myFunction (uint256  _value) public {
if(_value > 0){ emit Event(_value);}
}

✅ GOOD

function myFunction(uint256 _value) public {
    if (_value > 0) {
        emit Event(_value);
    }
}

1.3 Blank Lines

Use two blank lines between top-level declarations (contracts, interfaces, libraries). Use one blank line between function declarations within a contract.

❌ BAD

contract A {}
contract B {}
contract C {
    function foo() public {}
    function bar() public {}
}

✅ GOOD

contract A {}


contract B {}


contract C {
    function foo() public {}

    function bar() public {}
}

1.4 Maximum Line Length

Keep lines under 120 characters. Wrap long lines with a single indent for arguments, placing the closing parenthesis/semicolon on its own line.

❌ BAD

function reallyLongFunctionName(address _arg1, uint256 _arg2, bytes32 _arg3, bool _arg4, string memory _arg5) public pure returns (bool) { return true; }

✅ GOOD

function reallyLongFunctionName(
    address _arg1,
    uint256 _arg2,
    bytes32 _arg3,
    bool _arg4,
    string memory _arg5
)
    public
    pure
    returns (bool)
{
    return true;
}

Read the full file on GitHub · 309 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 309 lines · 2,142 tokens per session scan A ae279d747770

Subscribe to this mod's changes

solidity is a cursor rule published in the GitHub repository sanjeed5/awesome-cursor-rules-mdc (3,571 stars, last pushed 3mo ago), licensed CC0-1.0. It adds 2,142 tokens to every session, about $0.0107 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other cursor rules, from other repositories

solana-integration-constraints

Constraints and requirements for Solana integration with MetaMask Connect — wallet adapter config, CAIP-2 IDs, network support per platform, RPC routing, and platform limitations.

MetaMask/metamask-connect-cursor-plugin · 1,207 tokens

zama-protocol-zama-solidity--setups-foundry

Detailed reference for foundry (zama-solidity skill).

zama-ai/skills · 12 tokens

cardano-mcp

These rules complement our main development collaboration rules, focusing specifically on the Model Context Protocol (MCP) server project with TypeScript. This project serves as a specialized RAG (Retrieval-Augmented Generation) gateway to existing Cardano resources, documentation, and tools to assist with dApp…

Jimmyh-world/Cardano_MCP · 3,030 tokens

elizaos_v2_onchain_plugins

┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐ │ Wallet Provider│ │ Connection Mgmt │ │ Transaction Svc │ │ - Private Keys │───▶│ - RPC Endpoints │───▶│ - Tx Construction│ │ - Public Keys │ │ - Network Config │ │ - Fee Estimation│ │ - Signatures │ │ - Health Check │ │ - Broadcasting │ └─────────────────┘…

AIFlowML/cursor_rules · 0 tokens

solana_core_architecture

┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐ │ Entry Point │ │ Instruction │ │ Account │ │ lib.rs │───▶│ Processing │───▶│ Validation │ │ │ │ │ │ │ │ - entrypoint! │ │ - Route dispatch │ │ - Owner checks │ │ - processinst │ │ - Deserialize │ │ - Data validate │.

AIFlowML/cursor_rules · 4 tokens

stacks-development

Guidelines for Stacks blockchain development.

Mcsavvy/stacks-next-template-chainhooks-with-db · 7 tokens