swift-code-reviewer-skill 1.1.1 → 1.2.1

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 +44 -162
  2. package/README.md +91 -21
  3. package/SKILL.md +107 -725
  4. package/bin/install.js +87 -22
  5. package/package.json +16 -2
  6. package/references/companion-skills.md +70 -0
  7. package/skills/README.md +43 -0
  8. package/skills/swift-concurrency/NOTICE.md +18 -0
  9. package/skills/swift-concurrency/SKILL.md +235 -0
  10. package/skills/swift-concurrency/references/actors.md +640 -0
  11. package/skills/swift-concurrency/references/async-await-basics.md +249 -0
  12. package/skills/swift-concurrency/references/async-sequences.md +635 -0
  13. package/skills/swift-concurrency/references/core-data.md +533 -0
  14. package/skills/swift-concurrency/references/glossary.md +96 -0
  15. package/skills/swift-concurrency/references/linting.md +38 -0
  16. package/skills/swift-concurrency/references/memory-management.md +542 -0
  17. package/skills/swift-concurrency/references/migration.md +721 -0
  18. package/skills/swift-concurrency/references/performance.md +574 -0
  19. package/skills/swift-concurrency/references/sendable.md +578 -0
  20. package/skills/swift-concurrency/references/tasks.md +604 -0
  21. package/skills/swift-concurrency/references/testing.md +565 -0
  22. package/skills/swift-concurrency/references/threading.md +452 -0
  23. package/skills/swift-expert/NOTICE.md +18 -0
  24. package/skills/swift-expert/SKILL.md +226 -0
  25. package/skills/swift-expert/references/async-concurrency.md +363 -0
  26. package/skills/swift-expert/references/memory-performance.md +380 -0
  27. package/skills/swift-expert/references/protocol-oriented.md +357 -0
  28. package/skills/swift-expert/references/swiftui-patterns.md +294 -0
  29. package/skills/swift-expert/references/testing-patterns.md +402 -0
  30. package/skills/swift-testing/NOTICE.md +18 -0
  31. package/skills/swift-testing/SKILL.md +295 -0
  32. package/skills/swift-testing/references/async-testing.md +245 -0
  33. package/skills/swift-testing/references/dump-snapshot-testing.md +265 -0
  34. package/skills/swift-testing/references/fixtures.md +193 -0
  35. package/skills/swift-testing/references/integration-testing.md +189 -0
  36. package/skills/swift-testing/references/migration-xctest.md +301 -0
  37. package/skills/swift-testing/references/parameterized-tests.md +171 -0
  38. package/skills/swift-testing/references/snapshot-testing.md +201 -0
  39. package/skills/swift-testing/references/test-doubles.md +243 -0
  40. package/skills/swift-testing/references/test-organization.md +231 -0
  41. package/skills/swiftui-expert-skill/NOTICE.md +18 -0
  42. package/skills/swiftui-expert-skill/SKILL.md +281 -0
  43. package/skills/swiftui-expert-skill/references/accessibility-patterns.md +151 -0
  44. package/skills/swiftui-expert-skill/references/animation-advanced.md +403 -0
  45. package/skills/swiftui-expert-skill/references/animation-basics.md +284 -0
  46. package/skills/swiftui-expert-skill/references/animation-transitions.md +326 -0
  47. package/skills/swiftui-expert-skill/references/charts-accessibility.md +135 -0
  48. package/skills/swiftui-expert-skill/references/charts.md +602 -0
  49. package/skills/swiftui-expert-skill/references/image-optimization.md +203 -0
  50. package/skills/swiftui-expert-skill/references/latest-apis.md +464 -0
  51. package/skills/swiftui-expert-skill/references/layout-best-practices.md +266 -0
  52. package/skills/swiftui-expert-skill/references/liquid-glass.md +414 -0
  53. package/skills/swiftui-expert-skill/references/list-patterns.md +394 -0
  54. package/skills/swiftui-expert-skill/references/macos-scenes.md +318 -0
  55. package/skills/swiftui-expert-skill/references/macos-views.md +357 -0
  56. package/skills/swiftui-expert-skill/references/macos-window-styling.md +303 -0
  57. package/skills/swiftui-expert-skill/references/performance-patterns.md +403 -0
  58. package/skills/swiftui-expert-skill/references/scroll-patterns.md +293 -0
  59. package/skills/swiftui-expert-skill/references/sheet-navigation-patterns.md +363 -0
  60. package/skills/swiftui-expert-skill/references/state-management.md +417 -0
  61. package/skills/swiftui-expert-skill/references/view-structure.md +389 -0
  62. package/skills/swiftui-ui-patterns/NOTICE.md +18 -0
  63. package/skills/swiftui-ui-patterns/SKILL.md +95 -0
  64. package/skills/swiftui-ui-patterns/references/app-wiring.md +201 -0
  65. package/skills/swiftui-ui-patterns/references/async-state.md +96 -0
  66. package/skills/swiftui-ui-patterns/references/components-index.md +50 -0
  67. package/skills/swiftui-ui-patterns/references/controls.md +57 -0
  68. package/skills/swiftui-ui-patterns/references/deeplinks.md +66 -0
  69. package/skills/swiftui-ui-patterns/references/focus.md +90 -0
  70. package/skills/swiftui-ui-patterns/references/form.md +97 -0
  71. package/skills/swiftui-ui-patterns/references/grids.md +71 -0
  72. package/skills/swiftui-ui-patterns/references/haptics.md +71 -0
  73. package/skills/swiftui-ui-patterns/references/input-toolbar.md +51 -0
  74. package/skills/swiftui-ui-patterns/references/lightweight-clients.md +93 -0
  75. package/skills/swiftui-ui-patterns/references/list.md +86 -0
  76. package/skills/swiftui-ui-patterns/references/loading-placeholders.md +38 -0
  77. package/skills/swiftui-ui-patterns/references/macos-settings.md +71 -0
  78. package/skills/swiftui-ui-patterns/references/matched-transitions.md +59 -0
  79. package/skills/swiftui-ui-patterns/references/media.md +73 -0
  80. package/skills/swiftui-ui-patterns/references/menu-bar.md +101 -0
  81. package/skills/swiftui-ui-patterns/references/navigationstack.md +159 -0
  82. package/skills/swiftui-ui-patterns/references/overlay.md +45 -0
  83. package/skills/swiftui-ui-patterns/references/performance.md +62 -0
  84. package/skills/swiftui-ui-patterns/references/previews.md +48 -0
  85. package/skills/swiftui-ui-patterns/references/scroll-reveal.md +133 -0
  86. package/skills/swiftui-ui-patterns/references/scrollview.md +87 -0
  87. package/skills/swiftui-ui-patterns/references/searchable.md +71 -0
  88. package/skills/swiftui-ui-patterns/references/sheets.md +155 -0
  89. package/skills/swiftui-ui-patterns/references/split-views.md +72 -0
  90. package/skills/swiftui-ui-patterns/references/tabview.md +114 -0
  91. package/skills/swiftui-ui-patterns/references/theming.md +71 -0
  92. package/skills/swiftui-ui-patterns/references/title-menus.md +93 -0
  93. package/skills/swiftui-ui-patterns/references/top-bar.md +49 -0
  94. package/templates/agents/swift-code-reviewer.md +78 -0
  95. package/templates/commands/review.md +56 -0
