swift-code-reviewer-skill 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/CHANGELOG.md +43 -169
  2. package/README.md +43 -2
  3. package/SKILL.md +194 -711
  4. package/bin/install.js +1 -1
  5. package/package.json +2 -1
  6. package/references/agent-loop-feedback.md +148 -0
  7. package/references/companion-skills.md +70 -0
  8. package/references/spec-adherence.md +157 -0
  9. package/skills/README.md +43 -0
  10. package/skills/swift-concurrency/NOTICE.md +18 -0
  11. package/skills/swift-concurrency/SKILL.md +235 -0
  12. package/skills/swift-concurrency/references/actors.md +640 -0
  13. package/skills/swift-concurrency/references/async-await-basics.md +249 -0
  14. package/skills/swift-concurrency/references/async-sequences.md +635 -0
  15. package/skills/swift-concurrency/references/core-data.md +533 -0
  16. package/skills/swift-concurrency/references/glossary.md +96 -0
  17. package/skills/swift-concurrency/references/linting.md +38 -0
  18. package/skills/swift-concurrency/references/memory-management.md +542 -0
  19. package/skills/swift-concurrency/references/migration.md +721 -0
  20. package/skills/swift-concurrency/references/performance.md +574 -0
  21. package/skills/swift-concurrency/references/sendable.md +578 -0
  22. package/skills/swift-concurrency/references/tasks.md +604 -0
  23. package/skills/swift-concurrency/references/testing.md +565 -0
  24. package/skills/swift-concurrency/references/threading.md +452 -0
  25. package/skills/swift-expert/NOTICE.md +18 -0
  26. package/skills/swift-expert/SKILL.md +226 -0
  27. package/skills/swift-expert/references/async-concurrency.md +363 -0
  28. package/skills/swift-expert/references/memory-performance.md +380 -0
  29. package/skills/swift-expert/references/protocol-oriented.md +357 -0
  30. package/skills/swift-expert/references/swiftui-patterns.md +294 -0
  31. package/skills/swift-expert/references/testing-patterns.md +402 -0
  32. package/skills/swift-testing/NOTICE.md +18 -0
  33. package/skills/swift-testing/SKILL.md +295 -0
  34. package/skills/swift-testing/references/async-testing.md +245 -0
  35. package/skills/swift-testing/references/dump-snapshot-testing.md +265 -0
  36. package/skills/swift-testing/references/fixtures.md +193 -0
  37. package/skills/swift-testing/references/integration-testing.md +189 -0
  38. package/skills/swift-testing/references/migration-xctest.md +301 -0
  39. package/skills/swift-testing/references/parameterized-tests.md +171 -0
  40. package/skills/swift-testing/references/snapshot-testing.md +201 -0
  41. package/skills/swift-testing/references/test-doubles.md +243 -0
  42. package/skills/swift-testing/references/test-organization.md +231 -0
  43. package/skills/swiftui-expert-skill/NOTICE.md +18 -0
  44. package/skills/swiftui-expert-skill/SKILL.md +281 -0
  45. package/skills/swiftui-expert-skill/references/accessibility-patterns.md +151 -0
  46. package/skills/swiftui-expert-skill/references/animation-advanced.md +403 -0
  47. package/skills/swiftui-expert-skill/references/animation-basics.md +284 -0
  48. package/skills/swiftui-expert-skill/references/animation-transitions.md +326 -0
  49. package/skills/swiftui-expert-skill/references/charts-accessibility.md +135 -0
  50. package/skills/swiftui-expert-skill/references/charts.md +602 -0
  51. package/skills/swiftui-expert-skill/references/image-optimization.md +203 -0
  52. package/skills/swiftui-expert-skill/references/latest-apis.md +464 -0
  53. package/skills/swiftui-expert-skill/references/layout-best-practices.md +266 -0
  54. package/skills/swiftui-expert-skill/references/liquid-glass.md +414 -0
  55. package/skills/swiftui-expert-skill/references/list-patterns.md +394 -0
  56. package/skills/swiftui-expert-skill/references/macos-scenes.md +318 -0
  57. package/skills/swiftui-expert-skill/references/macos-views.md +357 -0
  58. package/skills/swiftui-expert-skill/references/macos-window-styling.md +303 -0
  59. package/skills/swiftui-expert-skill/references/performance-patterns.md +403 -0
  60. package/skills/swiftui-expert-skill/references/scroll-patterns.md +293 -0
  61. package/skills/swiftui-expert-skill/references/sheet-navigation-patterns.md +363 -0
  62. package/skills/swiftui-expert-skill/references/state-management.md +417 -0
  63. package/skills/swiftui-expert-skill/references/view-structure.md +389 -0
  64. package/skills/swiftui-ui-patterns/NOTICE.md +18 -0
  65. package/skills/swiftui-ui-patterns/SKILL.md +95 -0
  66. package/skills/swiftui-ui-patterns/references/app-wiring.md +201 -0
  67. package/skills/swiftui-ui-patterns/references/async-state.md +96 -0
  68. package/skills/swiftui-ui-patterns/references/components-index.md +50 -0
  69. package/skills/swiftui-ui-patterns/references/controls.md +57 -0
  70. package/skills/swiftui-ui-patterns/references/deeplinks.md +66 -0
  71. package/skills/swiftui-ui-patterns/references/focus.md +90 -0
  72. package/skills/swiftui-ui-patterns/references/form.md +97 -0
  73. package/skills/swiftui-ui-patterns/references/grids.md +71 -0
  74. package/skills/swiftui-ui-patterns/references/haptics.md +71 -0
  75. package/skills/swiftui-ui-patterns/references/input-toolbar.md +51 -0
  76. package/skills/swiftui-ui-patterns/references/lightweight-clients.md +93 -0
  77. package/skills/swiftui-ui-patterns/references/list.md +86 -0
  78. package/skills/swiftui-ui-patterns/references/loading-placeholders.md +38 -0
  79. package/skills/swiftui-ui-patterns/references/macos-settings.md +71 -0
  80. package/skills/swiftui-ui-patterns/references/matched-transitions.md +59 -0
  81. package/skills/swiftui-ui-patterns/references/media.md +73 -0
  82. package/skills/swiftui-ui-patterns/references/menu-bar.md +101 -0
  83. package/skills/swiftui-ui-patterns/references/navigationstack.md +159 -0
  84. package/skills/swiftui-ui-patterns/references/overlay.md +45 -0
  85. package/skills/swiftui-ui-patterns/references/performance.md +62 -0
  86. package/skills/swiftui-ui-patterns/references/previews.md +48 -0
  87. package/skills/swiftui-ui-patterns/references/scroll-reveal.md +133 -0
  88. package/skills/swiftui-ui-patterns/references/scrollview.md +87 -0
  89. package/skills/swiftui-ui-patterns/references/searchable.md +71 -0
  90. package/skills/swiftui-ui-patterns/references/sheets.md +155 -0
  91. package/skills/swiftui-ui-patterns/references/split-views.md +72 -0
  92. package/skills/swiftui-ui-patterns/references/tabview.md +114 -0
  93. package/skills/swiftui-ui-patterns/references/theming.md +71 -0
  94. package/skills/swiftui-ui-patterns/references/title-menus.md +93 -0
  95. package/skills/swiftui-ui-patterns/references/top-bar.md +49 -0
