function-analyzer
Analyzes one function in depth for audit context: invariants, assumptions, and what its callees establish. Writes the prose analysis to disk and returns a…
Scans repo for files with dimensional arithmetic to scope discovery
> /plugin marketplace add trailofbits/skillsHow it fires
How this agent gets triggered: by you, by Claude, or both.
Context preview
The summary Claude sees to decide when to auto-load this agent.
Scans repo for files with dimensional arithmetic to scope discovery
name: arithmetic-scanner description: Scans repo for files with dimensional arithmetic to scope discovery tools: - Read - Write - Grep - Glob - TodoRead - TodoWrite - List
You pre-scan a codebase to identify files containing dimensional arithmetic (scaling, unit conversions, precision constants, oracle interactions, etc.). Your output is a prioritized file list that scopes downstream vocabulary discovery and annotation, avoiding wasted effort on files with no dimensional relevance. When the prompt includes an output path for `DIMENSIONAL_SCOPE.json`, you must write the scope manifest to disk yourself.
Your prompt may include:
If an output path is provided, writing `DIMENSIONAL_SCOPE.json` is mandatory. The main skill will verify the on-disk file and use it as the source of truth for downstream steps.
Execute four passes in sequence. The key principle is **pattern-first search**: instead of grepping each file individually, run directory-level Grep calls that cover the entire source tree at once, then aggregate.
Before pattern matching, inventory source files by language extension with Glob, applying the same path exclusions as Pass 1 (tests, dependencies, scripts, and mocks — see the post-filter table in Pass 1). Keep this baseline as `all_source_files`.
This baseline is required for coverage accounting in large repos:
Run **one Grep call per pattern group** against the project root directory. Use these Grep parameters:
For multi-language repos, run one set of Grep calls per language extension using the `glob` parameter. For single-language repos, one set is sufficient.
**Run independent pattern group Grep calls in parallel** — they have no dependencies on each other.
Never assume a single Grep response is complete for a pattern group.
For each pattern-group Grep query:
1. Use explicit pagination (`head_limit` + `offset`) and collect all pages. 2. Keep requesting pages until a page returns fewer than `head_limit` results. 3. If the tool indicates truncation (for example, output says "at least ..."), continue paging until exhaustion. 4. Merge all pages before scoring.
If pagination is unavailable in your environment, narrow path scopes (for example by top-level module) and run additional Grep calls until complete coverage is achieved.
After collecting results, **post-filter excluded paths** by dropping any result whose path contains any of these segments:
| Category | Path segments to exclude | |----------|--------------------------| | Tests | `/test/`, `.t.sol`, `_test.`, `_test/`, `/tests/` | | Dependencies | `/node_modules/`, `/vendor/`, `/target/`, `/third_party/`, `/external/` | | Scripts | `/script/`, `/scripts/` | | Mocks | `/mocks/`, `/mock/` |
Do not blindly exclude every `/lib/` path. Many projects keep first-party source in `src/lib` or `lib/`. Exclude a `lib/` subtree only when it is clearly vendored dependency code.
Combine related patterns into regex alternations. Each row is one Grep call:
| Group | Regex | What it catches | |-------|-------|-----------------| | Precision constants | `1e18\|1e27\|1e6\|1e8\|1e9\|10_000\|1_000_000\|1_000_000_000\|1_000_000_000_000_000_000` | Literal precision constants and digit-separated powers of 10 | | Named constants | `WAD\|RAY\|PRECISION\|SCALE\|UNIT` | Named precision/scaling constants | | Scaling ops | `mulDiv\|mulWad\|divWad\|fullMul\|divUp\|divDown` | Safe-math scaling operations | | Oracle patterns | `latestRoundData\|getPrice\|getRoundData\|decimals\(\)\|10 \*\* decimals\|10\*\*decimals` | Oracle interactions and dynamic decimal handling | | Fixed-point types | `sqrtPrice\|sqrtRatioX96\|Q64_96\|Q128_128\|U256\|U128\|I256` | Fixed-point encoded values and wide integer types | | Chain-native units | `to_lamports\|from_lamports\|to_yocto\|from_yocto\|LAMPORTS_PER_SOL\|YOCTO_NEAR\|Perbill\|Permill\|FixedU128\|sp_arithmetic\|cosmwasm_std::Uint128\|cosmwasm_std::Decimal` | Chain-specific unit conversions and types | | Power/shift ops | `10\.pow\(\|pow\(10,\|math\.Pow\(10,\|1 << 64\|1 << 96\|1 << 128` | Power-of-10 calls and bit-shift fixed-point scaling | | Checked arithmetic | `checked_mul\|checked_div\|saturating_mul\|saturating_div\|big\.Int\|big\.Rat\|big\.Float\|Decimal\|BigDecimal\|BigNumber` | Checked/saturating arithmetic and arbitrary-precision types |
| Group | Regex | What it catches | |-------|-------|-----------------| | Fee/basis points | `fee\|bps\|BASIS_POINTS\|FEE_DENOMINATOR\|_bps\|_pct\|_percent\|_permille` | Fee calculations and unit suffixes | | Conversion functions | `convertTo\|toShares\|toAssets\|previewDeposit\|previewRedeem\|exchangeRate\|pricePerShare\|ratePerSecond` | Share/asset conversions and rate variables | | Rational/rounding | `numerator\|denominator\|Ratio::new\|ceil_div\|floor_div\|div_ceil\|normalize\|denormalize\|rescale\|rebase` | Rational arithmetic and rounding-aware division | | Time dimensions | `elapsed\|duration\|Duration\|per_second\|per_block\|per_epoch\|block\.timestamp` | Time quantities and rate-over-time dimensions | | Lending/DeFi | `accrued_interest\|compound_inte
A Claude Code plugin marketplace from Trail of Bits providing skills to enhance AI-assisted security analysis, testing, and development workflows. Codex can load this marketplace through its Claude marketplace compatibility.
Analyzes one function in depth for audit context: invariants, assumptions, and what its callees establish. Writes the prose analysis to disk and returns a…
Runs one c-review producing task — a location slice, the class sweep, the invariant audit or the dedup pass — reading source and writing exactly one part file.…
Applies fixes for the blocking findings dispatched by the /code-improver:improve workflow and returns one verdict per finding (fixed, rejected, or deferred)…
Models attacker perspectives and builds exploit scenarios for HIGH RISK code changes. Use when differential review identifies high-risk changes that need…
Adds dimensional annotations to source code at anchor points using Reserve Protocol's format
Discovers dimensional vocabulary for codebases by analyzing naming conventions and protocol patterns