What problem does it solve?
Many Swift codebases accumulate inconsistent patterns, fragile Codable handling, and manual looping or formatting that harm readability and correctness. This Skill helps apply modern Swift language features to core non-concurrency code so models, collections, and API layers are safer, clearer, and easier to review.
Core Features & Use Cases
- If/Switch Expressions & Guard Patterns: Replace mutation-heavy conditionals with expressive expressions and early-exit guards to keep happy paths left-aligned.
- Typed Throws & Never: Recommend typed throws for exhaustive handling and appropriate use of Never in generic contexts.
- Result Builders & Property Wrappers: Provide patterns for DSLs, composition, and encapsulated storage with projected values.
- Opaque vs Existential Types: Advise when to use some versus any for performance and type-safety tradeoffs.
- Codable Best Practices & Nested Containers: Canonical CodingKeys, safe decodeIfPresent with defaults, nested container flattening, and lossy array strategies.
- Regex Builders, Modern Collection APIs & FormatStyle: Suggest RegexBuilder usage, collection helpers (count(where:), compactMap, reduce(into:)), and .formatted() for dates, numbers, durations, and lists.
- Review Checklist: Provide a compact checklist for code reviews focusing on type choices, collection APIs, formatting, and Codable correctness.
- Use Case Example: Refactoring backend API models and serialization logic to be resilient across API changes while improving performance and testability.
Quick Start
Refactor this non-concurrent Swift module to apply Codable best practices, prefer some over any where possible, replace manual loops with modern collection APIs, and update date and number formatting to use FormatStyle.