dimensional-analysis

Annotates codebases with dimensional units and detects arithmetic bugs from unit mismatches.

Updated Mar 22, 2026
One-click install
npx skills add https://github.com/TECH-HY/SKILLS --skill dimensional-analysis-tech-hy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dimensional-analysis
Source: https://github.com/TECH-HY/SKILLS/tree/main/skills/dimensional-analysis
Command: npx skills add https://github.com/TECH-HY/SKILLS --skill dimensional-analysis-tech-hy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Codebases performing numeric computations with mixed units, decimal precisions, and scaling factors (common in DeFi protocols and financial code) are prone to subtle arithmetic bugs like unit mismatches, missing scaling, and precision loss that are hard to spot by manual review. ## Core Features & Use Cases - Dimensional Annotation: Adds unit and precision comments (e.g., D18{tok}, D27{UoA/tok}) to variables, function parameters, and formulas across the codebase. - Dimension Propagation: Traces dimensions through arithmetic, function calls, and assignments using formal dimensional algebra rules. - Bug Detection: Validates annotated code against a catalog of dimensional bug patterns such as oracle precision mismatches, wrong scaling direction, and adding incompatible dimensions. - Use Case: Audit a DeFi lending protocol by running the full pipeline to annotate all arithmetic files, propagate dimensions, and receive a structured report of confirmed dimensional bugs with severity ratings. ## Quick Start Ask the agent to perform a dimensional analysis on this repository to annotate units and find arithmetic bugs.

Frequently Asked Questions about dimensional-analysis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find unit mismatch bugs in a DeFi smart contract?

Run a dimensional analysis that annotates every numeric value with its unit and precision, propagates dimensions through arithmetic, then validates against known bug patterns like oracle precision mismatches and missing scaling factors. The pipeline reports confirmed findings with severity levels.

What is dimensional analysis for code auditing?

Dimensional analysis for code assigns semantic units (like {tok}, {share}, {UoA/tok}) and decimal scales (D18, D27) to numeric values, then applies algebra rules to verify that additions, multiplications, and function boundaries are dimensionally consistent.

Does dimensional analysis work for languages other than Solidity?

Yes. The dimensional vocabulary and algebra rules are language-agnostic and apply to Rust, TypeScript, Python, or any language performing fixed-point or scaled arithmetic. Only the comment syntax is adapted per language.

When should I not run a full dimensional analysis pipeline?

Skip it for codebases with no numeric arithmetic or unit conversions, pure integer counting logic like loop indices, or when you only need a quick spot-check of a single formula, which is faster to review directly.

What bug patterns does dimensional analysis detect?

It detects unit mismatches in price feeds, cross-contract dimension assumption errors, adding incompatible dimensions, overflow from wrong precision, missing or reversed scaling factors, inconsistent return dimensions, and time unit confusion in rate calculations.