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/README.md ADDED
@@ -0,0 +1,536 @@
1
+ # Swift Code Reviewer Agent Skill
2
+
3
+ A comprehensive code review skill for Claude that performs multi-layer analysis of Swift and SwiftUI code, combining Apple's best practices with project-specific coding standards.
4
+
5
+ ## Features
6
+
7
+ - 🔍 **Multi-Layer Analysis**: Combines Swift 6+ best practices, SwiftUI patterns, performance optimization, and security checks
8
+ - 📋 **Project-Aware Reviews**: Reads `.claude/CLAUDE.md` to validate against project-specific standards and architecture patterns
9
+ - 🎯 **Comprehensive Feedback**: Provides Critical/High/Medium/Low severity issues, positive feedback, and refactoring suggestions
10
+ - 🔗 **Skill Integration**: Leverages existing `swift-best-practices`, `swiftui-expert-skill`, and `swiftui-performance-audit` skills
11
+ - 📊 **Actionable Output**: Structured reports with file:line references, code examples, and prioritized action items
12
+ - 🚀 **Platform Support**: Works with GitHub PRs, GitLab MRs, and local git changes
13
+
14
+ ## What It Reviews
15
+
16
+ ### Swift Quality
17
+ - **Concurrency Safety**: Actor isolation, MainActor usage, Sendable conformance, data race prevention
18
+ - **Error Handling**: Typed throws, Result types, proper error propagation
19
+ - **Optionals**: Safe unwrapping, guard statements, no force unwraps
20
+ - **Access Control**: Explicit access modifiers, minimal API surface
21
+ - **Naming**: Swift API Design Guidelines compliance
22
+
23
+ ### SwiftUI Patterns
24
+ - **State Management**: @Observable, @State, @Binding, @Environment usage
25
+ - **Property Wrappers**: Correct wrapper selection for each use case
26
+ - **Modern APIs**: NavigationStack, .task, latest SwiftUI features
27
+ - **View Composition**: Extracted subviews, ViewBuilder patterns
28
+ - **Accessibility**: Labels, hints, Dynamic Type support
29
+
30
+ ### Performance
31
+ - **View Optimization**: Unnecessary updates, Equatable conformance
32
+ - **ForEach Performance**: Stable identity, lazy loading
33
+ - **Layout Efficiency**: GeometryReader usage, layout thrash
34
+ - **Resource Management**: Image loading, memory leaks, async patterns
35
+
36
+ ### Security & Safety
37
+ - **Input Validation**: Sanitization, bounds checking, type safety
38
+ - **Sensitive Data**: Keychain storage, biometric authentication, secure logging
39
+ - **Network Security**: HTTPS enforcement, certificate pinning, API key protection
40
+ - **Permissions**: Privacy descriptions, permission timing, graceful handling
41
+
42
+ ### Architecture
43
+ - **Pattern Compliance**: MVVM, MVI, TCA adherence
44
+ - **Dependency Injection**: Constructor injection, protocol-based dependencies
45
+ - **Code Organization**: File structure, MARK comments, logical grouping
46
+ - **Testability**: Unit test coverage, mock usage, test structure
47
+
48
+ ### Project Standards
49
+ - **Custom Guidelines**: Validates against `.claude/CLAUDE.md` rules
50
+ - **Design System**: Color palette, typography, spacing token usage
51
+ - **Error Patterns**: Custom error type conformance
52
+ - **Testing Requirements**: Coverage thresholds, testing patterns
53
+
54
+ ## Installation
55
+
56
+ ### Option 1: NPX (Recommended)
57
+
58
+ The fastest way to install - no cloning required:
59
+
60
+ ```bash
61
+ npx swift-code-reviewer-skill
62
+ ```
63
+
64
+ This automatically installs the skill to `~/.claude/skills/swift-code-reviewer-skill/`
65
+
66
+ To uninstall:
67
+
68
+ ```bash
69
+ npx swift-code-reviewer-skill uninstall
70
+ ```
71
+
72
+ ### Option 2: Clone This Repository
73
+
74
+ ```bash
75
+ # Clone the skill
76
+ git clone https://github.com/Viniciuscarvalho/swift-code-reviewer-skill.git ~/.claude/skills/swift-code-reviewer-skill
77
+
78
+ # The skill is now ready to use!
79
+ ```
80
+
81
+ ### Option 3: Manual Installation
82
+
83
+ 1. Create the skill directory:
84
+ ```bash
85
+ mkdir -p ~/.claude/skills/swift-code-reviewer-skill/references
86
+ ```
87
+
88
+ 2. Download the files from this repository into the directory
89
+
90
+ 3. Restart Claude or reload skills
91
+
92
+ ### Verify Installation
93
+
94
+ ```bash
95
+ ls ~/.claude/skills/swift-code-reviewer-skill/
96
+ # Should show: SKILL.md, README.md, references/, and more
97
+ ```
98
+
99
+ ## Usage
100
+
101
+ ### Basic Usage
102
+
103
+ The skill automatically activates when you ask Claude to review Swift/SwiftUI code:
104
+
105
+ ```
106
+ Review this PR
107
+
108
+ Review LoginView.swift
109
+
110
+ Review my uncommitted changes
111
+
112
+ Check if this follows our coding standards
113
+ ```
114
+
115
+ ### Review Specific Files
116
+
117
+ ```
118
+ Review UserProfileView.swift
119
+ ```
120
+
121
+ **What it does:**
122
+ 1. Reads `.claude/CLAUDE.md` for project standards
123
+ 2. Analyzes the file against all quality dimensions
124
+ 3. Provides structured feedback with severity levels
125
+ 4. Includes positive feedback and refactoring suggestions
126
+
127
+ ### Review Git Changes
128
+
129
+ ```
130
+ Review my uncommitted changes
131
+ ```
132
+
133
+ **What it does:**
134
+ 1. Runs `git diff` to identify changes
135
+ 2. Analyzes modified files
136
+ 3. Focuses on changed lines for efficiency
137
+ 4. Generates comprehensive review report
138
+
139
+ ### Review Pull Requests (GitHub)
140
+
141
+ ```
142
+ Review PR #123
143
+ ```
144
+
145
+ **What it does:**
146
+ 1. Fetches PR details using `gh pr view 123`
147
+ 2. Gets diff using `gh pr diff 123`
148
+ 3. Reads all changed files for context
149
+ 4. Generates detailed review with file:line references
150
+
151
+ ### Review Merge Requests (GitLab)
152
+
153
+ ```
154
+ Review MR #456
155
+ ```
156
+
157
+ **What it does:**
158
+ 1. Fetches MR details using `glab mr view 456`
159
+ 2. Gets diff and changed files
160
+ 3. Performs multi-layer analysis
161
+ 4. Generates actionable feedback
162
+
163
+ ### Review Against Custom Standards
164
+
165
+ ```
166
+ Review LoginViewModel.swift against our coding standards
167
+ ```
168
+
169
+ **What it does:**
170
+ 1. Reads `.claude/CLAUDE.md` and related architecture docs
171
+ 2. Extracts project-specific rules
172
+ 3. Validates code against both Apple and project standards
173
+ 4. Reports compliance and violations
174
+
175
+ ### Review Multiple Files
176
+
177
+ ```
178
+ Review all ViewModels in the Features folder
179
+ ```
180
+
181
+ **What it does:**
182
+ 1. Finds all matching files
183
+ 2. Analyzes each against architecture patterns
184
+ 3. Provides file-by-file review
185
+ 4. Summarizes common patterns and issues
186
+
187
+ ## How It Works
188
+
189
+ The skill follows a **four-phase workflow**:
190
+
191
+ ### Phase 1: Context Gathering
192
+
193
+ 1. **Read Project Guidelines**
194
+ - Loads `.claude/CLAUDE.md` if it exists
195
+ - Reads related architecture documents
196
+ - Extracts custom coding standards
197
+
198
+ 2. **Identify Review Scope**
199
+ - Determines files to review (user-specified, git diff, PR/MR)
200
+ - Categorizes changes by type (UI, logic, tests)
201
+
202
+ 3. **Gather Context**
203
+ - Reads all files completely
204
+ - Understands broader context
205
+ - Identifies component relationships
206
+
207
+ ### Phase 2: Automated Analysis
208
+
209
+ Runs parallel checks across **six core categories**:
210
+
211
+ 1. **Swift Best Practices** (leverages `swift-best-practices` skill)
212
+ - Concurrency safety and actor isolation
213
+ - API design and naming conventions
214
+ - Swift 6+ feature adoption
215
+
216
+ 2. **SwiftUI Quality** (leverages `swiftui-expert-skill`)
217
+ - State management patterns
218
+ - Modern API usage
219
+ - View composition
220
+
221
+ 3. **Performance** (leverages `swiftui-performance-audit`)
222
+ - View update optimization
223
+ - ForEach performance
224
+ - Resource management
225
+
226
+ 4. **Security & Safety**
227
+ - Force unwrap detection
228
+ - Sensitive data handling
229
+ - Network security
230
+
231
+ 5. **Architecture & Maintainability**
232
+ - Pattern compliance
233
+ - Dependency injection
234
+ - Testability
235
+
236
+ 6. **Project-Specific Standards**
237
+ - `.claude/CLAUDE.md` compliance
238
+ - Design system usage
239
+ - Custom error patterns
240
+
241
+ ### Phase 3: Report Generation
242
+
243
+ 1. **Categorizes findings** by severity (Critical, High, Medium, Low)
244
+ 2. **Includes positive feedback** for good practices
245
+ 3. **Adds refactoring suggestions** for improvements
246
+ 4. **Groups by file** and category
247
+ 5. **Provides code examples** for all issues
248
+
249
+ ### Phase 4: Delivery
250
+
251
+ Generates a structured markdown report:
252
+
253
+ ```markdown
254
+ # Code Review Report
255
+
256
+ ## Summary
257
+ - Files Reviewed: 5
258
+ - Critical: 0
259
+ - High: 2
260
+ - Medium: 5
261
+ - Low: 3
262
+ - Positive Feedback: 8
263
+
264
+ ## Detailed Findings
265
+
266
+ ### File: LoginView.swift
267
+
268
+ #### ✅ Positive Feedback
269
+ 1. Excellent use of @Observable for state management
270
+
271
+ #### 🟡 High Priority
272
+ 1. Force unwrap detected at line 89 (potential crash)
273
+
274
+ #### 💡 Refactoring Suggestions
275
+ 1. Consider extracting login form into separate view
276
+
277
+ ## Prioritized Action Items
278
+ [Must fix, should fix, consider items]
279
+ ```
280
+
281
+ ## Review Report Structure
282
+
283
+ ### Severity Levels
284
+
285
+ | Severity | Icon | Description | Response Time |
286
+ |----------|------|-------------|---------------|
287
+ | **Critical** | 🔴 | Security vulnerabilities, crashes, data races | Must fix before merge |
288
+ | **High** | 🟡 | Performance issues, anti-patterns, major violations | Should fix before merge |
289
+ | **Medium** | 🟠 | Code quality, documentation, minor violations | Fix in current sprint |
290
+ | **Low** | 🔵 | Style, suggestions, minor improvements | Consider for future |
291
+
292
+ ### Feedback Types
293
+
294
+ **Positive Feedback** ✅
295
+ - Acknowledges good practices
296
+ - Highlights excellent implementations
297
+ - Recognizes proper patterns
298
+
299
+ **Issues** 🔴🟡🟠🔵
300
+ - File and line references
301
+ - Code examples (before/after)
302
+ - Specific fixes with explanations
303
+ - Links to documentation
304
+
305
+ **Refactoring Suggestions** 💡
306
+ - Proactive improvements
307
+ - Modernization opportunities
308
+ - Code simplification ideas
309
+
310
+ ## Project-Specific Standards
311
+
312
+ The skill reads `.claude/CLAUDE.md` to understand your project's:
313
+
314
+ - Architecture pattern (MVVM, MVI, TCA, etc.)
315
+ - Dependency injection approach
316
+ - Error handling patterns
317
+ - Testing requirements
318
+ - Design system guidelines
319
+ - Navigation patterns
320
+ - Custom naming conventions
321
+
322
+ ### Example .claude/CLAUDE.md
323
+
324
+ ```markdown
325
+ # MyApp Coding Standards
326
+
327
+ ## Architecture
328
+ We use **MVVM with Coordinators**:
329
+ - ViewModels MUST use @Observable (iOS 17+)
330
+ - All dependencies MUST be injected via constructor
331
+ - Views MUST NOT contain business logic
332
+
333
+ ## Error Handling
334
+ All errors MUST conform to AppError:
335
+ ```swift
336
+ protocol AppError: Error {
337
+ var message: String { get }
338
+ var code: Int { get }
339
+ }
340
+ ```
341
+
342
+ ## Design System
343
+ - Use AppColors enum ONLY
344
+ - Use AppFonts enum ONLY
345
+ - Use AppSpacing for all padding
346
+
347
+ ## Testing
348
+ - Minimum coverage: 80%
349
+ - All ViewModels MUST have unit tests
350
+ ```
351
+
352
+ The skill will validate your code against these standards and report violations.
353
+
354
+ ## Reference Documentation
355
+
356
+ The skill includes comprehensive reference guides:
357
+
358
+ - **review-workflow.md**: Step-by-step review process and git commands
359
+ - **swift-quality-checklist.md**: Swift 6+ concurrency, error handling, optionals
360
+ - **swiftui-review-checklist.md**: State management, property wrappers, modern APIs
361
+ - **performance-review.md**: View optimization, ForEach performance, layout efficiency
362
+ - **security-checklist.md**: Input validation, sensitive data, network security
363
+ - **architecture-patterns.md**: MVVM, Repository, DI, Use Case, Coordinator patterns
364
+ - **feedback-templates.md**: Review comment templates and severity guidelines
365
+ - **custom-guidelines.md**: How to parse and validate `.claude/CLAUDE.md`
366
+
367
+ ## Integration with Other Skills
368
+
369
+ This skill **leverages** three foundational skills:
370
+
371
+ ### swift-best-practices
372
+ For Swift 6+ language patterns, concurrency, and API design
373
+ - Loads when reviewing Swift language usage
374
+ - References: `concurrency.md`, `swift6-features.md`, `api-design.md`
375
+
376
+ ### swiftui-expert-skill
377
+ For SwiftUI state management and modern APIs
378
+ - Loads when reviewing SwiftUI views
379
+ - References: `state-management.md`, `modern-apis.md`, `view-composition.md`
380
+
381
+ ### swiftui-performance-audit
382
+ For performance analysis
383
+ - Loads when performance concerns identified
384
+ - Runs focused audit on performance-sensitive paths
385
+
386
+ **Note**: These skills should be installed separately for full functionality, but the code reviewer works independently with its own comprehensive checklists.
387
+
388
+ ## Examples
389
+
390
+ ### Example 1: Review Uncommitted Changes
391
+
392
+ **Input:**
393
+ ```
394
+ Review my uncommitted changes
395
+ ```
396
+
397
+ **Output:**
398
+ ```markdown
399
+ # Code Review Report
400
+
401
+ ## Summary
402
+ - Files Reviewed: 3
403
+ - Critical: 0
404
+ - High: 1
405
+ - Medium: 2
406
+ - Low: 1
407
+ - Positive Feedback: 5
408
+
409
+ ## File: LoginViewModel.swift
410
+
411
+ ✅ **Excellent Modern API Usage** (line 12)
412
+ - Using @Observable instead of ObservableObject
413
+ - Clean, modern pattern for iOS 17+
414
+
415
+ 🟡 **Force Unwrap Detected** (line 89)
416
+ **Severity**: High
417
+ **Issue**: Force unwrapping can crash if data is nil
418
+
419
+ Current Code:
420
+ ```swift
421
+ let user = repository.currentUser!
422
+ ```
423
+
424
+ Recommended Fix:
425
+ ```swift
426
+ guard let user = repository.currentUser else {
427
+ logger.error("No current user")
428
+ return
429
+ }
430
+ ```
431
+ ```
432
+
433
+ ### Example 2: Review Against Project Standards
434
+
435
+ **Input:**
436
+ ```
437
+ Review LoginView.swift against our coding standards
438
+ ```
439
+
440
+ **Output:**
441
+ ```markdown
442
+ # Project Standards Review
443
+
444
+ ## .claude/CLAUDE.md Compliance
445
+
446
+ ✅ **Architecture Adherence**
447
+ - Follows MVVM pattern correctly
448
+ - No business logic in view
449
+ - Dependencies injected properly
450
+
451
+ 🔴 **Violates Design System Standard** (line 45)
452
+ **Project Guideline**: "Use AppColors enum ONLY. No hardcoded colors"
453
+
454
+ Current Code:
455
+ ```swift
456
+ .foregroundColor(.blue) // ❌ Hardcoded
457
+ ```
458
+
459
+ Expected Code:
460
+ ```swift
461
+ .foregroundColor(AppColors.primary) // ✅ Design system
462
+ ```
463
+
464
+ Reference: .claude/CLAUDE.md:Design System
465
+ ```
466
+
467
+ ## Requirements
468
+
469
+ - Claude Code CLI
470
+ - Git (for reviewing diffs and PRs)
471
+ - Optional: `gh` CLI for GitHub integration
472
+ - Optional: `glab` CLI for GitLab integration
473
+ - Swift 6.0+
474
+ - iOS 17+, macOS 14+, watchOS 10+, tvOS 17+, or visionOS 1+
475
+
476
+ ## Limitations
477
+
478
+ - Cannot execute code or run tests (static analysis only)
479
+ - Cannot access external systems or APIs
480
+ - Limited to analyzing provided code or git-accessible code
481
+ - Cannot detect runtime issues requiring execution
482
+ - Performance analysis based on patterns, not profiling data
483
+
484
+ For runtime analysis, use Instruments or other profiling tools alongside this skill.
485
+
486
+ ## Contributing
487
+
488
+ Contributions are welcome! Here's how you can help:
489
+
490
+ 1. **Report Issues**: Found a bug or have a suggestion? Open an issue
491
+ 2. **Improve Checklists**: Add new patterns or update existing checks
492
+ 3. **Add Examples**: Contribute real-world review examples
493
+ 4. **Update Documentation**: Improve clarity and add use cases
494
+ 5. **Add Templates**: Create new feedback templates
495
+
496
+ ### Development
497
+
498
+ To modify the skill:
499
+
500
+ 1. Edit `SKILL.md` for main skill logic
501
+ 2. Update reference files in `references/` for specific checklists
502
+ 3. Test with real Swift/SwiftUI code
503
+ 4. Submit a pull request
504
+
505
+ ## License
506
+
507
+ MIT License - See [LICENSE](LICENSE) file for details
508
+
509
+ ## Acknowledgments
510
+
511
+ - Inspired by Apple's Swift API Design Guidelines
512
+ - Leverages best practices from the Swift and SwiftUI communities
513
+ - Built on top of Claude's code analysis capabilities
514
+ - Designed to complement existing Swift development skills
515
+
516
+ ## Support
517
+
518
+ - **Issues**: [GitHub Issues](https://github.com/Viniciuscarvalho/swift-code-reviewer-skill/issues)
519
+ - **Discussions**: [GitHub Discussions](https://github.com/Viniciuscarvalho/swift-code-reviewer-skill/discussions)
520
+
521
+ ## Version History
522
+
523
+ ### 1.0.0 (2026-02-10)
524
+ - Initial release
525
+ - Comprehensive Swift 6+ and SwiftUI review capabilities
526
+ - Project-specific standards integration
527
+ - Multi-layer analysis (6 categories)
528
+ - Structured feedback with all severity levels
529
+ - Integration with existing skills
530
+ - 7,700+ lines of comprehensive documentation
531
+
532
+ ---
533
+
534
+ **Made with ❤️ for the Swift community**
535
+
536
+ If this skill helps improve your code reviews, please ⭐️ star the repository!