package/SKILL.md CHANGED
@@ -1,780 +1,162 @@
1
1
  ---
2
2
  name: swift-code-reviewer
3
- description: Perform thorough code reviews for Swift/SwiftUI code, analyzing code quality, architecture, performance, security, and adherence to Swift 6+ best practices, SwiftUI patterns, navigation architecture, sheet routing, theming, async state, iOS/macOS platform guidelines, and project-specific coding standards from .claude/CLAUDE.md. Use when reviewing code changes, performing quality audits, or providing structured feedback on Swift codebases with all severity levels and positive feedback.
3
+ description: "Multi-layer code review agent for Swift and SwiftUI projects. Analyzes PRs, diffs, and files across six dimensions: Swift 6+ concurrency safety, SwiftUI state management and modern APIs, performance (view updates, ForEach identity, lazy loading), security (force unwraps, Keychain, input validation), architecture compliance (MVVM/MVI/TCA, dependency injection), and project-specific standards from .claude/CLAUDE.md. Outputs structured reports with Critical/High/Medium/Low severity, positive feedback, and prioritized action items with file:line references. Use when the user says review this PR, review my code, review my changes, check this file, code review, audit this codebase, check code quality, review uncommitted changes, review all ViewModels, or mentions reviewing .swift files, navigation, sheets, theming, or async patterns."
4
4
  ---
5
5
 
6
6
  # Swift/SwiftUI Code Review Skill
7
7
 
8
- ## Overview
8
+ 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.
9
9
 
10
- This skill provides comprehensive code review capabilities for Swift and SwiftUI projects, combining Apple's best practices with project-specific coding standards. It performs multi-layer analysis covering code quality, architecture, performance, security, and maintainability.
10
+ ## Workflow
11
11
 
12
- ### Key Capabilities
12
+ ### Phase 1 — Context Gathering
13
13
 
14
- - **Project-Aware Reviews**: Reads `.claude/CLAUDE.md` and related architecture documents to validate against project-specific standards
15
- - **Multi-Layer Analysis**: Combines Swift 6+ best practices, SwiftUI patterns, performance optimization, and security checks
16
- - **Comprehensive Feedback**: Provides Critical/High/Medium/Low severity issues, positive feedback, and refactoring suggestions
17
- - **Integration with Existing Skills**: Leverages `swift-best-practices`, `swiftui-expert-skill`, and `swiftui-performance-audit` for domain expertise
18
- - **Actionable Output**: Structured feedback with file:line references, code examples, and prioritized action items
14
+ 1. Try to load `.claude/CLAUDE.md`.
15
+ - **If missing**: add a note to the report _"No project standards file found — review uses default Apple guidelines"_ — then continue.
16
+ 2. Obtain the changeset: `git diff`, `git diff --cached`, or `gh pr diff <n>`.
17
+ - **If diff is empty**: stop and ask the user to specify files, a PR number, or a directory.
18
+ 3. Read each changed file plus key related files (imports, protocols it conforms to, corresponding test file if present).
19
19
 
20
- ## When to Use This Skill
20
+ ### Phase 2 Analysis
21
21
 
22
- Use this skill when you need to:
22
+ For each category, load the reference file before writing findings:
23
23
 
