Agent skill · software engineering · dpearson2699

swift-formatstyle

Formats and parses locale-aware numbers, decimals, currencies, percentages, dates, durations, measurements, names, lists, byte counts, and URLs with Foundation FormatStyle and ParseableFormatStyle. Use when replacing legacy Formatter subclasses, designing reusable format APIs, using SwiftUI Text(_:format:), correcting availability, or testing user-facing formatted output across locales.

Why this skill is useful

Provides specific implementation patterns and best practices for using FormatStyle APIs in Swift, which the AI wouldn't reliably generate on its own.

What it needs

About 4k tokens when loaded. Last updated 2026-07-31. 973 stars on the source repository.

What this skill does

Swift FormatStyle Use Foundation's type-safe FormatStyle APIs for user-facing display and ParseableFormatStyle when the same convention must accept input. Route String Catalogs, plurals, localized copy, bundles, and RTL layout to ios-localization; formatting still requires locale review even when no text is translated. Contents Workflow Quick Reference Selection and Availability Parsing SwiftUI Integration Custom FormatStyle Common Mistakes Review Checklist References Workflow 1. Identify the value's semantic type and whether output is display-only or must round-trip through parsing. 2. Select the narrowest built-in style and keep the user's current locale unless a wire format explicitly requires another locale. 3. Render the exact UI with representative locales such as enUS, deDE, arSA, and jaJP. 4. Check separators, numbering systems, calendars, currency and unit conventions, text direction, and layout. 5. If output or parsing fails, fix the style or surrounding copy, restore the input fixture, and rerun the same locale matrix. Load FormatStyle Recipes when implementation needs concrete modifiers, date intervals, relative dates, duration patterns, measurements, names, lists, byte counts, or URL component controls. Quick Reference Value Default style Important constraint --- --- --- Int, Double .number Configure precision, rounding, grouping, notation, or sign only as required. Decimal .number, .percent, .currency(code:) Prefer for exact decimal display and parsing. Currency .currency(code:) Pass an ISO 4217 code; never hardcode a symbol. Percent .percent Confirm whether the input is a fraction (0.85) or whole percent (85). Date .dateTime, .relative, .interval Relative output should usually stand alone, not be embedded in a sentence. Duration .time(pattern:), .units(allowed:width:) Requires iOS 16+; choose compact clock output versus labeled units. Measurement .measurement(width:usage:) usage: controls locale-aware conversion policy. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills dpearson2699/swift-formatstyle

View the source on GitHub

Browse the @skills marketplace