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.
- package/CHANGELOG.md +214 -0
- package/CONTRIBUTING.md +271 -0
- package/LICENSE +21 -0
- package/README.md +536 -0
- package/SKILL.md +690 -0
- package/bin/install.js +173 -0
- package/package.json +41 -0
- package/references/architecture-patterns.md +862 -0
- package/references/custom-guidelines.md +852 -0
- package/references/feedback-templates.md +666 -0
- package/references/performance-review.md +914 -0
- package/references/review-workflow.md +1131 -0
- package/references/security-checklist.md +781 -0
- package/references/swift-quality-checklist.md +928 -0
- package/references/swiftui-review-checklist.md +909 -0
package/SKILL.md
ADDED
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
---
|
|
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, 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.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Swift/SwiftUI Code Review Skill
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
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.
|
|
11
|
+
|
|
12
|
+
### Key Capabilities
|
|
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
|
|
19
|
+
|
|
20
|
+
## When to Use This Skill
|
|
21
|
+
|
|
22
|
+
Use this skill when you need to:
|
|
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
|
|
31
|
+
|
|
32
|
+
**Trigger patterns:**
|
|
33
|
+
- "Review this PR"
|
|
34
|
+
- "Review [filename].swift"
|
|
35
|
+
- "Review my changes"
|
|
36
|
+
- "Code review for [component]"
|
|
37
|
+
- "Check if this follows our coding standards"
|
|
38
|
+
- "Review against .claude/CLAUDE.md"
|
|
39
|
+
|
|
40
|
+
## Review Workflow
|
|
41
|
+
|
|
42
|
+
The skill follows a **four-phase workflow** to ensure comprehensive and actionable feedback:
|
|
43
|
+
|
|
44
|
+
### Phase 1: Context Gathering
|
|
45
|
+
|
|
46
|
+
**Objective**: Understand the project context and scope of review
|
|
47
|
+
|
|
48
|
+
1. **Read Project Guidelines**
|
|
49
|
+
- Load `.claude/CLAUDE.md` if it exists in the repository
|
|
50
|
+
- Read related architecture documents (e.g., `DependencyInjection-Architecture.md`, `Design System Structure.md`)
|
|
51
|
+
- Extract custom coding standards, patterns, and rules
|
|
52
|
+
|
|
53
|
+
2. **Identify Review Scope**
|
|
54
|
+
- Determine files to review:
|
|
55
|
+
- User-specified files
|
|
56
|
+
- Git diff (uncommitted or PR/MR changes)
|
|
57
|
+
- Modified files in a specific directory
|
|
58
|
+
- Categorize changes by type (UI, logic, tests, configuration)
|
|
59
|
+
|
|
60
|
+
3. **Gather File Context**
|
|
61
|
+
- Read all files that will be reviewed
|
|
62
|
+
- Understand the broader context (related files, dependencies)
|
|
63
|
+
- Identify the purpose and role of each component
|
|
64
|
+
|
|
65
|
+
### Phase 2: Automated Analysis
|
|
66
|
+
|
|
67
|
+
**Objective**: Run parallel checks across multiple quality dimensions
|
|
68
|
+
|
|
69
|
+
Execute checks across **six core categories**:
|
|
70
|
+
|
|
71
|
+
#### 1. Swift Best Practices
|
|
72
|
+
Reference: `swift-best-practices` skill knowledge base
|
|
73
|
+
|
|
74
|
+
- **Concurrency Safety**
|
|
75
|
+
- Actor isolation correctness
|
|
76
|
+
- MainActor usage for UI code
|
|
77
|
+
- Sendable conformance
|
|
78
|
+
- Data race prevention
|
|
79
|
+
- Async/await patterns
|
|
80
|
+
|
|
81
|
+
- **API Design**
|
|
82
|
+
- Naming conventions (Swift API Design Guidelines)
|
|
83
|
+
- Parameter labels clarity
|
|
84
|
+
- Return type appropriateness
|
|
85
|
+
- Error handling (typed throws)
|
|
86
|
+
|
|
87
|
+
- **Language Features**
|
|
88
|
+
- Availability attributes for new APIs
|
|
89
|
+
- Migration to Swift 6 features
|
|
90
|
+
- Avoiding deprecated patterns
|
|
91
|
+
- Proper use of optionals
|
|
92
|
+
|
|
93
|
+
#### 2. SwiftUI Quality
|
|
94
|
+
Reference: `swiftui-expert-skill` knowledge base
|
|
95
|
+
|
|
96
|
+
- **State Management**
|
|
97
|
+
- Correct property wrapper selection (@Observable, @State, @Binding, @Environment)
|
|
98
|
+
- State ownership and data flow
|
|
99
|
+
- Avoiding unnecessary state
|
|
100
|
+
- View model patterns
|
|
101
|
+
|
|
102
|
+
- **Modern API Usage**
|
|
103
|
+
- Replace deprecated APIs with modern equivalents
|
|
104
|
+
- Use latest SwiftUI features (iOS 17+, macOS 14+)
|
|
105
|
+
- Proper use of view modifiers
|
|
106
|
+
- Composition over inheritance
|
|
107
|
+
|
|
108
|
+
- **View Composition**
|
|
109
|
+
- View extraction appropriateness
|
|
110
|
+
- Component reusability
|
|
111
|
+
- View hierarchy depth
|
|
112
|
+
- Subview organization
|
|
113
|
+
|
|
114
|
+
- **Accessibility**
|
|
115
|
+
- Accessibility labels and hints
|
|
116
|
+
- VoiceOver support
|
|
117
|
+
- Dynamic Type support
|
|
118
|
+
- Keyboard navigation
|
|
119
|
+
|
|
120
|
+
#### 3. Performance
|
|
121
|
+
Reference: `swiftui-performance-audit` knowledge base
|
|
122
|
+
|
|
123
|
+
- **View Optimization**
|
|
124
|
+
- Unnecessary view updates
|
|
125
|
+
- Heavy computation in body
|
|
126
|
+
- Equatable conformance for view models
|
|
127
|
+
- Lazy loading patterns
|
|
128
|
+
|
|
129
|
+
- **List Performance**
|
|
130
|
+
- ForEach identity stability
|
|
131
|
+
- Cell reuse patterns
|
|
132
|
+
- Scroll performance
|
|
133
|
+
- Large dataset handling
|
|
134
|
+
|
|
135
|
+
- **Layout Efficiency**
|
|
136
|
+
- Layout thrash detection
|
|
137
|
+
- GeometryReader overuse
|
|
138
|
+
- Frame calculations
|
|
139
|
+
- Animation performance
|
|
140
|
+
|
|
141
|
+
- **Resource Management**
|
|
142
|
+
- Image loading and caching
|
|
143
|
+
- Memory leaks (retain cycles)
|
|
144
|
+
- Background task management
|
|
145
|
+
- Network request optimization
|
|
146
|
+
|
|
147
|
+
#### 4. Security & Safety
|
|
148
|
+
|
|
149
|
+
- **Data Validation**
|
|
150
|
+
- Input sanitization
|
|
151
|
+
- Type safety
|
|
152
|
+
- Boundary checking
|
|
153
|
+
- Force unwrap audit (avoid `!` and `as!`)
|
|
154
|
+
|
|
155
|
+
- **Sensitive Data Handling**
|
|
156
|
+
- Password and token management
|
|
157
|
+
- Keychain usage for credentials
|
|
158
|
+
- Secure data transmission
|
|
159
|
+
- Log sanitization (no sensitive data in logs)
|
|
160
|
+
|
|
161
|
+
- **Platform Security**
|
|
162
|
+
- Permission handling (camera, location, etc.)
|
|
163
|
+
- Network security (TLS, certificate pinning)
|
|
164
|
+
- Secure storage (UserDefaults vs Keychain)
|
|
165
|
+
- Code signing and entitlements
|
|
166
|
+
|
|
167
|
+
#### 5. Architecture & Maintainability
|
|
168
|
+
|
|
169
|
+
- **Project Architecture Compliance**
|
|
170
|
+
- Adherence to defined patterns (MVVM, MVI, TCA, etc.)
|
|
171
|
+
- Layer separation (View/ViewModel/Repository/UseCase)
|
|
172
|
+
- Dependency injection patterns
|
|
173
|
+
- Module boundaries
|
|
174
|
+
|
|
175
|
+
- **Code Organization**
|
|
176
|
+
- File structure and naming
|
|
177
|
+
- Logical grouping
|
|
178
|
+
- Extension organization
|
|
179
|
+
- Protocol conformances
|
|
180
|
+
|
|
181
|
+
- **Testability**
|
|
182
|
+
- Unit test coverage
|
|
183
|
+
- Test structure (Arrange-Act-Assert)
|
|
184
|
+
- Mock/stub usage
|
|
185
|
+
- Test isolation
|
|
186
|
+
|
|
187
|
+
- **Documentation**
|
|
188
|
+
- DocC comments for public APIs
|
|
189
|
+
- Complex logic explanations
|
|
190
|
+
- Architecture decision records
|
|
191
|
+
- README and guides
|
|
192
|
+
|
|
193
|
+
#### 6. Project-Specific Standards
|
|
194
|
+
|
|
195
|
+
- **Custom Coding Standards**
|
|
196
|
+
- Validate against `.claude/CLAUDE.md` rules
|
|
197
|
+
- Check custom error handling patterns
|
|
198
|
+
- Verify project-specific naming conventions
|
|
199
|
+
- Validate testing requirements
|
|
200
|
+
|
|
201
|
+
- **Design System Compliance**
|
|
202
|
+
- Use of design tokens
|
|
203
|
+
- Consistent spacing and typography
|
|
204
|
+
- Color palette adherence
|
|
205
|
+
- Component library usage
|
|
206
|
+
|
|
207
|
+
- **Navigation Patterns**
|
|
208
|
+
- Coordinator pattern compliance
|
|
209
|
+
- Deep linking support
|
|
210
|
+
- State restoration
|
|
211
|
+
- Navigation flow consistency
|
|
212
|
+
|
|
213
|
+
### Phase 3: Report Generation
|
|
214
|
+
|
|
215
|
+
**Objective**: Aggregate findings into a structured, actionable report
|
|
216
|
+
|
|
217
|
+
1. **Categorize Findings by Severity**
|
|
218
|
+
- **Critical**: Security vulnerabilities, data races, crashes, breaking changes
|
|
219
|
+
- **High**: Performance issues, anti-patterns, major architecture violations
|
|
220
|
+
- **Medium**: Code quality improvements, missing documentation, minor violations
|
|
221
|
+
- **Low**: Style inconsistencies, suggestions for refactoring
|
|
222
|
+
|
|
223
|
+
2. **Include Positive Feedback**
|
|
224
|
+
- Acknowledge good practices and patterns
|
|
225
|
+
- Highlight excellent code quality
|
|
226
|
+
- Recognize proper use of modern APIs
|
|
227
|
+
- Note strong architecture decisions
|
|
228
|
+
|
|
229
|
+
3. **Add Refactoring Suggestions**
|
|
230
|
+
- Proactive improvement opportunities
|
|
231
|
+
- Modernization suggestions
|
|
232
|
+
- Code simplification ideas
|
|
233
|
+
- Performance optimization hints
|
|
234
|
+
|
|
235
|
+
4. **Group and Organize**
|
|
236
|
+
- Group by file, then by category
|
|
237
|
+
- Sort by severity within each file
|
|
238
|
+
- Include code location references (file:line)
|
|
239
|
+
- Provide specific code examples
|
|
240
|
+
|
|
241
|
+
### Phase 4: Delivery
|
|
242
|
+
|
|
243
|
+
**Objective**: Present findings in a clear, actionable format
|
|
244
|
+
|
|
245
|
+
1. **Format as Structured Markdown**
|
|
246
|
+
- Executive summary with key metrics
|
|
247
|
+
- Severity breakdown
|
|
248
|
+
- File-by-file detailed findings
|
|
249
|
+
- Positive feedback section
|
|
250
|
+
- Prioritized action items
|
|
251
|
+
|
|
252
|
+
2. **Include Code References**
|
|
253
|
+
- Exact file and line numbers (file.swift:123)
|
|
254
|
+
- Before/after code examples
|
|
255
|
+
- Links to relevant documentation
|
|
256
|
+
- Comparison with project guidelines
|
|
257
|
+
|
|
258
|
+
3. **Provide Context**
|
|
259
|
+
- Explain *why* something is an issue
|
|
260
|
+
- Reference best practices or standards
|
|
261
|
+
- Suggest specific fixes with examples
|
|
262
|
+
- Link to learning resources
|
|
263
|
+
|
|
264
|
+
## Core Review Categories
|
|
265
|
+
|
|
266
|
+
### 1. Swift Language Quality
|
|
267
|
+
|
|
268
|
+
**What to Check:**
|
|
269
|
+
- Concurrency patterns (actors, async/await, Sendable)
|
|
270
|
+
- Error handling (typed throws, Result type)
|
|
271
|
+
- Optionals handling (avoid force unwrapping)
|
|
272
|
+
- Access control (public, internal, private, fileprivate)
|
|
273
|
+
- Naming conventions (Swift API Design Guidelines)
|
|
274
|
+
- Type inference vs explicit types
|
|
275
|
+
- Value types vs reference types
|
|
276
|
+
|
|
277
|
+
**Reference:** `references/swift-quality-checklist.md`
|
|
278
|
+
|
|
279
|
+
### 2. SwiftUI Patterns
|
|
280
|
+
|
|
281
|
+
**What to Check:**
|
|
282
|
+
- Property wrapper selection and usage
|
|
283
|
+
- State management patterns
|
|
284
|
+
- View lifecycle understanding
|
|
285
|
+
- Modern API usage (avoid deprecated)
|
|
286
|
+
- View composition and extraction
|
|
287
|
+
- Accessibility implementation
|
|
288
|
+
- Preview configurations
|
|
289
|
+
|
|
290
|
+
**Reference:** `references/swiftui-review-checklist.md`
|
|
291
|
+
|
|
292
|
+
### 3. Performance Optimization
|
|
293
|
+
|
|
294
|
+
**What to Check:**
|
|
295
|
+
- View update optimization
|
|
296
|
+
- ForEach identity and performance
|
|
297
|
+
- Heavy work in view body
|
|
298
|
+
- Image loading and caching
|
|
299
|
+
- Memory management
|
|
300
|
+
- Background task efficiency
|
|
301
|
+
- Layout performance
|
|
302
|
+
|
|
303
|
+
**Reference:** `references/performance-review.md`
|
|
304
|
+
|
|
305
|
+
### 4. Security & Safety
|
|
306
|
+
|
|
307
|
+
**What to Check:**
|
|
308
|
+
- Force unwrap detection (`!`, `as!`, `try!`)
|
|
309
|
+
- Input validation and sanitization
|
|
310
|
+
- Sensitive data handling (passwords, tokens)
|
|
311
|
+
- Keychain usage for credentials
|
|
312
|
+
- Network security (HTTPS, certificate pinning)
|
|
313
|
+
- Permission handling
|
|
314
|
+
- Logging safety (no sensitive data in logs)
|
|
315
|
+
|
|
316
|
+
**Reference:** `references/security-checklist.md`
|
|
317
|
+
|
|
318
|
+
### 5. Architecture & Design
|
|
319
|
+
|
|
320
|
+
**What to Check:**
|
|
321
|
+
- MVVM, MVI, TCA, or other architecture compliance
|
|
322
|
+
- Dependency injection patterns
|
|
323
|
+
- Separation of concerns
|
|
324
|
+
- Module boundaries
|
|
325
|
+
- Code organization
|
|
326
|
+
- Testability
|
|
327
|
+
- Documentation quality
|
|
328
|
+
|
|
329
|
+
**Reference:** `references/architecture-patterns.md`
|
|
330
|
+
|
|
331
|
+
### 6. Project-Specific Standards
|
|
332
|
+
|
|
333
|
+
**What to Check:**
|
|
334
|
+
- `.claude/CLAUDE.md` compliance
|
|
335
|
+
- Custom architecture patterns
|
|
336
|
+
- Design system usage
|
|
337
|
+
- Navigation patterns
|
|
338
|
+
- Error handling standards
|
|
339
|
+
- Testing requirements
|
|
340
|
+
|
|
341
|
+
**Reference:** `references/custom-guidelines.md`
|
|
342
|
+
|
|
343
|
+
## Integration with Existing Skills
|
|
344
|
+
|
|
345
|
+
This skill **references** (not duplicates) three foundational skills for domain expertise:
|
|
346
|
+
|
|
347
|
+
### 1. swift-best-practices
|
|
348
|
+
**When to Use:** Reviewing Swift language usage, concurrency patterns, API design, or Swift 6+ migration
|
|
349
|
+
|
|
350
|
+
**What it Provides:**
|
|
351
|
+
- Swift 6+ concurrency patterns (actors, async/await, Sendable)
|
|
352
|
+
- API design guidelines compliance
|
|
353
|
+
- Availability pattern validation
|
|
354
|
+
- Breaking changes detection
|
|
355
|
+
- Modern Swift feature adoption
|
|
356
|
+
|
|
357
|
+
**How to Leverage:**
|
|
358
|
+
- Read `~/.claude/skills/swift-best-practices/references/concurrency.md` for concurrency checks
|
|
359
|
+
- Reference `swift6-features.md` for Swift 6 migration patterns
|
|
360
|
+
- Use `api-design.md` for naming and parameter validation
|
|
361
|
+
|
|
362
|
+
### 2. swiftui-expert-skill
|
|
363
|
+
**When to Use:** Reviewing SwiftUI views, state management, or UI code
|
|
364
|
+
|
|
365
|
+
**What it Provides:**
|
|
366
|
+
- State management patterns (@Observable, @State, @Binding)
|
|
367
|
+
- Modern SwiftUI API guidance (iOS 17+, macOS 14+)
|
|
368
|
+
- View composition best practices
|
|
369
|
+
- Property wrapper selection guide
|
|
370
|
+
- Accessibility patterns
|
|
371
|
+
|
|
372
|
+
**How to Leverage:**
|
|
373
|
+
- Read `~/.claude/skills/swiftui-expert-skill/references/state-management.md` for property wrapper checks
|
|
374
|
+
- Reference `modern-apis.md` for deprecation detection
|
|
375
|
+
- Use `view-composition.md` for component structure validation
|
|
376
|
+
|
|
377
|
+
### 3. swiftui-performance-audit
|
|
378
|
+
**When to Use:** Performance concerns identified or mentioned in PR description
|
|
379
|
+
|
|
380
|
+
**What it Provides:**
|
|
381
|
+
- View update optimization patterns
|
|
382
|
+
- ForEach performance analysis
|
|
383
|
+
- Layout thrash detection
|
|
384
|
+
- Image handling best practices
|
|
385
|
+
- Memory management
|
|
386
|
+
|
|
387
|
+
**How to Leverage:**
|
|
388
|
+
- Read `~/.claude/skills/swiftui-performance-audit/SKILL.md` for performance audit workflow
|
|
389
|
+
- Reference performance-specific checks when reviewing view code
|
|
390
|
+
- Apply recommendations from the skill to performance-sensitive paths
|
|
391
|
+
|
|
392
|
+
**Integration Strategy:**
|
|
393
|
+
1. Load relevant reference files from these skills as needed
|
|
394
|
+
2. Apply their checklist items to the review
|
|
395
|
+
3. Reference their documentation in feedback
|
|
396
|
+
4. Avoid duplicating content—point to their knowledge base
|
|
397
|
+
|
|
398
|
+
## Platform Support
|
|
399
|
+
|
|
400
|
+
### GitHub Pull Requests
|
|
401
|
+
Use `gh` CLI for fetching PR data:
|
|
402
|
+
|
|
403
|
+
```bash
|
|
404
|
+
# Get PR details
|
|
405
|
+
gh pr view <PR-number>
|
|
406
|
+
|
|
407
|
+
# Get PR diff
|
|
408
|
+
gh pr diff <PR-number>
|
|
409
|
+
|
|
410
|
+
# List PR files
|
|
411
|
+
gh pr view <PR-number> --json files
|
|
412
|
+
|
|
413
|
+
# Get PR comments
|
|
414
|
+
gh pr view <PR-number> --json comments
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
### GitLab Merge Requests
|
|
418
|
+
Use `glab` CLI for fetching MR data:
|
|
419
|
+
|
|
420
|
+
```bash
|
|
421
|
+
# Get MR details
|
|
422
|
+
glab mr view <MR-number>
|
|
423
|
+
|
|
424
|
+
# Get MR diff
|
|
425
|
+
glab mr diff <MR-number>
|
|
426
|
+
|
|
427
|
+
# List MR files
|
|
428
|
+
glab mr view <MR-number> --json
|
|
429
|
+
|
|
430
|
+
# Get MR comments
|
|
431
|
+
glab mr note list <MR-number>
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Local Git Changes
|
|
435
|
+
For uncommitted changes or manual review:
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
# Get uncommitted changes
|
|
439
|
+
git diff
|
|
440
|
+
|
|
441
|
+
# Get staged changes
|
|
442
|
+
git diff --cached
|
|
443
|
+
|
|
444
|
+
# Get changes in specific files
|
|
445
|
+
git diff -- path/to/file.swift
|
|
446
|
+
|
|
447
|
+
# Get commit diff
|
|
448
|
+
git show <commit-hash>
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
## Output Format
|
|
452
|
+
|
|
453
|
+
The review report follows this structure:
|
|
454
|
+
|
|
455
|
+
```markdown
|
|
456
|
+
# Code Review Report
|
|
457
|
+
|
|
458
|
+
## Summary
|
|
459
|
+
- **Files Reviewed**: X
|
|
460
|
+
- **Total Findings**: Y
|
|
461
|
+
- **Critical**: 0
|
|
462
|
+
- **High**: 2
|
|
463
|
+
- **Medium**: 5
|
|
464
|
+
- **Low**: 3
|
|
465
|
+
- **Positive Feedback**: 8
|
|
466
|
+
- **Refactoring Suggestions**: 4
|
|
467
|
+
|
|
468
|
+
## Executive Summary
|
|
469
|
+
[Brief overview of the changes and overall code quality]
|
|
470
|
+
|
|
471
|
+
---
|
|
472
|
+
|
|
473
|
+
## Detailed Findings
|
|
474
|
+
|
|
475
|
+
### File: Sources/Features/Login/LoginView.swift
|
|
476
|
+
|
|
477
|
+
#### ✅ Positive Feedback
|
|
478
|
+
1. **Excellent State Management** (line 23)
|
|
479
|
+
- Proper use of @Observable for view model
|
|
480
|
+
- Clean separation of concerns
|
|
481
|
+
|
|
482
|
+
2. **Modern API Usage** (line 45)
|
|
483
|
+
- Using new SwiftUI APIs effectively
|
|
484
|
+
- Proper async/await integration
|
|
485
|
+
|
|
486
|
+
#### 🔴 Critical Issues
|
|
487
|
+
1. **Data Race Risk** (line 67)
|
|
488
|
+
- **Severity**: Critical
|
|
489
|
+
- **Category**: Concurrency
|
|
490
|
+
- **Issue**: Mutable state accessed from multiple actors without synchronization
|
|
491
|
+
- **Fix**:
|
|
492
|
+
```swift
|
|
493
|
+
// Before
|
|
494
|
+
class LoginViewModel {
|
|
495
|
+
var isLoading = false
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// After
|
|
499
|
+
@MainActor
|
|
500
|
+
class LoginViewModel: ObservableObject {
|
|
501
|
+
@Published var isLoading = false
|
|
502
|
+
}
|
|
503
|
+
```
|
|
504
|
+
- **Reference**: swift-best-practices/references/concurrency.md
|
|
505
|
+
|
|
506
|
+
#### 🟡 High Priority
|
|
507
|
+
1. **Force Unwrap Detected** (line 89)
|
|
508
|
+
- **Severity**: High
|
|
509
|
+
- **Category**: Safety
|
|
510
|
+
- **Issue**: Force unwrapping optional can cause crash
|
|
511
|
+
- **Fix**:
|
|
512
|
+
```swift
|
|
513
|
+
// Before
|
|
514
|
+
let user = fetchUser()!
|
|
515
|
+
|
|
516
|
+
// After
|
|
517
|
+
guard let user = fetchUser() else {
|
|
518
|
+
logger.error("Failed to fetch user")
|
|
519
|
+
return
|
|
520
|
+
}
|
|
521
|
+
```
|
|
522
|
+
- **Reference**: Project coding standard (.claude/CLAUDE.md:45)
|
|
523
|
+
|
|
524
|
+
#### 💡 Refactoring Suggestions
|
|
525
|
+
1. **Extract Subview** (lines 120-150)
|
|
526
|
+
- Consider extracting login form into separate view
|
|
527
|
+
- Improves testability and reusability
|
|
528
|
+
|
|
529
|
+
---
|
|
530
|
+
|
|
531
|
+
## Prioritized Action Items
|
|
532
|
+
|
|
533
|
+
### Must Fix (Critical/High)
|
|
534
|
+
1. [ ] Fix data race in LoginViewModel.swift:67
|
|
535
|
+
2. [ ] Remove force unwrap in LoginView.swift:89
|
|
536
|
+
|
|
537
|
+
### Should Fix (Medium)
|
|
538
|
+
1. [ ] Add documentation to public APIs
|
|
539
|
+
2. [ ] Improve error handling in NetworkService.swift
|
|
540
|
+
|
|
541
|
+
### Consider (Low)
|
|
542
|
+
1. [ ] Refactor login form into separate view
|
|
543
|
+
2. [ ] Add more unit tests for edge cases
|
|
544
|
+
|
|
545
|
+
---
|
|
546
|
+
|
|
547
|
+
## Positive Patterns Observed
|
|
548
|
+
- Excellent use of @Observable for state management
|
|
549
|
+
- Consistent adherence to project architecture (MVVM)
|
|
550
|
+
- Comprehensive accessibility support
|
|
551
|
+
- Strong error handling in most areas
|
|
552
|
+
- Good test coverage for core functionality
|
|
553
|
+
|
|
554
|
+
## References
|
|
555
|
+
- [Swift Best Practices](~/.claude/skills/swift-best-practices/SKILL.md)
|
|
556
|
+
- [SwiftUI Expert Guide](~/.claude/skills/swiftui-expert-skill/SKILL.md)
|
|
557
|
+
- [Project Coding Standards](.claude/CLAUDE.md)
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
## How to Use
|
|
561
|
+
|
|
562
|
+
### Example 1: Review Specific File
|
|
563
|
+
```
|
|
564
|
+
User: "Review UserProfileView.swift"
|
|
565
|
+
|
|
566
|
+
Steps:
|
|
567
|
+
1. Read .claude/CLAUDE.md for project standards
|
|
568
|
+
2. Read UserProfileView.swift
|
|
569
|
+
3. Run multi-layer analysis
|
|
570
|
+
4. Provide structured feedback with severity levels and positive feedback
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
### Example 2: Review Git Changes
|
|
574
|
+
```
|
|
575
|
+
User: "Review my uncommitted changes"
|
|
576
|
+
|
|
577
|
+
Steps:
|
|
578
|
+
1. Read .claude/CLAUDE.md
|
|
579
|
+
2. Execute `git diff` to get changes
|
|
580
|
+
3. Identify modified files
|
|
581
|
+
4. Run analysis on each file
|
|
582
|
+
5. Generate comprehensive review report
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
### Example 3: Review Pull Request
|
|
586
|
+
```
|
|
587
|
+
User: "Review PR #123"
|
|
588
|
+
|
|
589
|
+
Steps:
|
|
590
|
+
1. Read .claude/CLAUDE.md
|
|
591
|
+
2. Execute `gh pr view 123` and `gh pr diff 123`
|
|
592
|
+
3. Identify changed files
|
|
593
|
+
4. Read affected files for context
|
|
594
|
+
5. Run multi-layer analysis
|
|
595
|
+
6. Generate report with file:line references
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
### Example 4: Review Against Custom Guidelines
|
|
599
|
+
```
|
|
600
|
+
User: "Review LoginViewModel.swift against our coding standards"
|
|
601
|
+
|
|
602
|
+
Steps:
|
|
603
|
+
1. Read .claude/CLAUDE.md
|
|
604
|
+
2. Read related docs (DependencyInjection-Architecture.md)
|
|
605
|
+
3. Read LoginViewModel.swift
|
|
606
|
+
4. Validate against project-specific patterns
|
|
607
|
+
5. Provide detailed feedback comparing with standards
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
### Example 5: Review Multiple Files
|
|
611
|
+
```
|
|
612
|
+
User: "Review all ViewModels in the Features folder"
|
|
613
|
+
|
|
614
|
+
Steps:
|
|
615
|
+
1. Read .claude/CLAUDE.md
|
|
616
|
+
2. Find all *ViewModel.swift files in Features/
|
|
617
|
+
3. Analyze each against architecture patterns
|
|
618
|
+
4. Provide file-by-file review
|
|
619
|
+
5. Summarize common patterns and issues across all files
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
## Resources
|
|
623
|
+
|
|
624
|
+
This skill includes the following reference materials:
|
|
625
|
+
|
|
626
|
+
### Core References
|
|
627
|
+
- **review-workflow.md**: Detailed step-by-step review process, git commands, and diff parsing strategies
|
|
628
|
+
- **feedback-templates.md**: Templates for positive/negative comments, severity classification guidelines
|
|
629
|
+
|
|
630
|
+
### Quality Checklists
|
|
631
|
+
- **swift-quality-checklist.md**: Swift 6+ concurrency, error handling, optionals, access control, naming
|
|
632
|
+
- **swiftui-review-checklist.md**: Property wrappers, state management, modern APIs, view composition
|
|
633
|
+
- **performance-review.md**: View updates, ForEach optimization, layout efficiency, resource management
|
|
634
|
+
- **security-checklist.md**: Input validation, sensitive data, keychain, network security
|
|
635
|
+
|
|
636
|
+
### Architecture & Customization
|
|
637
|
+
- **architecture-patterns.md**: MVVM, MVI, TCA patterns, dependency injection, testing strategies
|
|
638
|
+
- **custom-guidelines.md**: How to read and parse .claude/CLAUDE.md and project-specific standards
|
|
639
|
+
|
|
640
|
+
## Best Practices
|
|
641
|
+
|
|
642
|
+
1. **Always Read Project Guidelines First**
|
|
643
|
+
- Load `.claude/CLAUDE.md` before starting review
|
|
644
|
+
- Understand project-specific patterns and rules
|
|
645
|
+
- Merge project standards with Apple guidelines
|
|
646
|
+
|
|
647
|
+
2. **Provide Balanced Feedback**
|
|
648
|
+
- Include positive feedback for good practices
|
|
649
|
+
- Don't just criticize—acknowledge what's done well
|
|
650
|
+
- Suggest improvements, not just problems
|
|
651
|
+
|
|
652
|
+
3. **Be Specific and Actionable**
|
|
653
|
+
- Include exact file:line references
|
|
654
|
+
- Provide code examples for fixes
|
|
655
|
+
- Explain *why* something is an issue
|
|
656
|
+
- Link to relevant documentation
|
|
657
|
+
|
|
658
|
+
4. **Prioritize by Severity**
|
|
659
|
+
- Critical: Must fix before merge (security, crashes, data races)
|
|
660
|
+
- High: Should fix before merge (anti-patterns, performance issues)
|
|
661
|
+
- Medium: Address soon (code quality, documentation)
|
|
662
|
+
- Low: Consider for future (style, refactoring suggestions)
|
|
663
|
+
|
|
664
|
+
5. **Leverage Existing Skills**
|
|
665
|
+
- Reference swift-best-practices for language patterns
|
|
666
|
+
- Use swiftui-expert-skill for UI code
|
|
667
|
+
- Apply swiftui-performance-audit for performance concerns
|
|
668
|
+
- Don't duplicate their content—point to their knowledge
|
|
669
|
+
|
|
670
|
+
6. **Focus on Education**
|
|
671
|
+
- Explain the reasoning behind feedback
|
|
672
|
+
- Link to learning resources
|
|
673
|
+
- Help developers understand best practices
|
|
674
|
+
- Foster continuous improvement
|
|
675
|
+
|
|
676
|
+
## Limitations
|
|
677
|
+
|
|
678
|
+
- Cannot execute code or run tests (can only analyze statically)
|
|
679
|
+
- Cannot access external systems or APIs
|
|
680
|
+
- Limited to analyzing code provided or accessible via git
|
|
681
|
+
- Cannot detect runtime issues that require execution
|
|
682
|
+
- Performance analysis is based on patterns, not profiling data
|
|
683
|
+
|
|
684
|
+
For runtime analysis, recommend using Instruments or other profiling tools.
|
|
685
|
+
|
|
686
|
+
## Version
|
|
687
|
+
|
|
688
|
+
**Version**: 1.0.0
|
|
689
|
+
**Last Updated**: 2026-02-10
|
|
690
|
+
**Compatible with**: Swift 6+, SwiftUI (iOS 17+, macOS 14+, watchOS 10+, tvOS 17+, visionOS 1+)
|