swift-code-reviewer-skill 1.0.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.
@@ -0,0 +1,666 @@
1
+ # Feedback Templates
2
+
3
+ This document provides templates for code review feedback, including positive acknowledgments, issue reports across all severity levels, and refactoring suggestions. Use these templates to ensure consistent, constructive, and actionable code reviews.
4
+
5
+ ---
6
+
7
+ ## 1. Severity Classification
8
+
9
+ ### Severity Levels
10
+
11
+ | Severity | Description | Response Time | Examples |
12
+ |----------|-------------|---------------|----------|
13
+ | **Critical** | Security vulnerabilities, crashes, data loss, data races | Must fix before merge | Force unwraps with user data, data races, SQL injection, exposed credentials |
14
+ | **High** | Performance issues, anti-patterns, major architecture violations | Should fix before merge | Blocking main thread, memory leaks, O(n²) algorithms, improper concurrency |
15
+ | **Medium** | Code quality issues, missing documentation, minor violations | Fix in current sprint | Complex methods, code duplication, missing tests, accessibility gaps |
16
+ | **Low** | Style inconsistencies, suggestions, minor improvements | Consider for future | Naming improvements, refactoring opportunities, minor optimizations |
17
+
18
+ ### Classification Guidelines
19
+
20
+ **Critical Severity:**
21
+ - Can cause app crashes
22
+ - Security vulnerabilities (data leaks, injection attacks)
23
+ - Data races or concurrency issues
24
+ - Data corruption or loss
25
+
26
+ **High Severity:**
27
+ - Significant performance degradation
28
+ - Memory leaks or excessive memory usage
29
+ - Major architecture violations
30
+ - Breaking API changes without migration
31
+
32
+ **Medium Severity:**
33
+ - Code complexity (cyclomatic complexity > 10)
34
+ - Missing error handling
35
+ - Incomplete test coverage
36
+ - Minor accessibility issues
37
+ - Missing documentation for public APIs
38
+
39
+ **Low Severity:**
40
+ - Style guide violations (spacing, naming)
41
+ - Opportunities for refactoring
42
+ - Minor optimizations
43
+ - Suggestions for improvement
44
+
45
+ ---
46
+
47
+ ## 2. Positive Feedback Templates
48
+
49
+ ### 2.1 Modern API Adoption
50
+
51
+ **Template:**
52
+ ```markdown
53
+ ✅ **Excellent Modern API Usage** ([file]:[line])
54
+ - [Specific modern API or pattern used]
55
+ - Benefits: [List benefits: better performance, cleaner code, etc.]
56
+ - Great example for other developers to follow
57
+ ```
58
+
59
+ **Examples:**
60
+ ```markdown
61
+ ✅ **Excellent Modern API Usage** (LoginView.swift:45)
62
+ - Using @Observable instead of ObservableObject for iOS 17+
63
+ - Benefits: Cleaner syntax, better performance, automatic dependency tracking
64
+ - Great example for other developers to follow
65
+ ```
66
+
67
+ ```markdown
68
+ ✅ **Outstanding Async/Await Implementation** (NetworkService.swift:23)
69
+ - Properly structured async operations with error handling
70
+ - Uses TaskGroup for concurrent operations
71
+ - Excellent concurrency safety with MainActor isolation
72
+ ```
73
+
74
+ ### 2.2 Architecture Excellence
75
+
76
+ **Template:**
77
+ ```markdown
78
+ ✅ **Strong Architecture Adherence** ([file]:[line])
79
+ - [Specific pattern or principle followed]
80
+ - Clear separation of concerns
81
+ - Easy to test and maintain
82
+ ```
83
+
84
+ **Examples:**
85
+ ```markdown
86
+ ✅ **Strong Architecture Adherence** (UserViewModel.swift:12)
87
+ - Perfect MVVM implementation with dependency injection
88
+ - Clear separation between business logic and presentation
89
+ - All dependencies are protocol-based for easy testing
90
+ ```
91
+
92
+ ```markdown
93
+ ✅ **Excellent Repository Pattern** (UserRepository.swift:34)
94
+ - Well-structured caching strategy
95
+ - Proper error handling at all levels
96
+ - Clear abstraction over data sources
97
+ ```
98
+
99
+ ### 2.3 Code Quality
100
+
101
+ **Template:**
102
+ ```markdown
103
+ ✅ **High Code Quality** ([file]:[line])
104
+ - [Specific quality aspect]
105
+ - [Impact on codebase]
106
+ ```
107
+
108
+ **Examples:**
109
+ ```markdown
110
+ ✅ **High Code Quality** (ValidationService.swift:56)
111
+ - Comprehensive input validation
112
+ - Clear, descriptive error messages
113
+ - Excellent test coverage (95%)
114
+ ```
115
+
116
+ ```markdown
117
+ ✅ **Outstanding Error Handling** (LoginUseCase.swift:78)
118
+ - Typed throws for specific error cases
119
+ - Graceful degradation on failures
120
+ - Helpful error messages for users
121
+ ```
122
+
123
+ ### 2.4 Performance Optimization
124
+
125
+ **Template:**
126
+ ```markdown
127
+ ✅ **Great Performance Optimization** ([file]:[line])
128
+ - [Specific optimization]
129
+ - Impact: [Performance improvement]
130
+ ```
131
+
132
+ **Examples:**
133
+ ```markdown
134
+ ✅ **Great Performance Optimization** (ItemListView.swift:123)
135
+ - Using LazyVStack for efficient rendering
136
+ - Stable ForEach identity for smooth animations
137
+ - Equatable conformance reduces unnecessary updates
138
+ ```
139
+
140
+ ### 2.5 Accessibility Support
141
+
142
+ **Template:**
143
+ ```markdown
144
+ ✅ **Excellent Accessibility Support** ([file]:[line])
145
+ - Comprehensive accessibility labels and hints
146
+ - Dynamic Type support
147
+ - VoiceOver friendly
148
+ ```
149
+
150
+ **Examples:**
151
+ ```markdown
152
+ ✅ **Excellent Accessibility Support** (ProfileView.swift:89)
153
+ - Clear accessibility labels for all interactive elements
154
+ - Proper trait assignment (.isButton, .isHeader)
155
+ - Adapts layout for large text sizes
156
+ ```
157
+
158
+ ### 2.6 Security Awareness
159
+
160
+ **Template:**
161
+ ```markdown
162
+ ✅ **Strong Security Practices** ([file]:[line])
163
+ - [Specific security measure]
164
+ - Protects against: [Security threat]
165
+ ```
166
+
167
+ **Examples:**
168
+ ```markdown
169
+ ✅ **Strong Security Practices** (AuthService.swift:34)
170
+ - Using Keychain for credential storage
171
+ - Biometric authentication implemented
172
+ - No sensitive data in logs
173
+ ```
174
+
175
+ ---
176
+
177
+ ## 3. Issue Report Templates
178
+
179
+ ### 3.1 Critical Issues
180
+
181
+ **Template:**
182
+ ```markdown
183
+ 🔴 **[Issue Title]** ([file]:[line])
184
+ **Severity**: Critical
185
+ **Category**: [Concurrency/Security/Safety/etc.]
186
+
187
+ **Issue**: [Clear description of the problem]
188
+
189
+ **Risk**: [What could happen - crashes, data loss, security breach]
190
+
191
+ **Current Code:**
192
+ ```swift
193
+ [Show problematic code]
194
+ ```
195
+
196
+ **Recommended Fix:**
197
+ ```swift
198
+ [Show corrected code]
199
+ ```
200
+
201
+ **Reference**: [Link to documentation or best practice guide]
202
+ ```
203
+
204
+ **Examples:**
205
+
206
+ ```markdown
207
+ 🔴 **Data Race Risk** (LoginViewModel.swift:45)
208
+ **Severity**: Critical
209
+ **Category**: Concurrency
210
+
211
+ **Issue**: Mutable state accessed from multiple threads without synchronization
212
+
213
+ **Risk**: Can cause data corruption, crashes, or undefined behavior when multiple threads access `isLoading` simultaneously
214
+
215
+ **Current Code:**
216
+ ```swift
217
+ class LoginViewModel {
218
+ var isLoading = false // ❌ Can be accessed from any thread
219
+
220
+ func login() {
221
+ Task {
222
+ isLoading = true // ❌ Potential data race
223
+ // Login logic
224
+ isLoading = false
225
+ }
226
+ }
227
+ }
228
+ ```
229
+
230
+ **Recommended Fix:**
231
+ ```swift
232
+ @MainActor
233
+ class LoginViewModel: ObservableObject {
234
+ @Published var isLoading = false // ✅ MainActor-isolated
235
+
236
+ func login() async {
237
+ isLoading = true
238
+ // Login logic
239
+ isLoading = false
240
+ }
241
+ }
242
+ ```
243
+
244
+ **Reference**: swift-best-practices/references/concurrency.md
245
+ ```
246
+
247
+ ```markdown
248
+ 🔴 **Force Unwrap Can Crash** (UserDetailView.swift:89)
249
+ **Severity**: Critical
250
+ **Category**: Safety
251
+
252
+ **Issue**: Force unwrapping optional user data that may be nil
253
+
254
+ **Risk**: App will crash if user data is nil (e.g., network failure, cache miss)
255
+
256
+ **Current Code:**
257
+ ```swift
258
+ let user = userRepository.currentUser! // ❌ Can crash
259
+ let name = user.name!
260
+ ```
261
+
262
+ **Recommended Fix:**
263
+ ```swift
264
+ guard let user = userRepository.currentUser else {
265
+ logger.error("No current user")
266
+ return
267
+ }
268
+ let name = user.name ?? "Unknown"
269
+ ```
270
+
271
+ **Reference**: Project coding standard (.claude/CLAUDE.md:45)
272
+ ```
273
+
274
+ ### 3.2 High Priority Issues
275
+
276
+ **Template:**
277
+ ```markdown
278
+ 🟡 **[Issue Title]** ([file]:[line])
279
+ **Severity**: High
280
+ **Category**: [Performance/Architecture/etc.]
281
+
282
+ **Issue**: [Description]
283
+
284
+ **Impact**: [Performance degradation, maintainability, etc.]
285
+
286
+ **Current Code:**
287
+ ```swift
288
+ [Problematic code]
289
+ ```
290
+
291
+ **Recommended Fix:**
292
+ ```swift
293
+ [Better approach]
294
+ ```
295
+
296
+ **Why This Matters**: [Explanation]
297
+ ```
298
+
299
+ **Examples:**
300
+
301
+ ```markdown
302
+ 🟡 **Blocking Main Thread** (ImageLoader.swift:56)
303
+ **Severity**: High
304
+ **Category**: Performance
305
+
306
+ **Issue**: Synchronous image loading blocks the main thread
307
+
308
+ **Impact**: UI freezes during image download, poor user experience
309
+
310
+ **Current Code:**
311
+ ```swift
312
+ if let data = try? Data(contentsOf: imageURL), // ❌ Blocks main thread
313
+ let image = UIImage(data: data) {
314
+ self.image = image
315
+ }
316
+ ```
317
+
318
+ **Recommended Fix:**
319
+ ```swift
320
+ AsyncImage(url: imageURL) { phase in // ✅ Async loading
321
+ switch phase {
322
+ case .success(let image):
323
+ image.resizable().aspectRatio(contentMode: .fit)
324
+ case .failure:
325
+ Image(systemName: "photo")
326
+ case .empty:
327
+ ProgressView()
328
+ @unknown default:
329
+ EmptyView()
330
+ }
331
+ }
332
+ ```
333
+
334
+ **Why This Matters**: Blocking the main thread causes the UI to freeze, creating a poor user experience. AsyncImage handles loading asynchronously with built-in caching.
335
+ ```
336
+
337
+ ### 3.3 Medium Priority Issues
338
+
339
+ **Template:**
340
+ ```markdown
341
+ 🟠 **[Issue Title]** ([file]:[line])
342
+ **Severity**: Medium
343
+ **Category**: [Code Quality/Documentation/etc.]
344
+
345
+ **Issue**: [Description]
346
+
347
+ **Suggestion**: [How to improve]
348
+
349
+ **Benefits**: [Why this improvement helps]
350
+ ```
351
+
352
+ **Examples:**
353
+
354
+ ```markdown
355
+ 🟠 **Missing Documentation** (AuthService.swift:12)
356
+ **Severity**: Medium
357
+ **Category**: Documentation
358
+
359
+ **Issue**: Public protocol methods lack documentation
360
+
361
+ **Suggestion**: Add DocC comments explaining parameters, return values, and potential errors
362
+
363
+ **Benefits**:
364
+ - Improves code discoverability
365
+ - Helps other developers understand API usage
366
+ - Generates better documentation
367
+
368
+ **Example:**
369
+ ```swift
370
+ /// Authenticates a user with email and password
371
+ ///
372
+ /// - Parameters:
373
+ /// - email: User's email address
374
+ /// - password: User's password
375
+ /// - Returns: Authenticated user object
376
+ /// - Throws: `LoginError` if credentials are invalid or network fails
377
+ func login(email: String, password: String) async throws -> User
378
+ ```
379
+ ```
380
+
381
+ ### 3.4 Low Priority Issues
382
+
383
+ **Template:**
384
+ ```markdown
385
+ 🔵 **[Suggestion Title]** ([file]:[line])
386
+ **Severity**: Low
387
+ **Category**: [Style/Refactoring/etc.]
388
+
389
+ **Observation**: [What you noticed]
390
+
391
+ **Suggestion**: [Optional improvement]
392
+
393
+ **Note**: This is a minor suggestion and not required
394
+ ```
395
+
396
+ **Examples:**
397
+
398
+ ```markdown
399
+ 🔵 **Consider More Descriptive Name** (UserViewModel.swift:78)
400
+ **Severity**: Low
401
+ **Category**: Style
402
+
403
+ **Observation**: Method name `process()` is vague
404
+
405
+ **Suggestion**: Consider renaming to `processUserData()` or `transformUsersForDisplay()`
406
+
407
+ **Note**: This is a minor suggestion to improve code clarity
408
+ ```
409
+
410
+ ---
411
+
412
+ ## 4. Refactoring Suggestion Templates
413
+
414
+ ### 4.1 Extract Subview
415
+
416
+ **Template:**
417
+ ```markdown
418
+ 💡 **Consider Extracting Subview** ([file]:[lines])
419
+
420
+ **Observation**: View body is lengthy and could be broken down
421
+
422
+ **Suggestion**: Extract [specific section] into a separate view component
423
+
424
+ **Benefits**:
425
+ - Improved readability
426
+ - Better testability
427
+ - Potential reusability
428
+
429
+ **Example:**
430
+ ```swift
431
+ // Extract this section into LoginFormView
432
+ private struct LoginFormView: View {
433
+ // Extracted view
434
+ }
435
+ ```
436
+ ```
437
+
438
+ ### 4.2 Simplify Logic
439
+
440
+ **Template:**
441
+ ```markdown
442
+ 💡 **Simplify Complex Logic** ([file]:[line])
443
+
444
+ **Observation**: [What makes it complex]
445
+
446
+ **Suggestion**: [How to simplify]
447
+
448
+ **Benefits**: Easier to understand and maintain
449
+
450
+ **Example:**
451
+ ```swift
452
+ // Current approach
453
+ [Current code]
454
+
455
+ // Simplified approach
456
+ [Simpler code]
457
+ ```
458
+ ```
459
+
460
+ ### 4.3 Extract Reusable Component
461
+
462
+ **Template:**
463
+ ```markdown
464
+ 💡 **Potential Reusable Component** ([file]:[line])
465
+
466
+ **Observation**: Similar pattern used in [other files]
467
+
468
+ **Suggestion**: Extract into shared component in design system
469
+
470
+ **Benefits**:
471
+ - Consistency across app
472
+ - Single source of truth
473
+ - Easier to update globally
474
+ ```
475
+
476
+ ### 4.4 Performance Optimization
477
+
478
+ **Template:**
479
+ ```markdown
480
+ 💡 **Performance Optimization Opportunity** ([file]:[line])
481
+
482
+ **Observation**: [Current approach and its limitation]
483
+
484
+ **Suggestion**: [Optimized approach]
485
+
486
+ **Expected Impact**: [Performance improvement]
487
+
488
+ **Trade-offs**: [Any downsides to consider]
489
+ ```
490
+
491
+ ---
492
+
493
+ ## 5. Complete Review Report Template
494
+
495
+ ```markdown
496
+ # Code Review Report
497
+
498
+ ## Summary
499
+ - **Files Reviewed**: [X]
500
+ - **Total Findings**: [Y]
501
+ - **Critical**: [N]
502
+ - **High**: [N]
503
+ - **Medium**: [N]
504
+ - **Low**: [N]
505
+ - **Positive Feedback**: [N]
506
+ - **Refactoring Suggestions**: [N]
507
+
508
+ ## Executive Summary
509
+ [Brief overview of the changes and overall code quality assessment]
510
+
511
+ ---
512
+
513
+ ## Detailed Findings
514
+
515
+ ### File: [FilePath]
516
+
517
+ #### ✅ Positive Feedback
518
+
519
+ 1. **[Positive Item Title]** (line [N])
520
+ - [Details]
521
+
522
+ #### 🔴 Critical Issues
523
+
524
+ 1. **[Issue Title]** (line [N])
525
+ - **Severity**: Critical
526
+ - **Category**: [Category]
527
+ - **Issue**: [Description]
528
+ - **Fix**: [Solution]
529
+
530
+ #### 🟡 High Priority
531
+
532
+ 1. **[Issue Title]** (line [N])
533
+ - **Severity**: High
534
+ - **Category**: [Category]
535
+ - **Issue**: [Description]
536
+ - **Fix**: [Solution]
537
+
538
+ #### 🟠 Medium Priority
539
+
540
+ 1. **[Issue Title]** (line [N])
541
+ - **Severity**: Medium
542
+ - **Category**: [Category]
543
+ - **Issue**: [Description]
544
+ - **Suggestion**: [Improvement]
545
+
546
+ #### 🔵 Low Priority
547
+
548
+ 1. **[Suggestion Title]** (line [N])
549
+ - **Severity**: Low
550
+ - **Category**: [Category]
551
+ - **Observation**: [What was noticed]
552
+ - **Suggestion**: [Optional improvement]
553
+
554
+ #### 💡 Refactoring Suggestions
555
+
556
+ 1. **[Suggestion Title]** (lines [N-M])
557
+ - [Description and benefits]
558
+
559
+ ---
560
+
561
+ ## Prioritized Action Items
562
+
563
+ ### Must Fix (Critical/High)
564
+ - [ ] [Critical item 1]
565
+ - [ ] [Critical item 2]
566
+ - [ ] [High priority item 1]
567
+
568
+ ### Should Fix (Medium)
569
+ - [ ] [Medium item 1]
570
+ - [ ] [Medium item 2]
571
+
572
+ ### Consider (Low)
573
+ - [ ] [Low priority item 1]
574
+ - [ ] [Refactoring suggestion 1]
575
+
576
+ ---
577
+
578
+ ## Positive Patterns Observed
579
+ - [Positive pattern 1]
580
+ - [Positive pattern 2]
581
+ - [Positive pattern 3]
582
+
583
+ ## References
584
+ - [Swift Best Practices](~/.claude/skills/swift-best-practices/SKILL.md)
585
+ - [SwiftUI Expert Guide](~/.claude/skills/swiftui-expert-skill/SKILL.md)
586
+ - [Project Coding Standards](.claude/CLAUDE.md)
587
+
588
+ ---
589
+
590
+ ## Overall Assessment
591
+
592
+ **Code Quality**: [Excellent/Good/Fair/Needs Improvement]
593
+
594
+ **Architecture**: [Well-designed/Acceptable/Needs refactoring]
595
+
596
+ **Testing**: [Comprehensive/Adequate/Insufficient]
597
+
598
+ **Recommendation**: [Approve/Approve with comments/Request changes]
599
+
600
+ **Additional Notes**: [Any other observations or recommendations]
601
+ ```
602
+
603
+ ---
604
+
605
+ ## 6. Best Practices for Feedback
606
+
607
+ ### Do's
608
+ ✅ Be specific with file and line numbers
609
+ ✅ Provide code examples for fixes
610
+ ✅ Explain *why* something is an issue
611
+ ✅ Balance criticism with positive feedback
612
+ ✅ Prioritize by severity
613
+ ✅ Link to relevant documentation
614
+ ✅ Suggest improvements, not just problems
615
+ ✅ Be constructive and respectful
616
+
617
+ ### Don'ts
618
+ ❌ Be vague ("this could be better")
619
+ ❌ Only provide criticism (no positive feedback)
620
+ ❌ Nitpick style without impact
621
+ ❌ Use harsh or dismissive language
622
+ ❌ Suggest fixes without explaining why
623
+ ❌ Ignore project-specific standards
624
+ ❌ Review without reading the full context
625
+
626
+ ---
627
+
628
+ ## 7. Tone and Language Guidelines
629
+
630
+ ### Constructive Tone
631
+
632
+ ❌ **Poor Tone:**
633
+ "This code is terrible. You don't know how to use Swift properly."
634
+
635
+ ✅ **Good Tone:**
636
+ "This approach can lead to data races. Consider using @MainActor to ensure thread safety."
637
+
638
+ ### Suggest, Don't Demand
639
+
640
+ ❌ **Demanding:**
641
+ "You must change this immediately."
642
+
643
+ ✅ **Suggesting:**
644
+ "Consider refactoring this for better maintainability."
645
+
646
+ ### Acknowledge Good Work
647
+
648
+ ❌ **Ignoring Positives:**
649
+ [Only lists issues]
650
+
651
+ ✅ **Balanced:**
652
+ "Great job on the error handling! I noticed one area where we can improve performance..."
653
+
654
+ ### Educational Approach
655
+
656
+ ❌ **Just Pointing Out:**
657
+ "This is wrong."
658
+
659
+ ✅ **Educational:**
660
+ "This can cause memory leaks. When using closures with self, use [weak self] to avoid retain cycles. Here's an example..."
661
+
662
+ ---
663
+
664
+ ## Version
665
+ **Last Updated**: 2026-02-10
666
+ **Version**: 1.0.0