# Smart Contract Security

> Automated auditing, reentrancy guards, and flashloan attack prevention.

- Skill: `j4flmao/smart-contract-security` (Agent Skill)
- Install (CLI): `npx skillmds@latest add j4flmao/smart-contract-security`
- Raw SKILL.md: https://api.skillmd.com/api/skills/j4flmao/smart-contract-security/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: j4flmao (https://skillmd.com/u/j4flmao)
- Updated: 2026-09-21
- Page: https://skillmd.com/skills/j4flmao/smart-contract-security

---


# Smart Contract Security

## Reentrancy Guards
Use the Checks-Effects-Interactions pattern and OpenZeppelin's `ReentrancyGuard`.

```solidity
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

contract Vault is ReentrancyGuard {
    mapping(address => uint) public balances;

    function withdraw() external nonReentrant {
        uint bal = balances[msg.sender];
        require(bal > 0, "No balance");
        balances[msg.sender] = 0; // Effect
        (bool success, ) = msg.sender.call{value: bal}(""); // Interaction
        require(success, "Transfer failed");
    }
}
```

## Flashloan Attack Prevention
Use decentralized oracles (Chainlink) or TWAP (Uniswap V3) to prevent price manipulation.

## Security Audit Workflow
```mermaid
%%{init: {"theme": "default", "flowchart": {"useMaxWidth": true}}}%%
flowchart TD
    A[Source Code] --> B[Static Analysis (Slither)]
    B --> C[Fuzzing (Echidna)]
    C --> D[Formal Verification]
    D --> E[Manual Code Review]
    E --> F[Audit Report]
```

