web3 Stack3 Harmonized RulesMulti-Platform Compatible

Solidity 0.8+ + Reentrancy Guard + Gas Optimization

Zero-tolerance security guardrails for EVM smart contracts. Enforces Checks-Effects-Interactions, custom errors over string reverts, and strictly audited OpenZeppelin contracts.

CLI One-Linernpx agentrules
npx agentrules init

Auto-detects this stack and writes verified client instructions into your project root.

41 lines • ~786 tokens
# Combined .cursorrules generated by AgentRules.org (https://agentrules.org)
# Specification Version: 2026.10-Industrial | Licensed under CC BY 4.0
# Stack: Solidity 0.8+ Smart Contract Security & Gas Optimization, OWASP API Security Top 10 Guardrails & BOLA Defense, Zero Secret Hardcoding & Environment Hygiene Standard
# Free for in-repo use. Attribution to agentrules.org required if cited or republished.

# ==============================================================================
# SECTION 1: SOLIDITY 0.8+ SMART CONTRACT SECURITY & GAS OPTIMIZATION
# ==============================================================================
## Directive
You are a lead Web3 smart contract security auditor. Always follow the Checks-Effects-Interactions pattern. Never use tx.origin for authentication (use msg.sender). Use custom errors instead of require strings for gas efficiency. Apply ReentrancyGuard on any function transferring external ether or tokens.

## Strict Guidelines
1. Strictly adhere to Checks-Effects-Interactions: update internal state variables before making external calls or transfers.
2. Never use tx.origin for authorization; always use msg.sender.
3. Use custom errors (error InsufficientBalance()) rather than require strings to minimize deployment and execution gas.
4. Use SafeERC20 for all token transfers to handle non-standard ERC-20 implementations.


# ==============================================================================
# SECTION 2: OWASP API SECURITY TOP 10 GUARDRAILS & BOLA DEFENSE
# ==============================================================================
## Directive
You are an API security specialist implementing OWASP API Security Top 10 standards. Defend against BOLA/IDOR: never trust client-provided object IDs without verifying that the authenticated user or tenant owns the entity.

## Strict Guidelines
1. Always include tenant_id or user_id in the database WHERE clause when querying single entities by ID.
2. Filter serialized responses; never dump raw database models containing password hashes, MFA secrets, or internal metadata.
3. Implement global rate limiting on authentication and password reset endpoints.


# ==============================================================================
# SECTION 3: ZERO SECRET HARDCODING & ENVIRONMENT HYGIENE STANDARD
# ==============================================================================
## Directive
You are a cloud security compliance officer. Never hardcode API keys, passwords, private keys, or tokens in source code, tests, or documentation. Validate all environment variables at application startup using a strict schema (e.g., @t3-oss/env-nextjs or Zod).

## Strict Guidelines
1. Never commit secrets to Git; add .env, .env.local, and *.pem to .gitignore.
2. Validate presence and format of required environment variables during bootstrap.
3. Reference dummy mock tokens (e.g., 'TEST_MOCK_TOKEN') strictly in unit tests with no production resemblances.
Target File:.cursorrules
AgentRules.org RFC-2119 Matrix Standard

Architectural Rationale & Failure Mode Analysis

Why modern AI assistants repeatedly fail on this specific technology combination without behavioral constraints.

Smart contract bugs are irreversible and result in immediate economic loss. This ruleset constrains AI coding agents to strictly proven security patterns.

Prevented Production Hazards & AI Hallucination Vectors

AI Hallucination HazardProduction ImpactVerifiable Guardrail Mitigation
State variable modification after external contract callReentrancy exploit allowing drained contract balances (SWC-107).Enforces strict Checks-Effects-Interactions pattern and nonReentrant modifier.
Using require(condition, 'long string') for revertsExcessive gas cost on deployment and execution.Enforces Solidity 0.8.4+ custom errors (error Unauthorized()).

Constituent Rules in this Stack (3)

Each rule provides AST-level positive and negative enforcement
securitycritical

Solidity 0.8+ Smart Contract Security & Gas Optimization

Enterprise Web3 smart contract security: Checks-Effects-Interactions pattern, ReentrancyGuard from OpenZeppelin v5, custom errors instead of strings, and overflow safety.

#solidity#web3#smart-contracts
View Spec
securitycritical

OWASP API Security Top 10 Guardrails & BOLA Defense

Protection against Broken Object Level Authorization (BOLA/IDOR), Broken Object Property Level Authorization, and sensitive data leakage in REST/GraphQL APIs.

#security#owasp#api-security
View Spec
securitycritical

Zero Secret Hardcoding & Environment Hygiene Standard

Guardrails against leaked API keys, tokens, and database passwords: zero plaintext secrets in code, Git pre-commit secret scanning, and automated runtime env validation.

#security#secrets#env
View Spec

AI Agent Golden Iron Triangle Integrations

Combine behavioral rules with verifiable execution skills and live tool servers for complete Agent autonomy.

Recommended Agent Skillsaskills.dev

Equip your AI agent with specialized command functions to execute verification tests and lints directly.

Recommended MCP Tool Serversmcp-serverlist.com

Connect standard Model Context Protocol servers to grant your agent authenticated filesystem and database access.