# dimensional-analysis

Audits numeric code for unit confusion and decimal-scale errors, then adds dimensional comments. Use it when formulas or conversions need a unit-level review.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 4200 installs · ★ 7805
- Author: trailofbits
- License: CC-BY-SA-4.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/trailofbits/skills/tree/HEAD/plugins/dimensional-analysis/skills/dimensional-analysis/SKILL.md
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/dimensional-analysis

## What it does

The skill traces numeric calculations for incompatible units or scales. It can flag incorrect token decimals, WAD/RAY scale mistakes, prices with an unclear numerator or denominator, and missing scale adjustments after oracle calls.

It runs in `full-auto` mode through scanning, vocabulary discovery, annotation, and validation. The workflow writes `DIMENSIONAL_SCOPE.json` at the project root and reuses `DIMENSIONAL_UNITS.md` when present, otherwise it creates the vocabulary. Comments use notation such as `D18{tok}` and `{s}`.

Native agent dispatch and write access to an explicitly scoped target are required. It edits comments in files directly, so that is a reason to run it only where those changes are acceptable. The skill does not commit or publish the target.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill dimensional-analysis -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/dimensional-analysis/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/dimensional-analysis/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill dimensional-analysis -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/dimensional-analysis/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill dimensional-analysis -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/dimensional-analysis/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install trailofbits/skills dimensional-analysis
```

2. **Manually: put the files in place**
- File: `.github/skills/dimensional-analysis/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill dimensional-analysis -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/trailofbits/skills --path plugins/dimensional-analysis/skills/dimensional-analysis
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/dimensional-analysis/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill dimensional-analysis -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/trailofbits/skills/tree/HEAD/plugins/dimensional-analysis/skills/dimensional-analysis/SKILL.md

## When to use it
- detect additions of values from different tokens
- check WAD/RAY and other decimal scales
- find incorrect token decimals in calculations
- add unit comments to numeric values
- trace conversions after an oracle call

## Example prompts
- Run dimensional-analysis on the arithmetic in this repository and add unit comments.
- Audit these formulas for token decimal and WAD/RAY scale errors.
- Annotate the numeric calculations with dimensions and flag incompatible units.

## Similar
- [yield-analysis](https://affpapa.org/en/nevibecode/skills/yield-analysis.md) — skill · 426 installs
- [defi-protocol-templates](https://affpapa.org/en/nevibecode/skills/defi-protocol-templates.md) — skill · 10400 installs
- [defi-attack-patterns](https://affpapa.org/en/nevibecode/skills/defi-attack-patterns.md) — skill · 3600 installs
- [blockchain-developer](https://affpapa.org/en/nevibecode/skills/blockchain-developer.md) — skill · 1200 installs
- [pint-compute](https://affpapa.org/en/nevibecode/skills/pint-compute.md) — skill · 482 installs
- [binance-agentic-wallet](https://affpapa.org/en/nevibecode/skills/binance-agentic-wallet.md) — skill · 16700 installs

From the same set: [trailofbits/skills](https://affpapa.org/en/nevibecode/by/trailofbits/skills.md) — 77 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