24
- - Review Pull Requests or Merge Requests for Swift/SwiftUI projects
25
- - Perform code quality audits on existing codebases
26
- - Validate code changes against project-specific standards
27
- - Analyze individual Swift/SwiftUI files for best practices
28
- - Review uncommitted git changes before committing
29
- - Assess architecture and maintainability of Swift code
30
- - Provide structured feedback to team members
24
+ 1. **Swift Quality** concurrency, error handling, optionals, naming → `references/swift-quality-checklist.md`; for concurrency findings also read `skills/swift-concurrency/references/sendable.md` and `actors.md`
25
+ 2. **SwiftUI Patterns** property wrappers, state management, deprecated APIs → `references/swiftui-review-checklist.md`; for wrapper selection read `skills/swiftui-expert-skill/references/state-management.md`
26
+ 3. **Performance** view body cost, ForEach identity, lazy loading, retain cycles → `references/performance-review.md`
27
+ 4. **Security** force unwraps, Keychain vs UserDefaults, input validation, no secrets in logs → `references/security-checklist.md`
28
+ 5. **Architecture** MVVM/MVI/TCA compliance, DI, testability → `references/architecture-patterns.md`
29
+ 6. **Project Standards** validate against `.claude/CLAUDE.md` rules → `references/custom-guidelines.md`
31
30
 
32
- **Trigger patterns:**
31
+ For test file findings, consult `skills/swift-testing/references/test-organization.md`.
32
+ For navigation/routing findings, consult `skills/swiftui-ui-patterns/references/navigationstack.md`.
33
33
 
34
- - "Review this PR"
35
- - "Review [filename].swift"
36
- - "Review my changes"
37
- - "Code review for [component]"
38
- - "Check if this follows our coding standards"
39
- - "Review against .claude/CLAUDE.md"
34
+ ### Phase 3 — Report
40
35
 
41
- ## Review Workflow
36
+ Group findings by file → sort by severity within each file → write prioritized action items.
42
37
 
43
- The skill follows a **four-phase workflow** to ensure comprehensive and actionable feedback:
38
+ Severity: **Critical** (crash/data race/security hole) · **High** (anti-pattern/major arch violation) · **Medium** (quality/maintainability) · **Low** (style/suggestion).
44
39
 
45
- ### Phase 1: Context Gathering
40
+ Include one-sentence positive feedback where code is notably well-written. Never pad with generic praise.
46
41
 
47
- **Objective**: Understand the project context and scope of review
42
+ ## Concrete Finding Examples
48
43
 
49
- 1. **Read Project Guidelines**
50
- - Load `.claude/CLAUDE.md` if it exists in the repository
51
- - Read related architecture documents (e.g., `DependencyInjection-Architecture.md`, `Design System Structure.md`)
52
- - Extract custom coding standards, patterns, and rules
44
+ ### Force Unwrap → guard let (Critical)
53
45
 
54
- 2. **Identify Review Scope**
55
- - Determine files to review:
56
- - User-specified files
57
- - Git diff (uncommitted or PR/MR changes)
58
- - Modified files in a specific directory
59
- - Categorize changes by type (UI, logic, tests, configuration)
46
+ **`LoginViewModel.swift:89`** Current:
60
47
 
