Agent Skills
› mtarcure/claude-vibe-squad
› dimensional-analysis-check
dimensional-analysis-check
GitHub用于在代码审查中检查数值单位的维度一致性,覆盖算术、API边界及存储转换中的单位、精度和范围错误。
触发场景
涉及数值单位或精度的代码审查
跨系统边界的数值传递检查
安装
npx skills add mtarcure/claude-vibe-squad --skill dimensional-analysis-check -g -y
SKILL.md
Frontmatter
{
"name": "dimensional-analysis-check",
"audience": "specialist",
"description": "Use when numeric values cross arithmetic, API, storage, or time boundaries and a unit, scale, precision, rounding, signedness, or range mismatch could make the result wrong."
}
Dimensional Analysis Check
Catch unit, scale, base, and precision errors by checking that every quantity's dimensions agree across an expression, an API boundary, and a storage round-trip.
Steps
- Inventory every numeric quantity the change touches and annotate each with its unit and scale: seconds vs milliseconds, bytes vs KiB, basis points vs percent vs fraction, token decimals, wei vs ether.
- Check each arithmetic expression for dimensional consistency — added terms must share a unit, and a ratio's unit must be what the consumer expects.
- Check every boundary crossing: function parameters, JSON fields, database columns, environment variables, and RPC payloads are where units silently change identity.
- Verify conversion factors against the authoritative definition rather than an inline literal, and flag every magic constant that encodes a unit conversion.
- Check precision and rounding: integer division truncation, float accumulation in loops, and fixed-point scaling applied twice or not at all.
- Check signedness and range: values that can go negative, counters that can wrap, and durations that can exceed the field's width.
- Check time explicitly — epoch vs monotonic, UTC vs local, inclusive vs exclusive interval bounds — as it is the most common dimensional defect.
- Where a unit is only documented in a name, treat the name as an assertion to verify, not as evidence.
Acceptance
- Every quantity in the reviewed change has a stated unit and scale.
- Each expression and each boundary crossing is dimensionally consistent, or the mismatch is reported.
- Conversion constants are traced to an authoritative definition.
- Rounding, truncation, overflow, and sign behavior are checked at the extremes, not just at typical values.
- Time values state their epoch, zone, and interval bound convention.
版本历史
- d5262e2 当前 2026-09-11 11:16


