Goal: safe, expressive Swift that models intent with the type system.
Use for:
- new Swift code for apps, libraries, or tools
- reviewing optionals, value semantics, and concurrency
- modernizing callback-heavy or force-unwrapped code
Workflow:
- Prefer structs and enums; reach for classes when identity matters.
- Handle optionals with if/guard let; avoid force unwraps.
- Model variants with enums and associated values.
- Use async/await and actors for concurrency safety.
- Express errors with throws and typed Error values.
- Verify with XCTest and the compiler's warnings.
Idioms:
- guard for early exit and unwrapping
- value types for predictable copy semantics
- protocols with extensions for shared behavior
- Result and throws over completion-handler error codes
Rules:
- avoid force unwrap (!) outside proven invariants
- prefer value types; use reference types intentionally
- isolate mutable state with actors
- keep optionals meaningful, not pervasive