61
- 3. **Gather File Context**
62
- - Read all files that will be reviewed
63
- - Understand the broader context (related files, dependencies)
64
- - Identify the purpose and role of each component
65
-
66
- ### Phase 2: Automated Analysis
67
-
68
- **Objective**: Run parallel checks across multiple quality dimensions
69
-
70
- Execute checks across **six core categories**:
71
-
72
- #### 1. Swift Best Practices
73
-
74
- Reference: `swift-best-practices` skill knowledge base
75
-
76
- - **Concurrency Safety**
77
- - Actor isolation correctness
78
- - MainActor usage for UI code
79
- - Sendable conformance
80
- - Data race prevention
81
- - Async/await patterns
82
-
83
- - **API Design**
84
- - Naming conventions (Swift API Design Guidelines)
85
- - Parameter labels clarity
86
- - Return type appropriateness
87
- - Error handling (typed throws)
88
-
89
- - **Language Features**
90
- - Availability attributes for new APIs
91
- - Migration to Swift 6 features
92
- - Avoiding deprecated patterns
93
- - Proper use of optionals
94
-
95
- #### 2. SwiftUI Quality
96
-
97
- Reference: `swiftui-expert-skill` knowledge base
98
-
99
- - **State Management**
100
- - Correct property wrapper selection (@Observable, @State, @Binding, @Environment)
101
- - State ownership and data flow
102
- - Avoiding unnecessary state
103
- - View model patterns
104
-
105
- - **Modern API Usage**
106
- - Replace deprecated APIs with modern equivalents
107
- - Use latest SwiftUI features (iOS 17+, macOS 14+)
108
- - Proper use of view modifiers
109
- - Composition over inheritance
110
-
111
- - **View Composition**
112
- - View extraction appropriateness
113
- - Component reusability
114
- - View hierarchy depth
115
- - Subview organization
116
-
117
- - **Accessibility**
118
- - Accessibility labels and hints
119
- - VoiceOver support
120
- - Dynamic Type support
121
- - Keyboard navigation
122
-
123
- #### 3. Performance
124
-
125
- Reference: `swiftui-performance-audit` knowledge base
126
-
127
- - **View Optimization**
128
- - Unnecessary view updates
129
- - Heavy computation in body
130
- - Equatable conformance for view models
131
- - Lazy loading patterns
132
-
133
- - **List Performance**
134
- - ForEach identity stability
135
- - Cell reuse patterns
136
- - Scroll performance
137
- - Large dataset handling
138
-
139
- - **Layout Efficiency**
140
- - Layout thrash detection
141
- - GeometryReader overuse
142
- - Frame calculations
143
- - Animation performance
144
-
145
- - **Resource Management**
146
- - Image loading and caching
147
- - Memory leaks (retain cycles)
148
- - Background task management
149
- - Network request optimization
150
-
151
- #### 4. Security & Safety
152
-
153
- - **Data Validation**
154
- - Input sanitization
155
- - Type safety
156
- - Boundary checking
157
- - Force unwrap audit (avoid `!` and `as!`)
158
-
159
- - **Sensitive Data Handling**
160
- - Password and token management
161
- - Keychain usage for credentials
162
- - Secure data transmission
163
- - Log sanitization (no sensitive data in logs)
164
-
165
- - **Platform Security**
166
- - Permission handling (camera, location, etc.)
167
- - Network security (TLS, certificate pinning)
168
- - Secure storage (UserDefaults vs Keychain)
169
- - Code signing and entitlements
170
-
171
- #### 5. Architecture & Maintainability
172
-
173
- - **Project Architecture Compliance**
174
- - Adherence to defined patterns (MVVM, MVI, TCA, etc.)
175
- - Layer separation (View/ViewModel/Repository/UseCase)
176
- - Dependency injection patterns
177
- - Module boundaries
178
-
179
- - **Code Organization**
180
- - File structure and naming
181
- - Logical grouping
182
- - Extension organization
183
- - Protocol conformances
184
-
185
- - **Testability**
186
- - Unit test coverage
187
- - Test structure (Arrange-Act-Assert)
188
- - Mock/stub usage
189
- - Test isolation
190
-
191
- - **Documentation**
192
- - DocC comments for public APIs
193
- - Complex logic explanations
194
- - Architecture decision records
195
- - README and guides
196
-
197
- #### 6. Project-Specific Standards
198
-
199
- - **Custom Coding Standards**
200
- - Validate against `.claude/CLAUDE.md` rules
201
- - Check custom error handling patterns
202
- - Verify project-specific naming conventions
203
- - Validate testing requirements
204
-
205
- - **Design System Compliance**
206
- - Use of design tokens
207
- - Consistent spacing and typography
208
- - Color palette adherence
209
- - Component library usage
210
-
211
- - **Navigation Patterns**
212
- - Coordinator pattern compliance
213
- - Deep linking support
214
- - State restoration
215
- - Navigation flow consistency
216
-
217
- ### Phase 3: Report Generation
218
-
219
- **Objective**: Aggregate findings into a structured, actionable report
220
-
221
- 1. **Categorize Findings by Severity**
222
- - **Critical**: Security vulnerabilities, data races, crashes, breaking changes
223
- - **High**: Performance issues, anti-patterns, major architecture violations
224
- - **Medium**: Code quality improvements, missing documentation, minor violations
225
- - **Low**: Style inconsistencies, suggestions for refactoring
226
-
227
- 2. **Include Positive Feedback**
228
- - Acknowledge good practices and patterns
229
- - Highlight excellent code quality
230
- - Recognize proper use of modern APIs
231
- - Note strong architecture decisions
232
-
233
- 3. **Add Refactoring Suggestions**
234
- - Proactive improvement opportunities
235
- - Modernization suggestions
236
- - Code simplification ideas
237
- - Performance optimization hints
238
-
239
- 4. **Group and Organize**
240
- - Group by file, then by category
241
- - Sort by severity within each file
242
- - Include code location references (file:line)
243
- - Provide specific code examples
244
-
245
- ### Phase 4: Delivery
246
-
247
- **Objective**: Present findings in a clear, actionable format
248
-
249
- 1. **Format as Structured Markdown**
250
- - Executive summary with key metrics
251
- - Severity breakdown
252
- - File-by-file detailed findings
253
- - Positive feedback section
254
- - Prioritized action items
255
-
256
- 2. **Include Code References**
257
- - Exact file and line numbers (file.swift:123)
258
- - Before/after code examples
259
- - Links to relevant documentation
260
- - Comparison with project guidelines
261
-
262
- 3. **Provide Context**
263
- - Explain _why_ something is an issue
264
- - Reference best practices or standards
265
- - Suggest specific fixes with examples
266
- - Link to learning resources
267
-
268
- ## Core Review Categories
269
-
270
- ### 1. Swift Language Quality
271
-
272
- **What to Check:**
273
-
274
- - Concurrency patterns (actors, async/await, Sendable)
275
- - Error handling (typed throws, Result type)
276
- - Optionals handling (avoid force unwrapping)
277
- - Access control (public, internal, private, fileprivate)
278
- - Naming conventions (Swift API Design Guidelines)
279
- - Type inference vs explicit types
280
- - Value types vs reference types
281
-
282
- **Reference:** `references/swift-quality-checklist.md`
283
-
284
- ### 2. SwiftUI Patterns
285
-
286
- **What to Check:**
287
-
288
- - Property wrapper selection and usage
289
- - State management patterns
290
- - View lifecycle understanding
291
- - Modern API usage (avoid deprecated)
292
- - View composition and extraction
293
- - Accessibility implementation
294
- - Preview configurations
295
-
296
- **Reference:** `references/swiftui-review-checklist.md`
297
-
298
- ### 3. Performance Optimization
299
-
300
- **What to Check:**
301
-
302
- - View update optimization
303
- - ForEach identity and performance
304
- - Heavy work in view body
305
- - Image loading and caching
306
- - Memory management
307
- - Background task efficiency
308
- - Layout performance
309
-
310
- **Reference:** `references/performance-review.md`
311
-
312
- ### 4. Security & Safety
313
-
314
- **What to Check:**
315
-
316
- - Force unwrap detection (`!`, `as!`, `try!`)
317
- - Input validation and sanitization
318
- - Sensitive data handling (passwords, tokens)
319
- - Keychain usage for credentials
320
- - Network security (HTTPS, certificate pinning)
321
- - Permission handling
322
- - Logging safety (no sensitive data in logs)
323
-
324
- **Reference:** `references/security-checklist.md`
325
-
326
- ### 5. Architecture & Design
327
-
328
- **What to Check:**
329
-
330
- - MVVM, MVI, TCA, or other architecture compliance
331
- - Dependency injection patterns
332
- - Separation of concerns
333
- - Module boundaries
334
- - Code organization
335
- - Testability
336
- - Documentation quality
337
-
338
- **Reference:** `references/architecture-patterns.md`
339
-
340
- ### 6. Project-Specific Standards
341
-
342
- **What to Check:**
343
-
344
- - `.claude/CLAUDE.md` compliance
345
- - Custom architecture patterns
346
- - Design system usage
347
- - Navigation patterns
348
- - Error handling standards
349
- - Testing requirements
350
-
351
- **Reference:** `references/custom-guidelines.md`
352
-
353
- ## Integration with Existing Skills
354
-
355
- This skill **references** (not duplicates) three foundational skills for domain expertise:
356
-
357
- ### 1. swift-best-practices
358
-
359
- **When to Use:** Reviewing Swift language usage, concurrency patterns, API design, or Swift 6+ migration
360
-
361
- **What it Provides:**
362
-
363
- - Swift 6+ concurrency patterns (actors, async/await, Sendable)
364
- - API design guidelines compliance
365
- - Availability pattern validation
366
- - Breaking changes detection
367
- - Modern Swift feature adoption
368
-
369
- **How to Leverage:**
370
-
371
- - Read `~/.claude/skills/swift-best-practices/references/concurrency.md` for concurrency checks
372
- - Reference `swift6-features.md` for Swift 6 migration patterns
373
- - Use `api-design.md` for naming and parameter validation
374
-
375
- ### 2. swiftui-expert-skill
376
-
377
- **When to Use:** Reviewing SwiftUI views, state management, or UI code
378
-
379
- **What it Provides:**
380
-
381
- - State management patterns (@Observable, @State, @Binding)
382
- - Modern SwiftUI API guidance (iOS 17+, macOS 14+)
383
- - View composition best practices
384
- - Property wrapper selection guide
385
- - Accessibility patterns
386
-
387
- **How to Leverage:**
388
-
389
- - Read `~/.claude/skills/swiftui-expert-skill/references/state-management.md` for property wrapper checks
390
- - Reference `modern-apis.md` for deprecation detection
391
- - Use `view-composition.md` for component structure validation
392
-
393
- ### 3. swiftui-performance-audit
394
-
395
- **When to Use:** Performance concerns identified or mentioned in PR description
396
-
397
- **What it Provides:**
398
-
399
- - View update optimization patterns
400
- - ForEach performance analysis
401
- - Layout thrash detection
402
- - Image handling best practices
403
- - Memory management
404
-
405
- **How to Leverage:**
406
-
407
- - Read `~/.claude/skills/swiftui-performance-audit/SKILL.md` for performance audit workflow
408
- - Reference performance-specific checks when reviewing view code
409
- - Apply recommendations from the skill to performance-sensitive paths
410
-
411
- ### 4. swiftui-ui-patterns
412
-
413
- **When to Use:** Reviewing navigation architecture, sheet/modal routing, TabView setup, theming, async state management, focus handling, or API client patterns
414
-
415
- **What it Provides:**
416
-
417
- - Navigation architecture (route enums, RouterPath, centralized navigationDestination)
418
- - Sheet/modal routing (item-driven sheets, SheetDestination enum)
419
- - TabView with independent per-tab navigation history
420
- - Theming with semantic colors via `@Environment(Theme.self)`
421
- - Async state patterns (`.task(id:)`, LoadState enum, CancellationError handling)
422
- - Focus chaining with FocusField enum and `.onSubmit`
423
- - Lightweight API client pattern (closure-based structs, `.live()` / `.mock()` factories)
424
-
425
- **How to Leverage:**
426
-
427
- - Read `~/.claude/skills/swiftui-ui-patterns/references/navigation.md` for route enum and RouterPath checks
428
- - Reference `sheets-modals.md` for sheet routing validation
429
- - Use `theming.md` for semantic color enforcement
430
-
431
- **Integration Strategy:**
432
-
433
- 1. Load relevant reference files from these skills as needed
434
- 2. Apply their checklist items to the review
435
- 3. Reference their documentation in feedback
436
- 4. Avoid duplicating content—point to their knowledge base
437
-
438
- ## Platform Support
439
-
440
- ### GitHub Pull Requests
441
-
442
- Use `gh` CLI for fetching PR data:
443
-
444
- ```bash
445
- # Get PR details
446
- gh pr view <PR-number>
48
+ ```swift
49
+ let user = repository.currentUser!
50
+ ```
447
51
 
448
- # Get PR diff
449
- gh pr diff <PR-number>
52
+ **Finding**: crashes if `currentUser` is `nil` (e.g., after sign-out race condition).
450
53
 
451
- # List PR files
452
- gh pr view <PR-number> --json files
54
+ **Fix**:
453
55
 
454
- # Get PR comments
455
- gh pr view <PR-number> --json comments
56
+ ```swift
57
+ guard let user = repository.currentUser else {
58
+ logger.error("currentUser nil — aborting login flow")
59
+ return
60
+ }
456
61
  ```
457
62
 
458
- ### GitLab Merge Requests
63
+ ---
459
64
 
460
- Use `glab` CLI for fetching MR data:
65
+ ### Missing @MainActor on UI-bound ViewModel (High)
461
66
 
462
- ```bash
463
- # Get MR details
464
- glab mr view <MR-number>
67
+ **`FeedViewModel.swift:12`** — Current:
465
68
 
