cross-contract-statelisted
Install: claude install-skill iktok90-design/ai-smart-contract-auditor
# Cross-contract state consistency detection
## When this applies
Trigger on any of:
- A value (price, total supply, share rate, debt) lives in contract A but is read by B
- Cached/mirrored state (`cachedRate`, `lastTotalAssets`) that must be refreshed
- Multi-contract operations that mutate several contracts non-atomically
- Modules/plugins/hooks that read core state mid-update (read-during-callback)
- Proxy + implementation, or vault + strategy, or controller + market splits
- Accounting assuming "A and B are always in sync"
## Detection patterns
### Stale read of another contract's mid-update state (HIGH)
```solidity
// Vault.deposit() transfers to Strategy, then:
uint256 tvl = strategy.totalAssets(); // ← strategy hasn't accounted the deposit yet
shares = amount * totalSupply / tvl; // wrong denominator
```
**Signal:** B reads A while A's update is incomplete (or vice versa). Share/price math uses a denominator that's about to change, letting an attacker mint mispriced shares. This is the read-only-reentrancy family generalized to ordinary call ordering.
### Cached value drift (HIGH)
```solidity
uint256 public cachedPrice; // updated by poke()
function valueOf(uint256 amt) external view returns (uint256) {
return amt * cachedPrice / 1e18; // ← may be hours stale
}
```
**Signal:** a mirrored value with no freshness guarantee or no atomic refresh-before-use. Trades/loans price off a cache that diverged from the source contract.
### Non-atomic mu