swift-format-style
This skill guides you through adopting Swift's modern FormatStyle APIs for formatting values across numbers, dates, durations, measurements, and other types. It identifies legacy patterns like DateFormatter and C-style String(format:) calls, then shows you how to replace them with contemporary .formatted() methods and FormatStyle configurations. Perfect for modernizing iOS 15+ codebases.
swift-format-style teaches you to use modern FormatStyle APIs instead of legacy Formatter subclasses for all value formatting needs.
AI-generated summary based on this skill's SKILL.md
Decision gist · record as of 2026-04-16
swift-format-style teaches you to use modern FormatStyle APIs instead of legacy Formatter subclasses for all value formatting needs. This skill guides you through adopting Swift's modern FormatStyle APIs for formatting values across numbers, dates, durations, measurements, and other types. It identifies legacy patterns like DateFormatter and C-style String(format:) calls, then shows you how to replace them with contemporary .formatted() methods and FormatStyle configurations. Perfect for modernizing iOS 15+ codebases.
Use it when
- swift-format-style covers locale-aware currency formatting through FormatStyle.
- swift-format-style shows how to replace C-style String(format:) calls with modern .formatted() syntax.
Verify before relying
Read SKILL.md below before installing (8 files). Open directory: indexed for reading, not audited.
Install
n0an/Swift-FormatStyle-Agent-Skill/swift-format-style
Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.
Frequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I use FormatStyle in Swift to replace legacy formatters?
swift-format-style teaches you to adopt modern FormatStyle APIs instead of legacy Formatter subclasses. Replace DateFormatter, NumberFormatter, and similar classes with .formatted() methods on your values. For example, use `date.formatted(.dateTime.year().month().day())` instead of instantiating DateFormatter. FormatStyle is type-safe, Codable, and Hashable—making it ideal for iOS 15+ apps.
What are the best practices for swift currency formatting?
swift-format-style covers locale-aware currency formatting through FormatStyle. Use `.formatted(.currency(code: "USD"))` on Decimal or Double values to get proper symbol, grouping, and decimal placement. FormatStyle automatically respects the user's locale settings, eliminating manual currency symbol handling. This approach is safer and more maintainable than building format strings by hand.
How do I migrate from C-style String(format:) to .formatted() methods?
swift-format-style shows how to replace C-style String(format:) calls with modern .formatted() syntax. Instead of `String(format: "%.2f", value)`, use `value.formatted(.number.precision(.fractionLength(2)))`. The .formatted() API is type-checked at compile time, supports SwiftUI Text views natively, and eliminates format-string bugs. This skill guides you through common migration patterns.
Can swift-format-style help with FormatStyle date time formatting?
Yes. swift-format-style provides comprehensive guidance on date and time formatting with FormatStyle. Use `.formatted(.dateTime.year().month().day().hour().minute())` to customize output, or choose presets like `.dateTime.abbreviated`. FormatStyle handles locale-aware formatting automatically, replacing DateFormatter entirely for most use cases on iOS 15+.
How do I integrate FormatStyle with SwiftUI Text views properly?
swift-format-style explains how to use the `format:` parameter in SwiftUI Text views. Pass a FormatStyle directly: `Text(date, format: .dateTime.year().month().day())`. This approach is more efficient than calling .formatted() separately and keeps formatting logic declarative within your view hierarchy.
What does swift-format-style cover for modern number formatting?
swift-format-style guides you through modern number formatting with FormatStyle, including integers, decimals, percentages, and byte counts. Use `.formatted(.number.precision(.fractionLength(2)))` for decimals or `.formatted(.byteCount(style: .file))` for file sizes. These APIs replace NumberFormatter and provide compile-time safety with automatic locale adaptation.
SKILL.md
Rendered from the published skill. Quoted content, verbatim.
Write and review Swift code that formats values for display, ensuring modern FormatStyle APIs are used instead of legacy Formatter subclasses or C-style formatting.
Review process:
- Check for legacy formatting patterns and replace with modern FormatStyle equivalents using
references/anti-patterns.md. - Validate number, percent, and currency formatting using
references/numeric-styles.md. - Validate date and time formatting using
references/date-styles.md. - Validate duration formatting using
references/duration-styles.md. - Validate measurement, list, person name, byte count, and URL formatting using
references/other-styles.md. - Check SwiftUI Text views for proper FormatStyle integration using
references/swiftui.md.
If doing partial work, load only the relevant reference files.
Core Instructions
- Target iOS
(truncated - see the full file via the links below)
File tree — 8 files
swift-format-style/SKILL.md
swift-format-style/agents/openai.yaml
swift-format-style/references/anti-patterns.md
swift-format-style/references/date-styles.md
swift-format-style/references/duration-styles.md
swift-format-style/references/numeric-styles.md
swift-format-style/references/other-styles.md
swift-format-style/references/swiftui.md
Let your AI agent find skills like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.
wish › “Learn modern FormatStyle APIs to replace legacy Formatter subclasses”
Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →
Related skills
Swift Language covers contemporary syntax and idioms for core Swift development, excluding concurrency and SwiftUI. Learn if/switch expressions, typed throws, result builders, property wrappers, opaque versus existential types, guard patterns, the Never type, regex builders, Codable techniques, modern collection methods, FormatStyle basics, and string interpolation. Routes specialized topics like deep decoding, formatting, API naming, concurrency, and SwiftUI state to dedicated skills.
Master localization for iOS and macOS using String Catalogs, modern string types, and compile-time-safe generated symbols. Learn to handle pluralization, format dates and numbers for different locales, and implement right-to-left layout for languages like Arabic and Hebrew.
Localization Setup generates the foundation for supporting multiple languages in iOS and macOS applications. It guides you through creating String Catalogs, establishing type-safe string access patterns, and configuring pluralization and device-specific content. The skill handles migration from legacy approaches and includes SwiftUI preview helpers for testing across locales.
Upgrade outdated MATLAB code by swapping deprecated functions for their modern replacements across file I/O, deep learning, graphics, and UI domains. This skill pairs with static analysis to catch and fix anti-patterns like eval, growing arrays, and global variables that slow performance or pose security risks.
Modern C# for .NET helps you write idiomatic C# code that aligns with your repository's target framework and language-version constraints. It guides feature selection across C# versions, handles compatibility decisions, and validates that new syntax is actually supported by your project's configuration.
Swift is a powerful, modern programming language designed for building iOS, macOS, and other Apple platform applications. This skill covers core language concepts, syntax patterns, and contemporary best practices to help you write efficient, type-safe code. Whether you're starting fresh or deepening your expertise, you'll gain practical knowledge for real-world development scenarios.
More skills csharpier (MIT)