466
- # Get MR diff
467
- glab mr diff <MR-number>
69
+ ```swift
70
+ class FeedViewModel: ObservableObject {
71
+ @Published var posts: [Post] = []
468
72
 
469
- # List MR files
470
- glab mr view <MR-number> --json
471
-
472
- # Get MR comments
473
- glab mr note list <MR-number>
73
+ func load() async {
74
+ posts = try? await api.fetchPosts() // ⚠️ mutates @Published off main thread
75
+ }
76
+ }
474
77
  ```
475
78
 
476
- ### Local Git Changes
79
+ **Finding**: `@Published` mutations must happen on the main actor in Swift 6 strict concurrency; this is a data race.
477
80
 
478
- For uncommitted changes or manual review:
81
+ **Fix**:
479
82
 
480
- ```bash
481
- # Get uncommitted changes
482
- git diff
83
+ ```swift
84
+ @MainActor
85
+ @Observable
86
+ final class FeedViewModel {
87
+ var posts: [Post] = []
483
88
 
484
- # Get staged changes
485
- git diff --cached
486
-
487
- # Get changes in specific files
488
- git diff -- path/to/file.swift
489
-
490
- # Get commit diff
491
- git show <commit-hash>
89
+ func load() async throws {
90
+ posts = try await api.fetchPosts() // safe: whole class is @MainActor-isolated
91
+ }
92
+ }
492
93
  ```
493
94
 
494
- ## Output Format
95
+ Also migrate from `ObservableObject`/`@Published` to `@Observable` (iOS 17+) — see `skills/swiftui-expert-skill/references/state-management.md`.
495
96
 
496
- The review report follows this structure:
97
+ ## Output Format
497
98
 
498
- ````markdown
499
- # Code Review Report
99
+ ```
100
+ # Code Review — <scope>
500
101
 
