skills/advanced/context-detection/SKILL.md
Automatically identify the type of protocol being audited to load appropriate checklists, templates, and vulnerability patterns without manual configuration. Use when starting any new audit to classify the protocol (DeFi lending, AMM, bridge, governance, etc.) and surface the most relevant checks.
npx skillsauth add 0x-shashi/web3-audit-skills skills/advanced/context-detectionInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Automatically identify the type of protocol being audited to load appropriate checklists, templates, and vulnerability patterns without manual configuration.
Signals:
- Functions: deposit, withdraw, borrow, repay, liquidate
- State: collateralFactor, borrowRate, totalBorrows, totalReserves
- Imports: InterestRateModel, PriceOracle
- Patterns: health factor calculations, LTV ratios
→ Load: lending-template, defi-lending-checklist, oracle-chains
Signals:
- Functions: swap, addLiquidity, removeLiquidity, getAmountOut
- State: reserve0, reserve1, totalLiquidity, fee
- Imports: IUniswapV2Pair, IUniswapV3Pool
- Patterns: constant product (x*y=k), concentrated liquidity, tick math
→ Load: amm-dex-template, dex-amm-checklist, flash-loan-chains
Signals:
- Functions: sendMessage, receiveMessage, relayMessage, verifyProof
- State: nonce, messageHash, guardians, threshold
- Imports: MessageVerifier, CrossChainMessenger
- Patterns: lock-mint-burn-unlock, validator signatures
→ Load: bridge-template, bridge-checklist, bridge-chains
Signals:
- Functions: propose, vote, execute, queue, cancel
- State: proposals, votingPower, quorum, timelock
- Imports: GovernorAlpha, GovernorBravo, TimelockController
- Patterns: proposal lifecycle, voting snapshots, delegation
→ Load: governance-checklist, governance-chains
Signals:
- Functions: stake, unstake, claim, getReward
- State: rewardRate, rewardPerToken, totalStaked
- Imports: StakingRewards, MasterChef
- Patterns: reward accumulation per share, lock periods
→ Load: staking-template, staking-checklist
Signals:
- Functions: mint, burn, tokenURI, onERC721Received
- State: tokenId, baseURI, maxSupply, royaltyInfo
- Imports: ERC721, ERC1155, VRF
- Patterns: merkle proof minting, reveal mechanics, randomness
→ Load: nft-marketplace-template, nft-gaming-checklist
Signals:
- Functions: deposit, withdraw, harvest, compound
- State: totalAssets, totalShares, strategy
- Imports: ERC4626, Strategy
- Patterns: share/asset conversion, yield strategies
→ Load: defi-patterns, staking-checklist
Many protocols combine multiple types (e.g., lending + staking + governance). When multiple types detected:
Context detection requires access to contract source code or verified ABI. The detection algorithm MUST have function signature databases loaded.
To verify detection accuracy, test against known protocol types:
# Validate detection signals
def test_lending_detection():
signals = detect_protocol("contracts/LendingPool.sol")
assert signals['type'] == 'lending'
assert signals['confidence'] > 0.85
print(f"Detection verified: {signals['type']} ({signals['confidence']:.2f})")
# Expected detection outcome for Uniswap V2 Pair
input: UniswapV2Pair.sol
expected:
type: amm-dex
confidence: 0.95
signals: [swap, addLiquidity, reserve0, reserve1]
templates: [amm-dex-template, dex-amm-checklist]
# Run detection test suite
python -m pytest tests/context_detection/ -v
development
Systematically hunt for every variant of a discovered vulnerability across the entire codebase. Use when a bug is found and all instances of the same root cause pattern must be identified, or when performing variant analysis during competitive audits on Code4rena or Sherlock.
testing
Use when the user wants to audit TON smart contracts for security vulnerabilities, scan FunC or Tact contracts for message chain replay, bounce handling, or gas issues, review TON DeFi protocols for actor-model concurrency flaws, or analyze asynchronous message passing security.
tools
Analyze ERC20/ERC721/ERC1155 token implementations for non-standard behavior, fee-on-transfer mechanics, rebasing logic, blacklists, pausability, and integration risks. Use when reviewing protocols that interact with external tokens or implementing token-related features.
testing
Use when the user wants to audit Sui Move smart contracts, scan Sui-specific patterns including object ownership, shared objects, or dynamic fields, review Sui DeFi protocols for object model security issues, or analyze Sui-specific transaction and consensus patterns.