SO

solidity-security

An expert guide to smart contract security, focusing on vulnerability prevention, secure patterns, and audit readiness.

Install

mkdir -p .claude/skills/solidity-security && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/130" && unzip -o skill.zip -d .claude/skills/solidity-security && rm skill.zip

Installs to .claude/skills/solidity-security

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Master smart contract security best practices to prevent common vulnerabilities and implement secure Solidity patterns. Use when writing smart contracts, auditing existing contracts, or implementing security measures for blockchain applications.
245 chars✓ has a “when” trigger
Intermediate

Key capabilities

  • Prevent reentrancy attacks
  • Manage integer overflow
  • Implement access control
  • Prepare contracts for professional audits
  • Optimize gas usage

How it works

The skill provides patterns for vulnerability prevention and includes a testing framework to verify security measures like reentrancy guards and access control.

Inputs & outputs

You give it
Smart contract source code
You get back
Security-audited contract code and test results

When to use solidity-security

  • Audit smart contract for vulnerabilities
  • Prevent reentrancy in a contract
  • Implement secure access control
  • Prepare contract for professional audit

About this skill

Solidity Security

Master smart contract security best practices, vulnerability prevention, and secure Solidity development patterns.

When to Use This Skill

  • Writing secure smart contracts
  • Auditing existing contracts for vulnerabilities
  • Implementing secure DeFi protocols
  • Preventing reentrancy, overflow, and access control issues
  • Optimizing gas usage while maintaining security
  • Preparing contracts for professional audits
  • Understanding common attack vectors

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Testing for Security

// Hardhat test example
const { expect } = require("chai");
const { ethers } = require("hardhat");

describe("Security Tests", function () {
  it("Should prevent reentrancy attack", async function () {
    const [attacker] = await ethers.getSigners();

    const VictimBank = await ethers.getContractFactory("SecureBank");
    const bank = await VictimBank.deploy();

    const Attacker = await ethers.getContractFactory("ReentrancyAttacker");
    const attackerContract = await Attacker.deploy(bank.address);

    // Deposit funds
    await bank.deposit({ value: ethers.utils.parseEther("10") });

    // Attempt reentrancy attack
    await expect(
      attackerContract.attack({ value: ethers.utils.parseEther("1") }),
    ).to.be.revertedWith("ReentrancyGuard: reentrant call");
  });

  it("Should prevent integer overflow", async function () {
    const Token = await ethers.getContractFactory("SecureToken");
    const token = await Token.deploy();

    // Attempt overflow
    await expect(token.transfer(attacker.address, ethers.constants.MaxUint256))
      .to.be.reverted;
  });

  it("Should enforce access control", async function () {
    const [owner, attacker] = await ethers.getSigners();

    const Contract = await ethers.getContractFactory("SecureContract");
    const contract = await Contract.deploy();

    // Attempt unauthorized withdrawal
    await expect(contract.connect(attacker).withdraw(100)).to.be.revertedWith(
      "Ownable: caller is not the owner",
    );
  });
});

Audit Preparation

contract WellDocumentedContract {
    /**
     * @title Well Documented Contract
     * @dev Example of proper documentation for audits
     * @notice This contract handles user deposits and withdrawals
     */

    /// @notice Mapping of user balances
    mapping(address => uint256) public balances;

    /**
     * @dev Deposits ETH into the contract
     * @notice Anyone can deposit funds
     */
    function deposit() public payable {
        require(msg.value > 0, "Must send ETH");
        balances[msg.sender] += msg.value;
    }

    /**
     * @dev Withdraws user's balance
     * @notice Follows CEI pattern to prevent reentrancy
     * @param amount Amount to withdraw in wei
     */
    function withdraw(uint256 amount) public {
        // CHECKS
        require(amount <= balances[msg.sender], "Insufficient balance");

        // EFFECTS
        balances[msg.sender] -= amount;

        // INTERACTIONS
        (bool success, ) = msg.sender.call{value: amount}("");
        require(success, "Transfer failed");
    }
}

When not to use it

  • When the contract logic does not involve financial transactions
  • When the project does not require professional security standards

Prerequisites

HardhatChaiethers.js

Limitations

  • Requires manual integration of patterns into existing code
  • Does not replace a full professional security audit

How it compares

Unlike manual auditing, this skill provides standardized patterns and automated test examples to verify security compliance.

Compared to similar skills

solidity-security side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
solidity-security (this skill)152moNo flagsIntermediate
supabase-rls-policy-generator119moNo flagsAdvanced
backend-security-coder244moNo flagsIntermediate
sqlmap-database-penetration-testing46moReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

More by wshobson

View all by wshobson

You might also like

supabase-rls-policy-generator

hopeoverture

This skill should be used when the user requests to generate, create, or add Row-Level Security (RLS) policies for Supabase databases in multi-tenant or role-based applications. It generates comprehensive RLS policies using auth.uid(), auth.jwt() claims, and role-based access patterns. Trigger terms include RLS, row level security, supabase security, generate policies, auth policies, multi-tenant security, role-based access, database security policies, supabase permissions, tenant isolation.

11109

backend-security-coder

sickn33

Expert in secure backend coding practices specializing in input validation, authentication, and API security. Use PROACTIVELY for backend security implementations or security code reviews.

2446

sqlmap-database-penetration-testing

davila7

This skill should be used when the user asks to "automate SQL injection testing," "enumerate database structure," "extract database credentials using sqlmap," "dump tables and columns from a vulnerable database," or "perform automated database penetration testing." It provides comprehensive guidance for using SQLMap to detect and exploit SQL injection vulnerabilities.

449

agent-security-manager

ruvnet

Agent skill for security-manager - invoke with $agent-security-manager

337

secure-workflow-guide

trailofbits

Guides through Trail of Bits' 5-step secure development workflow. Runs Slither scans, checks special features (upgradeability/ERC conformance/token integration), generates visual security diagrams, helps document security properties for fuzzing/verification, and reviews manual security areas.

331

ton-vulnerability-scanner

trailofbits

Scans TON (The Open Network) smart contracts for 3 critical vulnerabilities including integer-as-boolean misuse, fake Jetton contracts, and forward TON without gas checks. Use when auditing FunC contracts.

410

Search skills

Search the agent skills registry