agentleFS
moasqmoasq/ios-dev-agent/.cursor/rules/currency.mdc

ios-dev-agent / rules

Cursor rule4 starsChanged 6 months agoMITView on GitHub

iOS development rule

The file

We split this currency.mdc into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use these rules for any iOS app that stores, calculates, or displays money.

    line 9
  2. Very specific:

    Use Decimal for monetary amounts.

    line 15
  3. Distinctive:

    Never concatenate currency symbols or force two decimal places.

    line 31
  4. Very specific:

    Default new entries to Locale.current.currency?.identifier when appropriate.

    line 55

≈ “Common” is an estimate: at least 1 in 5 of the 6,668 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
currency.mdc
---
description: iOS development rule
globs: "**/*.swift"
alwaysApply: true
---

# Currency Handling Rules

Use these rules for any iOS app that stores, calculates, or displays money.

## Non-Negotiables

### Store Money As Decimal

Use `Decimal` for monetary amounts. Never use `Double` or `Float` for stored money, model money, or totals.

```swift
// BANNED
let price: Double = 9.99

// CORRECT
let price: Decimal = Decimal(string: "9.99")!
```

### Pair Amount With Currency

An amount without a currency is incomplete. Keep `amount` and `currencyCode` together in models, DTOs, storage, and view state. Validate currency codes against `Locale.commonISOCurrencyCodes` or an app-owned wrapper.

### Format With Foundation

Never concatenate currency symbols or force two decimal places.

```swift
// BANNED
Text("$\(amount)")
String(format: "%.2f", amount)

// CORRECT
Text(amount.formatted(.currency(code: currencyCode)))
```

Foundation formatting handles symbol position, separators, minor-unit counts, right-to-left layout, and localized digits.

### Do Not Sum Across Currencies

Aggregate money per currency unless the product has an explicit, user-visible FX conversion feature. Cross-currency totals must show the conversion source, timestamp, and any unconverted currencies.

### User-Entered Prices

For prices entered by the user or extracted from OCR/imports:

- Store `Decimal`.
- Store ISO 4217 currency code.
- Mark uncertain or invalid parsed currencies for user review.
- Default new entries to `Locale.current.currency?.identifier` when appropriate.

## Banned Patterns

```swift
"$\(amount)"
"\(currency)\(amount)"
String(format: "$%.2f", amount)
Double(amountString)
totals.values.reduce(0, +) // when totals include mixed currencies
```

## Preferred Shape

```swift
struct Money: Hashable, Codable {
    var amount: Decimal
    var currencyCode: String
}
```

Expose a single formatting helper, such as `money.formatted(locale:)`, and use it from SwiftUI views instead of formatting inline.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.