---
name: format-price
description: Find every monetary price in the codebase and normalize it to one fixed standard format. Use when the user asks to standardize, unify, normalize, or "format" prices/currency across the code. Runs in two stages — a report first, then applies the fixes only after the user approves.
---

# Format Price

Scan the code for hard-coded prices and rewrite every one of them to a **single fixed
standard**. Always work in two stages: **report first, fix only after approval.**

## The standard

Unless the user overrides it for this run, normalize every price to:

- **Symbol:** `₪` placed immediately **before** the number (no space).
- **Decimals:** always exactly **2** digits after the decimal point.
- **Thousands separator:** comma `,` every three digits.
- **Decimal separator:** period `.`.

Examples of the target output:

| Found in code      | Normalized |
| ------------------ | ---------- |
| `19.9`             | `₪19.90`   |
| `1299`             | `₪1,299.00`|
| `12000.5`          | `₪12,000.50`|
| `"NIS 49"`         | `₪49.00`   |
| `49 ₪` / `49₪`     | `₪49.00`   |
| `$1,299.00`        | `₪1,299.00` (digits kept; only the format/symbol is normalized) |

If the project already has a price-format config (e.g. `.price-format.json`), read it
and let it override the standard above (`currency`, `symbol`, `decimals`, `thousands`).

## Stage 1 — Report (no edits)

1. Search the codebase for price-like values. Cast a wide net but stay precise:
   - Currency symbols / codes near numbers: `₪`, `$`, `€`, `£`, `NIS`, `ILS`, `USD`.
   - Common price identifiers: `price`, `amount`, `cost`, `total`, `subtotal`,
     `fee`, `discount`, `mrp`, `unitPrice`.
   - Prefer the dedicated search tools (Grep/Glob) over shell `grep`.
2. **Exclude false positives** — do not flag: version numbers, dates, ports, IDs,
   percentages, durations, dimensions, color/hex values, test fixtures the user
   asked to leave alone, or anything inside `node_modules`, build output, lockfiles,
   `.git`, or generated/minified files.
3. When a match is ambiguous (a bare number that *might* be a price), include it in a
   separate **"Needs confirmation"** list rather than assuming.
4. Present a clear report grouped by file, each line as:
   `path:line   <current>  →  <normalized>`
   End with a count: "Found N prices in M files (plus K needing confirmation)."
5. **Stop and ask the user to approve** before changing anything. Do not edit in this
   stage.

## Stage 2 — Fix (only after the user approves)

1. Apply the normalization with exact, surgical edits — change only the price token,
   never surrounding code, quotes, or types. Keep the value's type intact: a numeric
   literal stays a number unless it's clearly a display string.
2. Skip anything the user excluded during approval; honor any per-item corrections.
3. After editing, re-scan to confirm no non-standard prices remain, then summarize:
   "✏️ Updated N prices across M files" plus a short per-file breakdown.
4. If the repo is a git repo, remind the user they can review the diff before committing.

## Guardrails

- Two stages, always. Never edit during the report stage.
- Preserve meaning: normalize **format only**; never invent or convert exchange rates
  (e.g. `$10` becomes `₪10.00`, not a currency-converted amount) unless the user
  explicitly asks for conversion.
- When unsure whether a number is a price, ask — don't guess.
