swift-best-practices

Installation
SKILL.md

Swift Best Practices

Priority: P0 (CRITICAL)

Implementation Guidelines

Control Flow (Guard over If)

  • Guard for Early Exit: Use guard let over nested if statements for better readability and to unwrap optionals early.
  • Nested Checks: Use guard for precondition checks at top of function to reduce nested depth.
  • Switch Exhaustiveness: Always handle all cases; use @unknown default for freezing enums (enums from frameworks).
  • if-case: Use if case .success(let value) = result for simple enum pattern matching.

Value Types & Immutability

  • Prefer Structs: Default to struct for value semantics and thread safety. Use class only when reference identity or inheritance required.
  • Immutability: Always default to let for all properties and constants. Use var only when change required.
  • Modifiers: Use final for all classes that not intended to subclassed to improve performance (static dispatch).
  • Static Dispatch: Favor methods in structs and final classes.
Installs
1
GitHub Stars
561
First Seen
Jul 23, 2026
swift-best-practices — hoangnguyen0403/agent-skills-standard