Skills wshobson agents

solidity-security

Use it when:
You're writing a smart contract, checking one for vulnerabilities, or preparing it for a professional audit.
It does:
Shows vulnerable and fixed Solidity for reentrancy, integer overflow, missing access control and front-running.
You get:
Contracts that follow checks-effects-interactions and pull payments, plus Hardhat tests that try the attacks.
Also covers:
An emergency stop, gas savings, documentation for auditors and a 15-item security checklist.

TL;DR

A security reference for Ethereum-style smart contracts. The SKILL.md itself shows Hardhat tests that attempt a reentrancy attack, an overflow and an unauthorized withdrawal and expect each to revert, and a contract documented for auditors whose withdrawal checks the balance, updates it, and only then sends the funds. A separate file holds the detail: each critical vulnerability as vulnerable code and its fix, with OpenZeppelin's ReentrancyGuard, Solidity 0.8's built-in overflow checks (SafeMath before it), owner-only and role-based access control, and a commit-reveal scheme against front-running; secure patterns such as checks-effects-interactions, pulling payments instead of pushing them, input validation and a circuit breaker to pause the contract; gas optimizations such as packed storage and calldata arguments; and a checklist that also covers delegatecall to untrusted contracts, tx.origin authentication, unchecked return values and hardcoded addresses.

Summarizes the skill at 4bde316.

npx skills add https://github.com/wshobson/agents --skill solidity-security
Total Downloads
15,800 on skills.sh, Nov 9, 2026
Repo stars
42,334 wshobson/agents
First seen
Jan 20, 2026 on skills.sh
Weekly Downloads
172
-14% over the 8 weeks to Nov 9
Weekly values
Week toInstalls
Sep 21201
Sep 28230
Oct 5281
Oct 12228
Oct 19196
Oct 26199
Nov 2184
Nov 9172
Category

Compliance, guardrails, skill vetting and browser fingerprinting.

Everything for building software: planning, coding, debugging, design, frameworks, cloud, agents and skills.

Type

Knowledge and rules the agent applies while it works: best practices, design principles, API references.

Effect

Adds no side effects of its own. It shapes how the agent thinks, writes or reviews. Guidelines and routers are always effect:none, even when the task they support edits code.

Needs

Instructions only. Works in any agent that supports skills.

Publisher

Everyone else. Unverified vendor claims default to community.

Topics
Stack

SKILL.md

From wshobson/agents at 4bde316. Checked daily, last changed Nov 6, 2026.

Frontmatter
name: solidity-security
description: 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.

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");
    }
}