feat: add Swift rules and SwiftUI patterns skill#244
Conversation
Add 5 rule files for Swift following the established pattern used by TypeScript, Python, and Go rule sets. Covers Swift 6 strict concurrency, Swift Testing framework, protocol-oriented patterns, Keychain-based secret management, and SwiftFormat/SwiftLint hooks.
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdds a new Swift rules subtree with five Swift-specific guideline documents plus a Swift SKILL, and updates Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
rules/swift/coding-style.md (1)
8-8: Consider hyphenating compound adjective (applies to all Swift rule files).Static analysis correctly identified that "Swift specific" should be hyphenated as "Swift-specific" when used as a compound adjective. This same pattern appears in line 8 of all five Swift rule files (hooks.md, patterns.md, testing.md, security.md, coding-style.md).
📝 Proposed fix for consistent hyphenation
Apply this change to line 8 in all five Swift rule files:
-> This file extends [common/xxx.md](../common/xxx.md) with Swift specific content. +> This file extends [common/xxx.md](../common/xxx.md) with Swift-specific content.Files to update:
- rules/swift/hooks.md:8
- rules/swift/patterns.md:8
- rules/swift/testing.md:8
- rules/swift/security.md:8
- rules/swift/coding-style.md:8
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@rules/swift/coding-style.md` at line 8, Replace instances of the unhyphenated compound adjective "Swift specific" with the hyphenated form "Swift-specific" in the five Swift rule files where it appears (e.g., the sentence that currently reads "This file extends [common/coding-style.md] with Swift specific content."); search for the exact phrase "Swift specific" in rules/swift/hooks.md, patterns.md, testing.md, security.md, and coding-style.md and update each occurrence to "Swift-specific" to ensure consistent compound adjective hyphenation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@rules/swift/coding-style.md`:
- Line 8: Replace instances of the unhyphenated compound adjective "Swift
specific" with the hyphenated form "Swift-specific" in the five Swift rule files
where it appears (e.g., the sentence that currently reads "This file extends
[common/coding-style.md] with Swift specific content."); search for the exact
phrase "Swift specific" in rules/swift/hooks.md, patterns.md, testing.md,
security.md, and coding-style.md and update each occurrence to "Swift-specific"
to ensure consistent compound adjective hyphenation.
Add comprehensive SwiftUI skill covering @observable state management, view composition, type-safe NavigationStack routing, performance optimization with lazy containers, and modern preview patterns.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@skills/swiftui-patterns/SKILL.md`:
- Around line 61-72: The view currently creates its own `@State` private var
viewModel = ItemListViewModel(), so preview .environment(...) injections are
ignored; change ItemListView to read the model from the environment (replace the
`@State` property with `@EnvironmentObject` var viewModel: ItemListViewModel and
remove the inline initializer) and update the previews to inject the mock with
.environmentObject(MockItemListViewModel()) (also fix the same pattern in the
other occurrence around lines 235-243), ensuring calls like await
viewModel.load() continue to work with the environment-provided instance.
- Around line 217-223: The current Equatable implementation on
ExpensiveChartView only compares dataPoints.count which can mark different
datasets as equal; update the static func == (in struct ExpensiveChartView) to
compare a stable identifier or lightweight content instead of just count — for
example compare dataPoints' IDs (e.g. dataPoints.map { $0.id }) or
compute/compare a small hash of the dataPoints contents, or, if DataPoint
conforms to Equatable, compare the arrays directly (dataPoints ==
other.dataPoints) so that real differences trigger re-renders.
Fix ItemListView to accept viewModel via init with default parameter so previews can inject mocks. Fix ExpensiveChartView Equatable to compare full array instead of only count.
LGTM — Swift rules and SwiftUI patterns skill. Pure documentation, no security concerns.
Summary
rules/swift/) following the same pattern as TypeScript, Python, and Go rule setscommon/counterpart with Swift-specific content covering Swift 6 strict concurrency, Swift Testing framework, protocol-oriented patterns, Keychain-based secrets, and SwiftFormat/SwiftLint hooksswiftui-patternsskill with comprehensive coverage of@Observablestate management, view composition, type-safeNavigationStackrouting, performance optimization, and modern preview patternsrules/README.mdto include Swift in the directory tree, install script examples, and manual installation commandsNew Files
rules/swift/coding-style.mdletovervar, value types, Apple API naming, typed throws, strict concurrencyrules/swift/testing.md@Test,#expect), parameterized tests, coveragerules/swift/patterns.mdrules/swift/security.mdProcessInfo.environment, input validationrules/swift/hooks.mdswift build,print()warningskills/swiftui-patterns/SKILL.md@Observablestate management, view composition,NavigationStackrouting, lazy containers, previewsTest plan
node scripts/ci/validate-rules.jspasses (29 rule files)node scripts/ci/validate-skills.jspasses (44 skill directories)markdownlintpasses on all new filespathstargeting**/*.swiftand**/Package.swift> This file extends [common/xxx.md]referenceswift-actor-persistence,swift-protocol-di-testingSummary by CodeRabbit
New Features
Documentation