---
name: "solidity-reentrancy-guard-pattern"
description: "Protect smart contracts from reentrancy attacks using Checks-Effects-Interactions and guards."
metadata:
  author: "OpenZeppelin"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "prevent reentrancy attack solidity"
  - "use reentrancyguard openzeppelin"
  - "apply checks-effects-interactions"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Reentrancy Guard & Checks-Effects-Interactions Pattern

Implements defensive smart contract architecture: Checks-Effects-Interactions (CEI) state ordering, OpenZeppelin ReentrancyGuard nonReentrant modifiers, and safe external call isolation.

## When to Invoke
Invoke this skill whenever you need to:
- prevent reentrancy attack solidity
- use reentrancyguard openzeppelin
- apply checks-effects-interactions

## Execution SOP & Rules
1. Perform parameter checks and validations first (Checks).
2. Update internal balances and contract state variables second (Effects).
3. Perform external contract calls or ether transfers last (Interactions).
4. Apply nonReentrant modifier on sensitive external functions that interact with untrusted addresses.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
