mcpField
D
dinero-currency-patterns

dinero-currency-patterns

github.com/dinerojsDevelopment2345 installsUpdated 35w ago
Repository

About dinero-currency-patterns

A reference skill for developers using Dinero.js to handle currencies, covering type safety, conversion, storage, and payment-service mappings.

Key features

  1. 01Type-safe custom currencies
  2. 02Currency code validation
  3. 03Scaled-rate conversions
  4. 04Database storage patterns
  5. 05Payment-service mappings

Use cases

  1. 01Define custom currency types
  2. 02Convert using fractional exchange rates
  3. 03Store multi-currency amounts in databases
  4. 04Map Dinero objects to payment formats

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/dinerojs/skills --skill dinero-currency-patterns

After installing, type/dinero-currency-patternsin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

rules/
_sections.md
convert-reusable.md
convert-scaled-rates.md
payment-services.md
storage-database.md
storage-no-money-type.md
types-as-const.md
types-currency-mismatch.md
types-lookup-validation.md

Details

From the project README

Dinero.js Currency Patterns

Patterns for handling currencies with Dinero.js: type safety, conversions, custom currencies, database storage, and payment service integration.

When to Apply

Reference these guidelines when:

  • Converting between currencies with convert
  • Defining custom currencies (e.g., cryptocurrencies, loyalty points)
  • Looking up currencies dynamically from external input
  • Storing monetary values in a database
  • Integrating with payment services (Stripe, PayPal, Square)

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Type SafetyHIGHtypes-
2ConversionHIGHconvert-
3StorageHIGHstorage-
4Payment IntegrationMEDIUMpayment-

Quick Reference

1. Type Safety (HIGH)
  • types-as-const - Define custom currencies with as const satisfies for compile-time safety
  • types-currency-mismatch - TypeScript catches currency mismatches in operations at compile time
  • types-lookup-validation - Validate currency codes from external sources at runtime
2. Conversion (HIGH)
  • convert-scaled-rates - Use scaled amounts for fractional exchange rates, not floats
  • convert-reusable - Build reusable converter functions with higher-order patterns
3. Storage (HIGH)
  • storage-database - Store amount, currency code, and scale as separate columns
  • storage-no-money-type - Avoid PostgreSQL's money type for multi-currency applications
4. Payment Integration (MEDIUM)
  • payment-services - Map Dinero objects to payment service formats with dedicated helpers

How to Use

Read individual rule files for detailed explanations and code examples:

rules/types-as-const.md
rules/convert-scaled-rates.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