Claude Code skill for replacing Rust magic numbers with associated constants
Give repeated domain values a name on the Rust type that owns their meaning, then use that constant consistently.
中文Install in Claude Code
Use a Miden Rust checkout and pick a helper type whose capacity is duplicated. Work within local Rust files for this exercise.
- Review `.claude/skills/masm-named-literals/SKILL.md` and its requirements at the pinned GitHub commit.
- Create `.claude/skills/masm-named-literals/` in your project and save the reviewed file as `.claude/skills/masm-named-literals/SKILL.md`.
- Start Claude Code from that project's root, then select `/masm-named-literals` in the slash menu.
Example task
Use a trail-record queue. Replace 24 in the capacity allocation and boundary check with one associated constant. Keep unrelated values with the same number separate.
`TrailQueue` · `TrailQueue::CAPACITY` · `24` rows · `25` rowsWhat to check
One definition gives `TrailQueue::CAPACITY` the value `24`. The queue admits `24` rows and rejects row `25` through the existing limit.
Original SKILL.md on GitHub · Updated
Frequently asked question
Why keep two constants that have the same number?
A constant name represents a domain meaning. Reuse a number when its meaning is shared and let separate limits evolve independently.