501
102
  ## Summary
103
+ Files: N | Critical: N | High: N | Medium: N | Low: N
502
104
 
503
- - **Files Reviewed**: X
504
- - **Total Findings**: Y
505
- - **Critical**: 0
506
- - **High**: 2
507
- - **Medium**: 5
508
- - **Low**: 3
509
- - **Positive Feedback**: 8
510
- - **Refactoring Suggestions**: 4
511
-
512
- ## Executive Summary
513
-
514
- [Brief overview of the changes and overall code quality]
515
-
516
- ---
517
-
518
- ## Detailed Findings
519
-
520
- ### File: Sources/Features/Login/LoginView.swift
521
-
522
- #### ✅ Positive Feedback
523
-
524
- 1. **Excellent State Management** (line 23)
525
- - Proper use of @Observable for view model
526
- - Clean separation of concerns
527
-
528
- 2. **Modern API Usage** (line 45)
529
- - Using new SwiftUI APIs effectively
530
- - Proper async/await integration
531
-
532
- #### 🔴 Critical Issues
533
-
534
- 1. **Data Race Risk** (line 67)
535
- - **Severity**: Critical
536
- - **Category**: Concurrency
537
- - **Issue**: Mutable state accessed from multiple actors without synchronization
538
- - **Fix**:
539
-
540
- ```swift
541
- // Before
542
- class LoginViewModel {
543
- var isLoading = false
544
- }
545
-
546
- // After
547
- @MainActor
548
- class LoginViewModel: ObservableObject {
549
- @Published var isLoading = false
550
- }
551
- ```
552
-
553
- - **Reference**: swift-best-practices/references/concurrency.md
554
-
555
- #### 🟡 High Priority
556
-
557
- 1. **Force Unwrap Detected** (line 89)
558
- - **Severity**: High
559
- - **Category**: Safety
560
- - **Issue**: Force unwrapping optional can cause crash
561
- - **Fix**:
562
-
563
- ```swift
564
- // Before
565
- let user = fetchUser()!
105
+ ## <Filename.swift>
566
106
 
567
- // After
568
- guard let user = fetchUser() else {
569
- logger.error("Failed to fetch user")
570
- return
571
- }
572
- ```
107
+ [Severity] **<Category>** (line N)
108
+ Current: `<problematic snippet>`
109
+ Fix: <explanation + corrected snippet>
573
110
 
