Swift/SwiftUI Code Review Skill
Multi-layer review covering Swift 6+ concurrency, SwiftUI patterns, performance, security, architecture, and project-specific standards. Reads .claude/CLAUDE.md and outputs Critical/High/Medium/Low severity findings with file:line references and before/after code examples.
Workflow
Phase 1 — Context Gathering
- Try to load
.claude/CLAUDE.md.
- If missing: add a note to the report — *"No project standards file found — review uses default Apple guidelines"* — then continue.
- Obtain the changeset:
git diff,git diff --cached, orgh pr diff <n>.
- If diff is empty: stop and ask the user to specify files, a PR number, or a directory.
- Read each changed file plus key related files (imports, protocols it conforms to, corresponding test file if present).
Phase 2 — Analysis
For each category, load the reference file before writing findings:
- Swift Quality — concurrency, error handling, optionals, naming →
references/swift-quality-checklist.md; for concurrency findings also readskills/swift-concurrency/references/sendable.mdandactors.md - SwiftUI Patterns — property wrappers, state management, deprecated APIs →
references/swiftui-review-checklist.md; for wrapper selection readskills/swiftui-expert-skill/references/state-management.md - Performance — view body cost, ForEach identity, lazy loading, retain cycles →
references/performance-review.md - Security — force unwraps, Keychain vs UserDefaults, input validation, no secrets in logs →
references/security-checklist.md - Architecture — MVVM/MVI/TCA compliance, DI, testability →
references/architecture-patterns.md - Project Standards — validate against
.claude/CLAUDE.mdrules →references/custom-guidelines.md
For test file findings, consult skills/swift-testing/references/test-organization.md. For navigation/routing findings, consult skills/swiftui-ui-patterns/references/navigationstack.md.
Phase 3 — Report
Group findings by file → sort by severity within each file → write prioritized action items.
Severity: Critical (crash/data race/security hole) · High (anti-pattern/major arch violation) · Medium (quality/maintainability) · Low (style/suggestion).
Include one-sentence positive feedback where code is notably well-written. Never pad with generic praise.
Concrete Finding Examples
Force Unwrap → guard let (Critical)
LoginViewModel.swift:89 — Current:
let user = repository.currentUser!Finding: crashes if currentUser is nil (e.g., after sign-out race condition).
Fix:
guard let user = repository.currentUser else {
logger.error("currentUser nil — aborting login flow")
return
}Missing @MainActor on UI-bound ViewModel (High)
FeedViewModel.swift:12 — Current:
class FeedViewModel: ObservableObject {
@Published var posts: [Post] = []
func load() async {
posts = try? await api.fetchPosts() // ⚠️ mutates @Published off main thread
}
}Finding: @Published mutations must happen on the main actor in Swift 6 strict concurrency; this is a data race.
Fix:
@MainActor
@Observable
final class FeedViewModel {
var posts: [Post] = []
func load() async throws {
posts = try await api.fetchPosts() // safe: whole class is @MainActor-isolated
}
}Also migrate from ObservableObject/@Published to @Observable (iOS 17+) — see skills/swiftui-expert-skill/references/state-management.md.
Output Format
# Code Review — <scope>
## Summary
Files: N | Critical: N | High: N | Medium: N | Low: N
## <Filename.swift>
[Severity] **<Category>** (line N)
Current: `<problematic snippet>`
Fix: <explanation + corrected snippet>
## Positive Observations
...
## Prioritized Action Items
- [Must fix] ...
- [Should fix] ...
- [Consider] ...Full templates and severity classification: references/feedback-templates.md.
Companion Skills
Full reference tables (all files, when to consult each): references/companion-skills.md.
| Skill | Use for |
|---|---|
skills/swiftui-expert-skill/ | SwiftUI state, Liquid Glass, macOS patterns, accessibility |
skills/swift-concurrency/ | Actors, Sendable, Swift 6 migration, async/await |
skills/swift-testing/ | Swift Testing framework, test doubles, snapshots |
skills/swift-expert/ | Swift 6+ patterns, protocols, memory, SPM |
skills/swiftui-ui-patterns/ | Navigation, sheets, theming, async state, grids |
Platform Commands
# GitHub PR
gh pr diff <n>
gh pr view <n> --json files,comments
# GitLab MR
glab mr diff <n>
glab mr view <n> --json
# Local changes
git diff # unstaged
git diff --cached # staged
git diff HEAD~1 # last commit
git diff -- path/to/file.swiftReference Files
references/review-workflow.md— detailed process, diff parsing, git commandsreferences/feedback-templates.md— output templates, severity classificationreferences/swift-quality-checklist.md— Swift 6+, concurrency, optionals, namingreferences/swiftui-review-checklist.md— property wrappers, state, modern APIsreferences/performance-review.md— view optimization, ForEach, resource managementreferences/security-checklist.md— input validation, Keychain, network securityreferences/architecture-patterns.md— MVVM/MVI/TCA, DI, testabilityreferences/custom-guidelines.md— parsing.claude/CLAUDE.mdreferences/companion-skills.md— full companion skill tables