AGENT SKILL

parse-locale-money-input

Use when accepting an amount typed by a user (a form field, a CSV, an SMS). Parses locale-specific separators into exact minor units without float, and rejects ambiguous input.

License 许可
MIT
最近更新
2026-11-15
Stars
★ 81
Forks
17

01 前言 Front Matter

name
parse-locale-money-input
description
Use when accepting an amount typed by a user (a form field, a CSV, an SMS). Parses locale-specific separators into exact minor units without float, and rejects ambiguous input.

02 资源文件 3

03 SKILL.md 正文

Parse locale money input

"1.234,56" (German) and "1,234.56" (US) are the same number written two ways, and "1.234" alone is ambiguous. Parse with an explicit locale into exact minor units; never float() a user string.

Procedure

  1. Require the currency alongside the number — parsing "1.234" without knowing EUR vs USD cannot decide whether it means 1.234 or 1234.
  2. Take a locale, or better a declared decimal separator, and map , and . explicitly rather than guessing.
  3. Strip the currency symbol and thousands separators by the locale's rules: US groups with , every 3 digits; FR/DE use spaces or .; Indian grouping is 1,00,000.
  4. Reject ambiguous forms: a string with two candidate separators where neither groups correctly ("1.234", "1,234"), or a lone separator with 1–2 trailing digits and no grouping.
  5. Convert to minor units with exact arithmetic: int(Decimal(cleaned).scaleb(exp)), never round(float(s) * 100).
  6. Validate the fraction length against the currency's exponent: "1.999" in USD has a third decimal that must be rejected or explicitly rounded per policy, not silently dropped.
  7. Handle negative forms: a leading sign, a trailing -, and accounting parentheses ("1.234,56").
  8. Return a Money {currency, amount_minor} or an error — never a bare number.
  9. Fuzz the parser with mixed-separator strings to confirm it raises rather than guessing.
  10. Normalise non-breaking and narrow spaces (\u00a0, \u202f) to a plain space before parsing.
  11. Round-trip each parse through the display format in the same locale as a test.

Pitfalls

  • float("1.234") yields 1.234 when the user meant 1234; the ambiguity is the bug, not the float.
  • parseFloat("1,234.56") stops at the comma and yields 1 — silent truncation.
  • Excel/LibreOffice CSV exports use the displayed locale format; importing with the wrong locale multiplies by 1000.
  • Unicode non-breaking spaces as thousands separators (fr-FR) survive a plain .strip() and break the number.
  • Accepting "1e6" or "+1_000" from a form field; restrict to digits, one separator and a sign.
  • Silently rounding a third decimal changes a legal amount; reject it or flag it.
  • A leading +, a currency prefix, and trailing whitespace can arrive together; strip known affixes in a defined order rather than strip()-ing everything.

Verification

python3 -c "from decimal import Decimal as D; print(int(D('1.234,56'.replace('.','').replace(',','.'))*100))"   # 123456
# assert parse('1,234.56','en_US') == parse('1.234,56','de_DE')

Report the locale/decimal separator assumed, the parsed minor-unit value, and any input rejected as ambiguous.

04 同仓库更多 Skills

jiayaoqijia
jiayaoqijia/cryptoskill

troves

Deposit and withdraw from Troves DeFi yield vault strategies on Starknet. View available strategies, check positions, and manage vault deposits. Use this skill when the user mentions Troves, vault, yield vault, DeFi vault, strategy, yield farming, vault deposit, vault withdraw, earning yield through vaults, passive yield strategies, or wants to deposit into or withdraw from a yield strategy — even if they don't say "Troves" explicitly.

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

trade

Swap tokens on Starknet via Fibrous DEX aggregator. Supports per-provider selection (avnu, ekubo, or auto to race all). Use this skill when the user wants to swap, exchange, trade, convert, buy, or sell one token for another on Starknet. Also use when the user asks about token prices, exchange rates, DEX routing, best swap route, or wants to check how much they would receive for a given amount — even if they don't explicitly say "swap".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

staking

Stake, unstake, claim, and compound rewards for STRK, WBTC, tBTC, SolvBTC, and LBTC on Starknet. View validators, pools, and staking positions. Use this skill when the user mentions staking, delegating, validators, staking pools, rewards, compounding, unstaking, earning yield, passive income on crypto, or wants to earn on their STRK or BTC tokens — even if they don't say "stake" explicitly.

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

send

Send STRK, ETH, or any ERC-20 token to a Starknet address. Supports simulation (dry-run) before execution. Use this skill when the user wants to send, transfer, pay, tip, or move tokens to another wallet address on Starknet. Also trigger when the user mentions sending funds to someone, making a payment, transferring assets, or moving crypto to a specific address — even if they just say "pay 10 STRK to 0x...".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

portfolio

View a comprehensive DeFi portfolio dashboard and optimize portfolio allocation via automated rebalancing. Use this skill when the user wants an overview, summary, dashboard, total value, net worth, portfolio rebalancing, target allocation, or wants to see all their DeFi positions across Starknet at once. Also trigger when the user asks "what do I have", "show me everything", "how much am I worth", "my positions", "my investments", "rebalance my portfolio", "I want 50% ETH", "optimize my holdings", or any request for a holistic view of their Starknet holdings — even if they don't explicitly say "portfolio".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

multi-swap

Execute multiple token swaps in a single Starknet transaction via Fibrous (default). Supports per-provider selection (avnu, ekubo, or auto to race all). Supports 2-3 swap pairs bundled into one multicall. Use this skill when the user wants to swap multiple token pairs at once, do batch swaps, execute several trades simultaneously, perform parallel swaps, or do bulk trading in one transaction. Also trigger when the user mentions "two swaps", "three swaps", "swap X and Y at the same time", or wants to convert multiple tokens in a single call.

★ 81