mcpField
D
dinero-best-practices

dinero-best-practices

github.com/dinerojsDevelopment2364 installsUpdated 35w ago
Repository

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

  1. 01Create amounts in minor currency units
  2. 02Use safe monetary arithmetic patterns
  3. 03Choose number or bigint calculators
  4. 04Handle precision and cryptocurrency values
  5. 05Import functions for tree-shaking

Use cases

  1. 01Convert user or API inputs into money objects
  2. 02Split totals or calculate percentages
  3. 03Process amounts beyond safe integer limits
  4. 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-practices

After installing, type/dinero-best-practicesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

rules/
_sections.md
arithmetic-allocate-not-divide.md
arithmetic-immutability.md
arithmetic-percentages.md
arithmetic-scaled-amounts.md
creation-from-floats.md
creation-minor-units.md
creation-zero-exponent.md
imports-bigint-currencies.md
imports-tree-shaking.md
precision-bigint.md
precision-crypto.md
precision-trim-scale.md

Details

From the project README

Dinero.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 number and bigint calculators
  • Importing from dinero.js, dinero.js/currencies, or dinero.js/bigint
  • Working with prices, costs, taxes, or any financial calculation

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Object CreationCRITICALcreation-
2ArithmeticCRITICALarithmetic-
3PrecisionHIGHprecision-
4ImportsMEDIUMimports-

Quick Reference

1. Object Creation (CRITICAL)
  • creation-minor-units - Always pass amounts as integers in minor currency units
  • creation-from-floats - Use a helper to convert float inputs to minor units
  • creation-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 value
  • arithmetic-allocate-not-divide - Use allocate for splitting money, not manual division
  • arithmetic-scaled-amounts - Never multiply by a raw decimal; use scaled amounts
  • arithmetic-percentages - Calculate percentages with allocate or scaled multiply
3. Precision (HIGH)
  • precision-bigint - Use dinero.js/bigint for amounts exceeding Number.MAX_SAFE_INTEGER
  • precision-crypto - Cryptocurrencies require bigint due to high exponents
  • precision-trim-scale - Use trimScale to remove trailing zeros after chained operations
4. Imports (MEDIUM)
  • imports-tree-shaking - Import only what you use; standalone functions enable tree-shaking
  • imports-bigint-currencies - Match calculator type: use dinero.js/bigint/currencies with dinero.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