Annotates codebases with dimensional analysis comments documenting units, dimensions, and decimal scaling. Use when someone asks to annotate units in a codebase, perform a dimensional analysis, or find vulnerabilities in a DeFi protocol, offchain code, or other blockchain-related codebase with arithmetic. Prevents dimensional mismatches and catches formula bugs early.
The dimensional-analysis skill orchestrates a comprehensive pipeline for annotating codebases with dimensional analysis comments that document units, dimensions, and decimal scaling factors. It prevents dimensional mismatches and catches formula bugs early by systematically analyzing numeric computations across mixed units, precisions, or scaling factors. This is particularly valuable for DeFi protocols, financial systems, and scientific codebases where arithmetic errors can lead to critical vulnerabilities or incorrect calculations.
The skill operates through a four-step workflow that delegates specialized tasks to subagents: repository scanning to identify arithmetic-heavy files, vocabulary discovery to extract dimensional units from the codebase, anchor annotation to mark key variables and functions with dimension comments, and propagation to ensure dimensional consistency throughout the call graph. The main skill context acts as a workflow controller, managing batching, persistence, retries, coverage gates, and final reporting. It guarantees complete coverage by tracking all in-scope files through each pipeline step and persisting state in manifest files like DIMENSIONAL_SCOPE.json and DIMENSIONAL_UNITS.md.
This skill is designed for security auditors, protocol developers, and engineers working with blockchain arithmetic, fixed-point math, or any codebase involving unit conversions and precision transformations. It's particularly useful when auditing DeFi protocols for arithmetic vulnerabilities, annotating financial codebases with unit documentation, or validating scientific computations where dimensional consistency is critical. The automated workflow handles large repositories systematically, ensuring no arithmetic file is missed during the analysis.
Use this skill when you need comprehensive dimensional analysis across an entire codebase, especially for DeFi protocols, financial systems, or codebases with mixed decimal precisions. It systematically covers all arithmetic files and catches unit mismatches that manual review might miss. For quick spot-checks of a single formula, reading the code directly is more efficient.
The skill works with any codebase performing numeric computations with mixed units, precisions, or scaling factors. This includes DeFi protocols, blockchain offchain code, financial applications, and scientific computations. It's not useful for codebases with no arithmetic operations or simple integer counting logic.
The skill tracks all in-scope files through a manifest system (DIMENSIONAL_SCOPE.json) and guarantees that every arithmetic file passes through all four pipeline steps: scanning, vocabulary discovery, annotation, and validation. A file is only considered covered when all three processing statuses (step2, step3, step4) are present. The workflow does not finish until all in-scope files are processed.
The skill generates DIMENSIONAL_SCOPE.json in the project root to track in-scope files and their processing status across all pipeline steps, and DIMENSIONAL_UNITS.md to persist the discovered dimensional vocabulary for reuse by later steps and future runs.
No, the skill runs in full-auto mode only and always executes the complete four-step pipeline in order: scanning → vocabulary discovery → annotation → validation. Any mode arguments provided by the caller are ignored to ensure comprehensive analysis and coverage guarantees.
Quick Setup:
.claude/skills/Repository
trailofbits/skills