574
- - **Reference**: Project coding standard (.claude/CLAUDE.md:45)
575
-
576
- #### 💡 Refactoring Suggestions
577
-
578
- 1. **Extract Subview** (lines 120-150)
579
- - Consider extracting login form into separate view
580
- - Improves testability and reusability
581
-
582
- ---
111
+ ## Positive Observations
112
+ ...
583
113
 
584
114
  ## Prioritized Action Items
585
-
586
- ### Must Fix (Critical/High)
587
-
588
- 1. [ ] Fix data race in LoginViewModel.swift:67
589
- 2. [ ] Remove force unwrap in LoginView.swift:89
590
-
591
- ### Should Fix (Medium)
592
-
593
- 1. [ ] Add documentation to public APIs
594
- 2. [ ] Improve error handling in NetworkService.swift
595
-
596
- ### Consider (Low)
597
-
598
- 1. [ ] Refactor login form into separate view
599
- 2. [ ] Add more unit tests for edge cases
600
-
601
- ---
602
-
603
- ## Positive Patterns Observed
604
-
605
- - Excellent use of @Observable for state management
606
- - Consistent adherence to project architecture (MVVM)
607
- - Comprehensive accessibility support
608
- - Strong error handling in most areas
609
- - Good test coverage for core functionality
610
-
611
- ## References
612
-
613
- - [Swift Best Practices](~/.claude/skills/swift-best-practices/SKILL.md)
614
- - [SwiftUI Expert Guide](~/.claude/skills/swiftui-expert-skill/SKILL.md)
615
- - [Project Coding Standards](.claude/CLAUDE.md)
616
- ````
617
-
618
- ## How to Use
619
-
620
- ### Example 1: Review Specific File
621
-
622
- ```
623
- User: "Review UserProfileView.swift"
624
-
625
- Steps:
626
- 1. Read .claude/CLAUDE.md for project standards
627
- 2. Read UserProfileView.swift
628
- 3. Run multi-layer analysis
629
- 4. Provide structured feedback with severity levels and positive feedback
115
+ - [Must fix] ...
116
+ - [Should fix] ...
117
+ - [Consider] ...
630
118
  ```
631
119
 
632
- ### Example 2: Review Git Changes
633
-
634
- ```
635
- User: "Review my uncommitted changes"
636
-
637
- Steps:
638
- 1. Read .claude/CLAUDE.md
639
- 2. Execute `git diff` to get changes
640
- 3. Identify modified files
641
- 4. Run analysis on each file
642
- 5. Generate comprehensive review report
643
- ```
120
+ Full templates and severity classification: `references/feedback-templates.md`.
644
121
 
645
- ### Example 3: Review Pull Request
122
+ ## Companion Skills
646
123
 
647
- ```
648
- User: "Review PR #123"
649
-
650
- Steps:
651
- 1. Read .claude/CLAUDE.md
652
- 2. Execute `gh pr view 123` and `gh pr diff 123`
653
- 3. Identify changed files
654
- 4. Read affected files for context
655
- 5. Run multi-layer analysis
656
- 6. Generate report with file:line references
657
- ```
124
+ Full reference tables (all files, when to consult each): `references/companion-skills.md`.
658
125
 
659
- ### Example 4: Review Against Custom Guidelines
126
+ | Skill | Use for |
127
+ | ------------------------------ | ---------------------------------------------------------- |
128
+ | `skills/swiftui-expert-skill/` | SwiftUI state, Liquid Glass, macOS patterns, accessibility |
129
+ | `skills/swift-concurrency/` | Actors, Sendable, Swift 6 migration, async/await |
130
+ | `skills/swift-testing/` | Swift Testing framework, test doubles, snapshots |
131
+ | `skills/swift-expert/` | Swift 6+ patterns, protocols, memory, SPM |
132
+ | `skills/swiftui-ui-patterns/` | Navigation, sheets, theming, async state, grids |
660
133
 
661
- ```
662
- User: "Review LoginViewModel.swift against our coding standards"
663
-
664
- Steps:
665
- 1. Read .claude/CLAUDE.md
666
- 2. Read related docs (DependencyInjection-Architecture.md)
667
- 3. Read LoginViewModel.swift
668
- 4. Validate against project-specific patterns
669
- 5. Provide detailed feedback comparing with standards
670
- ```
134
+ ## Platform Commands
671
135
 
