diamond-eip2535listed
Install: claude install-skill iktok90-design/ai-smart-contract-auditor
# Diamond (EIP-2535) detection
## When this applies
- Any contract using EIP-2535 Diamond Standard
- Custom multi-facet upgradeable systems
- Frameworks: Nick Mudge's diamond-1, Diamond Industries' SoliState, custom diamond impls
## Detection patterns
### Function-selector collision (CRITICAL)
Two facets implementing the same 4-byte selector (e.g. `function foo()` and `function bar(uint256)` that hash to the same selector). Diamond routes to the last-cut facet, but during a cut, the *old* version may be reachable.
- Required: precompute selector mapping at deploy + verify uniqueness; rerun at every diamond-cut.
### Storage namespace collision (CRITICAL)
Two facets using the same `bytes32 STORAGE_POSITION` slot prefix.
```solidity
library LibA { bytes32 constant POS = keccak256("auditsentry.a"); }
library LibB { bytes32 constant POS = keccak256("auditsentry.a"); } // ← collision
```
Use unique namespace strings per facet.
### Init-vs-upgrade confusion (HIGH)
Diamond init runs once via `delegatecall` to an Init contract. Re-running init after diamond-cut → can re-initialize values or run dangerous code. See [[initialization]].
### `diamondCut` access control (CRITICAL)
```solidity
function diamondCut(FacetCut[] calldata cuts, address init, bytes calldata data) external {
// ← no owner check
}
```
Anyone can add/remove/replace facets.
### Removing facet without removing selectors (HIGH)
Facet contract removed from blockchain (selfdestructed pre-6780, or simply deau