Protocol Templates Skill
Purpose
Provide structured, protocol-type-specific audit templates that enumerate the exact checks, invariants, and attack vectors relevant to each protocol category. These templates are loaded based on context detection.
Available Templates
| Template |
Protocol Type |
Key Focus Areas |
| AMM/DEX |
Uniswap, Curve, Balancer-style |
Price manipulation, LP attacks, MEV |
| Bridge |
Cross-chain bridges |
Message verification, replay, accounting |
| Lending |
Aave, Compound-style |
Oracle, liquidation, interest rates |
| NFT Marketplace |
OpenSea, Blur-style |
Order validation, royalties, signatures |
| Staking |
Lido, RocketPool-style |
Reward distribution, withdrawal, delegation |
Template Structure
Each template follows a consistent format:
- Protocol Overview: What the protocol does
- Architecture Checklist: Structural checks
- Invariants: Mathematical properties that must hold
- Attack Vectors: Known exploits for this protocol type
- Critical Functions: Functions requiring deepest review
- Integration Risks: External dependency risks
- Economic Considerations: Game theory and incentive analysis
Usage
- Context detection identifies protocol type
- Appropriate template is loaded
- Auditor follows template checklist systematically
- Findings tagged with template category for standardized reporting
Prerequisites
Protocol templates require Context Detection for automatic loading. Manual template selection is also supported.
Validation
To verify template coverage, validate against known protocol types:
# Validate template completeness
required_sections = ["Overview", "Architecture Checklist", "Invariants", "Attack Vectors", "Critical Functions"]
for template in templates:
for section in required_sections:
assert section in template.sections, f"{template.name} missing {section}"
# Example template loading configuration
detected_type: amm-dex
confidence: 0.92
loaded_templates:
- amm-dex-template.md
- defi-patterns.md
checklist: dex-amm-checklist
# Test template file integrity
for f in *-template.md; do echo "Validating $f"; head -5 "$f"; done
Behavior Guidelines
- Template loading is required when context detection confidence exceeds 0.8
- Auditors MUST verify that all invariants in the template are tested
- Custom template sections may optionally be added for novel protocol designs
References
- Protocol Templates References - Template customization guides and architecture patterns
1---2name: protocol-templates3description: Structured, protocol-type-specific audit templates enumerating the exact checks, invariants, and attack vectors relevant to each protocol category. Use when auditing AMM/DEX, lending, bridge, governance, or vault protocols to load targeted checklists based on context detection results.4---56# Protocol Templates Skill78## Purpose9Provide structured, protocol-type-specific audit templates that enumerate the exact checks, invariants, and attack vectors relevant to each protocol category. These templates are loaded based on context detection.1011## Available Templates1213| Template | Protocol Type | Key Focus Areas |14|----------|--------------|-----------------|15| [AMM/DEX](amm-dex-template.md) | Uniswap, Curve, Balancer-style | Price manipulation, LP attacks, MEV |16| [Bridge](bridge-template.md) | Cross-chain bridges | Message verification, replay, accounting |17| [Lending](lending-template.md) | Aave, Compound-style | Oracle, liquidation, interest rates |18| [NFT Marketplace](nft-marketplace-template.md) | OpenSea, Blur-style | Order validation, royalties, signatures |19| [Staking](staking-template.md) | Lido, RocketPool-style | Reward distribution, withdrawal, delegation |2021## Template Structure22Each template follows a consistent format:231. **Protocol Overview**: What the protocol does242. **Architecture Checklist**: Structural checks253. **Invariants**: Mathematical properties that must hold264. **Attack Vectors**: Known exploits for this protocol type275. **Critical Functions**: Functions requiring deepest review286. **Integration Risks**: External dependency risks297. **Economic Considerations**: Game theory and incentive analysis3031## Usage321. Context detection identifies protocol type332. Appropriate template is loaded343. Auditor follows template checklist systematically354. Findings tagged with template category for standardized reporting3637## Prerequisites3839Protocol templates require [Context Detection](../context-detection/SKILL.md) for automatic loading. Manual template selection is also supported.4041## Validation4243To verify template coverage, validate against known protocol types:4445```python46# Validate template completeness47required_sections = ["Overview", "Architecture Checklist", "Invariants", "Attack Vectors", "Critical Functions"]48for template in templates:49 for section in required_sections:50 assert section in template.sections, f"{template.name} missing {section}"51```5253```yaml54# Example template loading configuration55detected_type: amm-dex56confidence: 0.9257loaded_templates:58 - amm-dex-template.md59 - defi-patterns.md60checklist: dex-amm-checklist61```6263```bash64# Test template file integrity65for f in *-template.md; do echo "Validating $f"; head -5 "$f"; done66```6768## Behavior Guidelines6970- Template loading is **required** when context detection confidence exceeds 0.871- Auditors MUST verify that all invariants in the template are tested72- Custom template sections may optionally be added for novel protocol designs7374## References7576- [Protocol Templates References](references/README.md) - Template customization guides and architecture patterns