672
- ### Example 5: Review Multiple Files
673
-
674
- ```
675
- User: "Review all ViewModels in the Features folder"
676
-
677
- Steps:
678
- 1. Read .claude/CLAUDE.md
679
- 2. Find all *ViewModel.swift files in Features/
680
- 3. Analyze each against architecture patterns
681
- 4. Provide file-by-file review
682
- 5. Summarize common patterns and issues across all files
683
- ```
684
-
685
- ### Example 6: Review Navigation / Routing Code
686
-
687
- ```
688
- User: "Review our navigation setup and routing code"
689
-
690
- Steps:
691
- 1. Read .claude/CLAUDE.md for project navigation patterns
692
- 2. Read router/coordinator files (RouterPath, AppCoordinator, TabRouter)
693
- 3. Read root views that set up NavigationStack and TabView
694
- 4. Run navigation architecture checks:
695
- - Route destinations use typed Hashable enum (not String/Int)
696
- - RouterPath @Observable owns path (not ad-hoc @State)
697
- - Single centralized .navigationDestination per stack
698
- - .sheet(item:) preferred over .sheet(isPresented:) when model selected
699
- - Multiple sheets use SheetDestination enum (not multiple booleans)
700
- - Each tab has independent RouterPath (not shared)
701
- - .onOpenURL at app root, not scattered in feature views
702
- 5. Run async state checks:
703
- - .task(id:) for input-driven async work
704
- - CancellationError silenced
705
- - LoadState<T> enum instead of multiple booleans
706
- 6. Generate report with navigation-specific findings
136
+ ```bash
137
+ # GitHub PR
138
+ gh pr diff <n>
139
+ gh pr view <n> --json files,comments
140
+
141
+ # GitLab MR
142
+ glab mr diff <n>
143
+ glab mr view <n> --json
144
+
145
+ # Local changes
146
+ git diff # unstaged
147
+ git diff --cached # staged
148
+ git diff HEAD~1 # last commit
149
+ git diff -- path/to/file.swift
707
150
  ```
708
151
 
709
- ## Resources
710
-
711
- This skill includes the following reference materials:
712
-
713
- ### Core References
714
-
715
- - **review-workflow.md**: Detailed step-by-step review process, git commands, and diff parsing strategies
716
- - **feedback-templates.md**: Templates for positive/negative comments, severity classification guidelines
717
-
718
- ### Quality Checklists
719
-
720
- - **swift-quality-checklist.md**: Swift 6+ concurrency, error handling, optionals, access control, naming
721
- - **swiftui-review-checklist.md**: Property wrappers, state management, modern APIs, view composition
722
- - **performance-review.md**: View updates, ForEach optimization, layout efficiency, resource management
723
- - **security-checklist.md**: Input validation, sensitive data, keychain, network security
724
-
725
- ### Architecture & Customization
726
-
727
- - **architecture-patterns.md**: MVVM, MVI, TCA patterns, dependency injection, testing strategies
728
- - **custom-guidelines.md**: How to read and parse .claude/CLAUDE.md and project-specific standards
729
-
730
- ## Best Practices
731
-
732
- 1. **Always Read Project Guidelines First**
733
- - Load `.claude/CLAUDE.md` before starting review
734
- - Understand project-specific patterns and rules
735
- - Merge project standards with Apple guidelines
736
-
737
- 2. **Provide Balanced Feedback**
738
- - Include positive feedback for good practices
739
- - Don't just criticize—acknowledge what's done well
740
- - Suggest improvements, not just problems
741
-
742
- 3. **Be Specific and Actionable**
743
- - Include exact file:line references
744
- - Provide code examples for fixes
745
- - Explain _why_ something is an issue
746
- - Link to relevant documentation
747
-
748
- 4. **Prioritize by Severity**
749
- - Critical: Must fix before merge (security, crashes, data races)
750
- - High: Should fix before merge (anti-patterns, performance issues)
751
- - Medium: Address soon (code quality, documentation)
752
- - Low: Consider for future (style, refactoring suggestions)
753
-
754
- 5. **Leverage Existing Skills**
755
- - Reference swift-best-practices for language patterns
756
- - Use swiftui-expert-skill for UI code
757
- - Apply swiftui-performance-audit for performance concerns
758
- - Don't duplicate their content—point to their knowledge
759
-
760
- 6. **Focus on Education**
761
- - Explain the reasoning behind feedback
762
- - Link to learning resources
763
- - Help developers understand best practices
764
- - Foster continuous improvement
765
-
766
- ## Limitations
767
-
768
- - Cannot execute code or run tests (can only analyze statically)
769
- - Cannot access external systems or APIs
770
- - Limited to analyzing code provided or accessible via git
771
- - Cannot detect runtime issues that require execution
772
- - Performance analysis is based on patterns, not profiling data
773
-
774
- For runtime analysis, recommend using Instruments or other profiling tools.
775
-
776
- ## Version
777
-
778
- **Version**: 1.1.1
779
- **Last Updated**: 2026-03-16
780
- **Compatible with**: Swift 6+, SwiftUI (iOS 17+, macOS 14+, watchOS 10+, tvOS 17+, visionOS 1+)
152
+ ## Reference Files
153
+
154
+ - `references/review-workflow.md` detailed process, diff parsing, git commands
155
+ - `references/feedback-templates.md` — output templates, severity classification
156
+ - `references/swift-quality-checklist.md` — Swift 6+, concurrency, optionals, naming
157
+ - `references/swiftui-review-checklist.md` — property wrappers, state, modern APIs
158
+ - `references/performance-review.md` view optimization, ForEach, resource management
159
+ - `references/security-checklist.md` input validation, Keychain, network security
160
+ - `references/architecture-patterns.md` — MVVM/MVI/TCA, DI, testability
161
+ - `references/custom-guidelines.md` — parsing `.claude/CLAUDE.md`
162
+ - `references/companion-skills.md` — full companion skill tables