Skip to content

nghyane/luma / .agents/skills/numeric-casts

numeric-casts

Verified

Rules for numeric type conversions in Luma. Use when writing or reviewing code that casts between integer or float types, especially across different widths.

FileKindSize
SKILL.mdskill md950 B
---
name: numeric-casts
description: Rules for numeric type conversions in Luma. Use when writing or reviewing code that casts between integer or float types, especially across different widths.
---

# Numeric Casts in Luma

## Widening casts (smaller → larger)

Always use `From`/`Into`, never `as`:

```rust
// Correct
let x: u64 = u64::from(byte);
let x: u64 = byte.into();

// Wrong — triggers clippy::cast_lossless
let x = byte as u64;
```

`clippy::cast_lossless` enforces this automatically.

## Narrowing casts (larger → smaller)

Only use `as` when the bound is provably safe and documented:

```rust
// Acceptable — bound is clear from context
let idx = offset as usize; // offset is always < usize::MAX by construction

// Preferred when bound is not obvious
let idx = usize::try_from(offset).expect("offset fits usize");
```

If overflow is possible and silent truncation is wrong, use `try_from` and handle the error explicitly.
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall