Claude Code skill for checking integer addition overflow in Rust
Use Rust checked_add to distinguish an ordinary sum from overflow and keep consistent error behavior for external data.
中文Install in Claude Code
Use Claude Code in the Miden Rust workspace to review arithmetic on externally supplied quantities. Prepare in-memory fixtures for the numeric boundary.
- Review `.claude/skills/checked-arithmetic/SKILL.md` and its requirements at the pinned GitHub commit.
- Create `.claude/skills/checked-arithmetic/` in your project and save the reviewed file as `.claude/skills/checked-arithmetic/SKILL.md`.
- Start Claude Code from that project's root, then select `/checked-arithmetic` in the slash menu.
Example task
Model a counter with a narrow integer. Add 5 and then separately try 6 against the same starting value, 250, mapping checked_add failure to the caller's error.
`u8::MAX` · `250_u8.checked_add(5)` · `250_u8.checked_add(6)`What to check
The addition of `5` returns `Some(255)`. The addition of `6` returns `None` and maps to `Overflow`.
Original SKILL.md on GitHub · Updated
Frequently asked question
Should I test this boundary in debug builds only?
Use explicit overflow handling across build modes, and cover both the valid edge and out-of-range case with unit tests.