@@ -0,0 +1,235 @@
1
+ ---
2
+ name: swift-concurrency
3
+ description: 'Expert guidance on Swift Concurrency best practices, patterns, and implementation. Use when developers mention: (1) Swift Concurrency, async/await, actors, or tasks, (2) "use Swift Concurrency" or "modern concurrency patterns", (3) migrating to Swift 6, (4) data races or thread safety issues, (5) refactoring closures to async/await, (6) @MainActor, Sendable, or actor isolation, (7) concurrent code architecture or performance optimization, (8) concurrency-related linter warnings (SwiftLint or similar; e.g. async_without_await, Sendable/actor isolation/MainActor lint).'
4
+ ---
5
+ # Swift Concurrency
6
+
7
+ ## Overview
8
+
9
+ This skill provides expert guidance on Swift Concurrency, covering modern async/await patterns, actors, tasks, Sendable conformance, and migration to Swift 6. Use this skill to help developers write safe, performant concurrent code and navigate the complexities of Swift's structured concurrency model.
10
+
11
+ ## Agent Behavior Contract (Follow These Rules)
12
+
13
+ 1. Analyze the project/package file to find out which Swift language mode (Swift 5.x vs Swift 6) and which Xcode/Swift toolchain is used when advice depends on it.
14
+ 2. Before proposing fixes, identify the isolation boundary: `@MainActor`, custom actor, actor instance isolation, or nonisolated.
15
+ 3. Do not recommend `@MainActor` as a blanket fix. Justify why main-actor isolation is correct for the code.
16
+ 4. Prefer structured concurrency (child tasks, task groups) over unstructured tasks. Use `Task.detached` only with a clear reason.
17
+ 5. If recommending `@preconcurrency`, `@unchecked Sendable`, or `nonisolated(unsafe)`, require:
18
+ - a documented safety invariant
19
+ - a follow-up ticket to remove or migrate it
20
+ 6. For migration work, optimize for minimal blast radius (small, reviewable changes) and add verification steps.
21
+ 7. Course references are for deeper learning only. Use them sparingly and only when they clearly help answer the developer’s question.
22
+
23
+ ## Project Settings Intake (Evaluate Before Advising)
24
+
25
+ Concurrency behavior depends on build settings. Always try to determine:
26
+
27
+ - Default actor isolation (is the module default `@MainActor` or `nonisolated`?)
28
+ - Strict concurrency checking level (minimal/targeted/complete)
29
+ - Whether upcoming features are enabled (especially `NonisolatedNonsendingByDefault`)
30
+ - Swift language mode (Swift 5.x vs Swift 6) and SwiftPM tools version
31
+
32
+ ### Manual checks (no scripts)
33
+
34
+ - SwiftPM:
35
+ - Check `Package.swift` for `.defaultIsolation(MainActor.self)`.
36
+ - Check `Package.swift` for `.enableUpcomingFeature("NonisolatedNonsendingByDefault")`.
37
+ - Check for strict concurrency flags: `.enableExperimentalFeature("StrictConcurrency=targeted")` (or similar).
38
+ - Check tools version at the top: `// swift-tools-version: ...`
39
+ - Xcode projects:
40
+ - Search `project.pbxproj` for:
41
+ - `SWIFT_DEFAULT_ACTOR_ISOLATION`
42
+ - `SWIFT_STRICT_CONCURRENCY`
43
+ - `SWIFT_UPCOMING_FEATURE_` (and/or `SWIFT_ENABLE_EXPERIMENTAL_FEATURES`)
44
+
45
+ If any of these are unknown, ask the developer to confirm them before giving migration-sensitive guidance.
46
+
47
+ ## Quick Decision Tree
48
+
49
+ When a developer needs concurrency guidance, follow this decision tree:
50
+
51
+ 1. **Starting fresh with async code?**
52
+ - Read `references/async-await-basics.md` for foundational patterns
53
+ - For parallel operations → `references/tasks.md` (async let, task groups)
54
+
55
+ 2. **Protecting shared mutable state?**
56
+ - Need to protect class-based state → `references/actors.md` (actors, @MainActor)
57
+ - Need thread-safe value passing → `references/sendable.md` (Sendable conformance)
58
+
59
+ 3. **Managing async operations?**
60
+ - Structured async work → `references/tasks.md` (Task, child tasks, cancellation)
61
+ - Streaming data → `references/async-sequences.md` (AsyncSequence, AsyncStream)
62
+
63
+ 4. **Working with legacy frameworks?**
64
+ - Core Data integration → `references/core-data.md`
65
+ - General migration → `references/migration.md`
66
+
67
+ 5. **Performance or debugging issues?**
68
+ - Slow async code → `references/performance.md` (profiling, suspension points)
69
+ - Testing concerns → `references/testing.md` (XCTest, Swift Testing)
70
+
71
+ 6. **Understanding threading behavior?**
72
+ - Read `references/threading.md` for thread/task relationship and isolation
73
+
74
+ 7. **Memory issues with tasks?**
75
+ - Read `references/memory-management.md` for retain cycle prevention
76
+
77
+ ## Triage-First Playbook (Common Errors -> Next Best Move)
78
+
79
+ - SwiftLint concurrency-related warnings
80
+ - Use `references/linting.md` for rule intent and preferred fixes; avoid dummy awaits as “fixes”.
81
+ - SwiftLint `async_without_await` warning
82
+ - Remove `async` if not required; if required by protocol/override/@concurrent, prefer narrow suppression over adding fake awaits. See `references/linting.md`.
83
+ - "Sending value of non-Sendable type ... risks causing data races"
84
+ - First: identify where the value crosses an isolation boundary
85
+ - Then: use `references/sendable.md` and `references/threading.md` (especially Swift 6.2 behavior changes)
86
+ - "Main actor-isolated ... cannot be used from a nonisolated context"
87
+ - First: decide if it truly belongs on `@MainActor`
88
+ - Then: use `references/actors.md` (global actors, `nonisolated`, isolated parameters) and `references/threading.md` (default isolation)
89
+ - "Class property 'current' is unavailable from asynchronous contexts" (Thread APIs)
90
+ - Use `references/threading.md` to avoid thread-centric debugging and rely on isolation + Instruments
91
+ - XCTest async errors like "wait(...) is unavailable from asynchronous contexts"
92
+ - Use `references/testing.md` (`await fulfillment(of:)` and Swift Testing patterns)
93
+ - Core Data concurrency warnings/errors
94
+ - Use `references/core-data.md` (DAO/`NSManagedObjectID`, default isolation conflicts)
95
+
96
+ ## Core Patterns Reference
97
+
98
+ ### When to Use Each Concurrency Tool
99
+
100
+ **async/await** - Making existing synchronous code asynchronous
101
+ ```swift
102
+ // Use for: Single asynchronous operations
103
+ func fetchUser() async throws -> User {
104
+ try await networkClient.get("/user")
105
+ }
106
+ ```
107
+
108
+ **async let** - Running multiple independent async operations in parallel
109
+ ```swift
110
+ // Use for: Fixed number of parallel operations known at compile time
111
+ async let user = fetchUser()
112
+ async let posts = fetchPosts()
113
+ let profile = try await (user, posts)
114
+ ```
115
+
116
+ **Task** - Starting unstructured asynchronous work
117
+ ```swift
118
+ // Use for: Fire-and-forget operations, bridging sync to async contexts
119
+ Task {
120
+ await updateUI()
121
+ }
122
+ ```
123
+
124
+ **Task Group** - Dynamic parallel operations with structured concurrency
125
+ ```swift
126
+ // Use for: Unknown number of parallel operations at compile time
127
+ await withTaskGroup(of: Result.self) { group in
128
+ for item in items {
129
+ group.addTask { await process(item) }
130
+ }
131
+ }
132
+ ```
133
+
134
+ **Actor** - Protecting mutable state from data races
135
+ ```swift
136
+ // Use for: Shared mutable state accessed from multiple contexts
137
+ actor DataCache {
138
+ private var cache: [String: Data] = [:]
139
+ func get(_ key: String) -> Data? { cache[key] }
140
+ }
141
+ ```
142
+
143
+ **@MainActor** - Ensuring UI updates on main thread
144
+ ```swift
145
+ // Use for: View models, UI-related classes
146
+ @MainActor
147
+ class ViewModel: ObservableObject {
148
+ @Published var data: String = ""
149
+ }
150
+ ```
151
+
152
+ ### Common Scenarios
153
+
154
+ **Scenario: Network request with UI update**
155
+ ```swift
156
+ Task { @concurrent in
157
+ let data = try await fetchData() // Background
158
+ await MainActor.run {
159
+ self.updateUI(with: data) // Main thread
160
+ }
161
+ }
162
+ ```
163
+
164
+ **Scenario: Multiple parallel network requests**
165
+ ```swift
166
+ async let users = fetchUsers()
167
+ async let posts = fetchPosts()
168
+ async let comments = fetchComments()
169
+ let (u, p, c) = try await (users, posts, comments)
170
+ ```
171
+
172
+ **Scenario: Processing array items in parallel**
173
+ ```swift
174
+ await withTaskGroup(of: ProcessedItem.self) { group in
175
+ for item in items {
176
+ group.addTask { await process(item) }
177
+ }
178
+ for await result in group {
179
+ results.append(result)
180
+ }
181
+ }
182
+ ```
183
+
184
+ ## Swift 6 Migration Quick Guide
185
+
186
+ Key changes in Swift 6:
187
+ - **Strict concurrency checking** enabled by default
188
+ - **Complete data-race safety** at compile time
189
+ - **Sendable requirements** enforced on boundaries
190
+ - **Isolation checking** for all async boundaries
191
+
192
+ For detailed migration steps, see `references/migration.md`.
193
+
194
+ ## Reference Files
195
+
196
+ Load these files as needed for specific topics:
197
+
198
+ - **`async-await-basics.md`** - async/await syntax, execution order, async let, URLSession patterns
199
+ - **`tasks.md`** - Task lifecycle, cancellation, priorities, task groups, structured vs unstructured
200
+ - **`threading.md`** - Thread/task relationship, suspension points, isolation domains, nonisolated
201
+ - **`memory-management.md`** - Retain cycles in tasks, memory safety patterns
202
+ - **`actors.md`** - Actor isolation, @MainActor, global actors, reentrancy, custom executors, Mutex
203
+ - **`sendable.md`** - Sendable conformance, value/reference types, @unchecked, region isolation
204
+ - **`linting.md`** - Concurrency-focused lint rules and SwiftLint `async_without_await`
205
+ - **`async-sequences.md`** - AsyncSequence, AsyncStream, when to use vs regular async methods
206
+ - **`core-data.md`** - NSManagedObject sendability, custom executors, isolation conflicts
207
+ - **`performance.md`** - Profiling with Instruments, reducing suspension points, execution strategies
208
+ - **`testing.md`** - XCTest async patterns, Swift Testing, concurrency testing utilities
209
+ - **`migration.md`** - Swift 6 migration strategy, closure-to-async conversion, @preconcurrency, FRP migration
210
+
211
+ ## Best Practices Summary
212
+
213
+ 1. **Prefer structured concurrency** - Use task groups over unstructured tasks when possible
214
+ 2. **Minimize suspension points** - Keep actor-isolated sections small to reduce context switches
215
+ 3. **Use @MainActor judiciously** - Only for truly UI-related code
216
+ 4. **Make types Sendable** - Enable safe concurrent access by conforming to Sendable
217
+ 5. **Handle cancellation** - Check Task.isCancelled in long-running operations
218
+ 6. **Avoid blocking** - Never use semaphores or locks in async contexts
219
+ 7. **Test concurrent code** - Use proper async test methods and consider timing issues
220
+
221
+ ## Verification Checklist (When You Change Concurrency Code)
222
+
223
+ - Confirm build settings (default isolation, strict concurrency, upcoming features) before interpreting diagnostics.
224
+ - After refactors:
225
+ - Run tests, especially concurrency-sensitive ones (see `references/testing.md`).
226
+ - If performance-related, verify with Instruments (see `references/performance.md`).
227
+ - If lifetime-related, verify deinit/cancellation behavior (see `references/memory-management.md`).
228
+
229
+ ## Glossary
230
+
231
+ See `references/glossary.md` for quick definitions of core concurrency terms used across this skill.
232
+
233
+ ---
234
+
235
+ **Note**: This skill is based on the comprehensive [Swift Concurrency Course](https://www.swiftconcurrencycourse.com?utm_source=github&utm_medium=agent-skill&utm_campaign=skill-footer) by Antoine van der Lee.