About dinero-best-practices
dinero-best-practices is a guidance skill for developers using Dinero.js to create, calculate, and format monetary values safely. Its prioritized rules cover object creation, arithmetic, precision, and imports in JavaScript and TypeScript.
Key features
- 01Create amounts in minor currency units
- 02Use safe monetary arithmetic patterns
- 03Choose number or bigint calculators
- 04Handle precision and cryptocurrency values
- 05Import functions for tree-shaking
Use cases
- 01Convert user or API inputs into money objects
- 02Split totals or calculate percentages
- 03Process amounts beyond safe integer limits
- 04Select matching bigint currency imports
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ dinerojs/ skills --skill dinero-best-practicesAfter installing, type/dinero-best-practicesin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
rules/_sections.mdarithmetic-allocate-not-divide.mdarithmetic-immutability.mdarithmetic-percentages.mdarithmetic-scaled-amounts.mdcreation-from-floats.mdcreation-minor-units.mdcreation-zero-exponent.mdimports-bigint-currencies.mdimports-tree-shaking.mdprecision-bigint.mdprecision-crypto.mdprecision-trim-scale.mdDetails
From the project READMEDinero.js Best Practices
Core rules for working with Dinero.js, the JavaScript/TypeScript library for creating, calculating, and formatting money safely. Contains rules across 4 categories, prioritized by impact.
When to Apply
Reference these guidelines when:
- Creating Dinero objects from user input, API responses, or database values
- Performing arithmetic on monetary values (adding, splitting, multiplying)
- Choosing between
numberandbigintcalculators - Importing from
dinero.js,dinero.js/currencies, ordinero.js/bigint - Working with prices, costs, taxes, or any financial calculation
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Object Creation | CRITICAL | creation- |
| 2 | Arithmetic | CRITICAL | arithmetic- |
| 3 | Precision | HIGH | precision- |
| 4 | Imports | MEDIUM | imports- |
Quick Reference
1. Object Creation (CRITICAL)
creation-minor-units- Always pass amounts as integers in minor currency unitscreation-from-floats- Use a helper to convert float inputs to minor unitscreation-zero-exponent- Currencies with exponent 0 (e.g., JPY) take major units directly
2. Arithmetic (CRITICAL)
arithmetic-immutability- All operations return new objects; capture the return valuearithmetic-allocate-not-divide- Useallocatefor splitting money, not manual divisionarithmetic-scaled-amounts- Never multiply by a raw decimal; use scaled amountsarithmetic-percentages- Calculate percentages withallocateor scaledmultiply
3. Precision (HIGH)
precision-bigint- Usedinero.js/bigintfor amounts exceedingNumber.MAX_SAFE_INTEGERprecision-crypto- Cryptocurrencies require bigint due to high exponentsprecision-trim-scale- UsetrimScaleto remove trailing zeros after chained operations
4. Imports (MEDIUM)
imports-tree-shaking- Import only what you use; standalone functions enable tree-shakingimports-bigint-currencies- Match calculator type: usedinero.js/bigint/currencieswithdinero.js/bigint
How to Use
Read individual rule files for detailed explanations and code examples:
rules/creation-minor-units.md
rules/arithmetic-allocate-not-divide.md
Each rule file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and references
Comments
Markdown supported