swift-code-reviewer-skill 1.0.0 → 1.1.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.
package/README.md CHANGED
@@ -1,502 +1,155 @@
1
1
  # Swift Code Reviewer Agent Skill
2
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.
3
+ [![GitHub Sponsors](https://img.shields.io/github/sponsors/Viniciuscarvalho?style=social)](https://github.com/sponsors/Viniciuscarvalho)
4
+ [![npm version](https://img.shields.io/npm/v/swift-code-reviewer-skill)](https://www.npmjs.com/package/swift-code-reviewer-skill)
4
5
 
5
- ## Features
6
+ A code review skill for [Claude Code](https://docs.anthropic.com/en/docs/claude-code) that performs multi-layer analysis of Swift and SwiftUI code, combining Apple's best practices with your project-specific coding standards.
6
7
 
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:
8
+ ## Quick Start
59
9
 
60
10
  ```bash
61
11
  npx swift-code-reviewer-skill
62
12
  ```
63
13
 
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
14
+ That's it. The skill is installed and ready to use. Run it again anytime to update to the latest version.
89
15
 
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
- ```
16
+ > No cloning, no manual setup. NPX always fetches the latest version automatically.
98
17
 
99
18
  ## Usage
100
19
 
101
- ### Basic Usage
20
+ ![Swift Code Reviewer in action](assets/demo.png)
102
21
 
103
- The skill automatically activates when you ask Claude to review Swift/SwiftUI code:
22
+ Just ask Claude to review your code:
104
23
 
105
24
  ```
106
25
  Review this PR
107
-
108
26
  Review LoginView.swift
109
-
110
27
  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
28
  Review all ViewModels in the Features folder
29
+ Check if this follows our coding standards
179
30
  ```
180
31
 
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
32
+ The skill automatically activates, reads your `.claude/CLAUDE.md` for project standards, and generates a structured report with severity levels, code examples, and prioritized action items.
186
33
 
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:
34
+ ### Example Output
252
35
 
253
36
  ```markdown
254
37
  # Code Review Report
255
38
 
256
39
  ## Summary
257
- - Files Reviewed: 5
258
- - Critical: 0
259
- - High: 2
260
- - Medium: 5
261
- - Low: 3
262
- - Positive Feedback: 8
263
40
 
264
- ## Detailed Findings
41
+ - Files Reviewed: 3 | Critical: 0 | High: 1 | Medium: 2 | Low: 1
42
+
43
+ ## File: LoginViewModel.swift
265
44
 
266
- ### File: LoginView.swift
45
+ **Excellent Modern API Usage** (line 12)
267
46
 
268
- #### Positive Feedback
269
- 1. Excellent use of @Observable for state management
47
+ - Using @Observable instead of ObservableObject
270
48
 
271
- #### 🟡 High Priority
272
- 1. Force unwrap detected at line 89 (potential crash)
49
+ 🟡 **Force Unwrap Detected** (line 89)
50
+ Current: `let user = repository.currentUser!`
51
+ Fix:
52
+ guard let user = repository.currentUser else {
53
+ logger.error("No current user")
54
+ return
55
+ }
273
56
 
274
- #### 💡 Refactoring Suggestions
275
- 1. Consider extracting login form into separate view
57
+ 🔴 **Violates Design System Standard** (line 45)
58
+ Current: `.foregroundColor(.blue)`
59
+ Fix: `.foregroundColor(AppColors.primary)`
276
60
 
277
61
  ## Prioritized Action Items
278
- [Must fix, should fix, consider items]
279
- ```
280
62
 
281
- ## Review Report Structure
63
+ 1. [Must fix] Remove force unwrap at line 89
64
+ 2. [Should fix] Use design system colors at line 45
65
+ ```
282
66
 
283
- ### Severity Levels
67
+ ## What It Reviews
284
68
 
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 |
69
+ | Category | Checks |
70
+ | --------------------- | --------------------------------------------------------------------------------------------------------- |
71
+ | **Swift Quality** | Concurrency safety, actor isolation, Sendable, error handling, optionals, access control, naming |
72
+ | **SwiftUI Patterns** | @Observable, state management, property wrappers, NavigationStack, .task, view composition, accessibility |
73
+ | **Performance** | View updates, Equatable, ForEach identity, GeometryReader, lazy loading, memory leaks |
74
+ | **Security** | Keychain, input validation, HTTPS, certificate pinning, API key protection, sensitive data logging |
75
+ | **Architecture** | MVVM/MVI/TCA compliance, dependency injection, code organization, testability |
76
+ | **Project Standards** | `.claude/CLAUDE.md` rules, design system, custom error patterns, testing requirements |
291
77
 
292
- ### Feedback Types
78
+ ### Severity Levels
293
79
 
294
- **Positive Feedback**
295
- - Acknowledges good practices
296
- - Highlights excellent implementations
297
- - Recognizes proper patterns
80
+ | Icon | Severity | Action |
81
+ | ---- | -------- | ----------------------- |
82
+ | 🔴 | Critical | Must fix before merge |
83
+ | 🟡 | High | Should fix before merge |
84
+ | 🟠 | Medium | Fix in current sprint |
85
+ | 🔵 | Low | Consider for future |
298
86
 
299
- **Issues** 🔴🟡🟠🔵
300
- - File and line references
301
- - Code examples (before/after)
302
- - Specific fixes with explanations
303
- - Links to documentation
87
+ ## Platform Support
304
88
 
305
- **Refactoring Suggestions** 💡
306
- - Proactive improvements
307
- - Modernization opportunities
308
- - Code simplification ideas
89
+ - Works with **GitHub PRs** (`gh`), **GitLab MRs** (`glab`), and **local git changes**
90
+ - Swift 6.0+ | iOS 17+ | macOS 14+ | watchOS 10+ | tvOS 17+ | visionOS 1+
309
91
 
310
92
  ## Project-Specific Standards
311
93
 
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
94
+ Add a `.claude/CLAUDE.md` to your project and the skill will validate against your rules:
323
95
 
324
96
  ```markdown
325
- # MyApp Coding Standards
97
+ # MyApp Standards
326
98
 
327
99
  ## Architecture
328
- We use **MVVM with Coordinators**:
100
+
329
101
  - ViewModels MUST use @Observable (iOS 17+)
330
102
  - All dependencies MUST be injected via constructor
331
103
  - Views MUST NOT contain business logic
332
104
 
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
105
  ## Design System
106
+
343
107
  - Use AppColors enum ONLY
344
108
  - Use AppFonts enum ONLY
345
- - Use AppSpacing for all padding
346
109
 
347
110
  ## Testing
111
+
348
112
  - Minimum coverage: 80%
349
113
  - All ViewModels MUST have unit tests
350
114
  ```
351
115
 
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+
116
+ ## Alternative Installation
414
117
 
415
- 🟡 **Force Unwrap Detected** (line 89)
416
- **Severity**: High
417
- **Issue**: Force unwrapping can crash if data is nil
118
+ <details>
119
+ <summary>Clone this repository</summary>
418
120
 
419
- Current Code:
420
- ```swift
421
- let user = repository.currentUser!
121
+ ```bash
122
+ git clone https://github.com/Viniciuscarvalho/swift-code-reviewer-skill.git ~/.claude/skills/swift-code-reviewer-skill
422
123
  ```
423
124
 
424
- Recommended Fix:
425
- ```swift
426
- guard let user = repository.currentUser else {
427
- logger.error("No current user")
428
- return
429
- }
430
- ```
431
- ```
125
+ </details>
432
126
 
433
- ### Example 2: Review Against Project Standards
127
+ <details>
128
+ <summary>Manual installation</summary>
434
129
 
435
- **Input:**
436
- ```
437
- Review LoginView.swift against our coding standards
130
+ ```bash
131
+ mkdir -p ~/.claude/skills/swift-code-reviewer-skill/references
438
132
  ```
439
133
 
440
- **Output:**
441
- ```markdown
442
- # Project Standards Review
134
+ Download the files from this repository into the directory, then restart Claude.
443
135
 
444
- ## .claude/CLAUDE.md Compliance
136
+ </details>
445
137
 
446
- ✅ **Architecture Adherence**
447
- - Follows MVVM pattern correctly
448
- - No business logic in view
449
- - Dependencies injected properly
138
+ <details>
139
+ <summary>Uninstall</summary>
450
140
 
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
141
+ ```bash
142
+ npx swift-code-reviewer-skill uninstall
465
143
  ```
466
144
 
467
- ## Requirements
145
+ </details>
468
146
 
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
147
+ ## Integration with Other Skills
483
148
 
484
- For runtime analysis, use Instruments or other profiling tools alongside this skill.
149
+ This skill optionally leverages **swift-best-practices**, **swiftui-expert-skill**, and **swiftui-performance-audit** for deeper analysis. It works independently with its own comprehensive checklists.
485
150
 
486
151
  ## Contributing
487
152
 
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
153
  1. Edit `SKILL.md` for main skill logic
501
154
  2. Update reference files in `references/` for specific checklists
502
155
  3. Test with real Swift/SwiftUI code
@@ -504,33 +157,12 @@ To modify the skill:
504
157
 
505
158
  ## License
506
159
 
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
160
+ MIT License - See [LICENSE](LICENSE) file for details.
531
161
 
532
162
  ---
533
163
 
534
164
  **Made with ❤️ for the Swift community**
535
165
 
536
- If this skill helps improve your code reviews, please ⭐️ star the repository!
166
+ If this skill helps your code reviews, please star the repository!
167
+
168
+ - [Issues](https://github.com/Viniciuscarvalho/swift-code-reviewer-skill/issues) | [Discussions](https://github.com/Viniciuscarvalho/swift-code-reviewer-skill/discussions)