# Swift

> Use when: write or review idiomatic Swift with value types, optionals, and safe concurrency.

- Skill: `kimtth/swift` (Agent Skill)
- Install (CLI): `npx skillmds@latest add kimtth/swift`
- Raw SKILL.md: https://api.skillmd.com/api/skills/kimtth/swift/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: kimtth (https://skillmd.com/u/kimtth)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/kimtth/swift

---


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:
1. Prefer structs and enums; reach for classes when identity matters.
2. Handle optionals with if/guard let; avoid force unwraps.
3. Model variants with enums and associated values.
4. Use async/await and actors for concurrency safety.
5. Express errors with throws and typed Error values.
6. 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

