swift-code-quality
Automates Swift code quality checks and enforcement for strict codebase standards.
Install
mkdir -p .claude/skills/swift-code-quality && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16744" && unzip -o skill.zip -d .claude/skills/swift-code-quality && rm skill.zipInstalls to .claude/skills/swift-code-quality
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Swift code quality rules for mach-mono — 300-line file limit, @Observable, no singletons in views, no direct Defaults access, protocol-based services. Auto-loaded when editing .swift files.Key capabilities
- →Enforce a 300-line file limit for Swift files
- →Require the use of @Observable for UI-related classes
- →Prevent direct access to `Defaults` outside `NotchSettings.swift`
- →Ensure services are protocol-based
- →Ban singletons in views and services
How it works
The skill automatically loads when a `.swift` file is edited and checks the code against predefined quality rules.
Inputs & outputs
When to use swift-code-quality
- →Check file size limits
- →Enforce clean dependency injection
- →Validate Swift architecture
About this skill
Swift Code Quality Rules
Full reference:
docs/AGENT-GUIDELINES.md→ Swift Code Quality Rules.
File Size
| Limit | Rule |
|---|---|
| 300 lines | Hard limit — files exceeding this must be split |
| 200 lines | Target — prefer smaller, focused files |
When approaching 300 lines: extract cohesive responsibilities into separate files, use extensions in separate files for protocol conformances.
No Singletons in Views or Services
// ❌ BANNED
@Bindable var coordinator = NotchViewCoordinator.shared
let manager = SomeManager.shared
// ✅ REQUIRED — environment injection
@Environment(NotchViewModel.self) private var viewModel
@Environment(\.pluginManager) private var pluginManager
// ✅ REQUIRED — init injection
init(service: SomeServiceProtocol) { ... }
Allowed .shared exceptions: NSWorkspace, NSApplication, URLSession, URLCache, XPCHelperClient, FullScreenMonitor, QLThumbnailGenerator, QLPreviewPanel, NSScreenUUIDCache, SkyLightOperator, DefaultsNotchSettings (injection root only), ScreenDisplayRegistry (system-level screen cache).
No Direct Defaults Access
// ❌ BANNED everywhere except NotchSettings.swift
Defaults[.someSetting]
@Default(.someSetting) var setting
// ✅ REQUIRED
settings.someSetting
@Environment(\.bindableSettings) private var settings
Exception: NotchSettings.swift is the only file allowed direct Defaults access.
Observable State
// ✅ REQUIRED
@Observable
@MainActor
final class SomeViewModel { ... }
// ❌ BANNED
class SomeViewModel: ObservableObject {
@Published var state: State
}
All UI-related protocols and classes must be @MainActor.
Protocol-Based Services
// Protocol in separate file
protocol SomeServiceProtocol: Sendable {
func doThing() async throws
}
// Implementation
final class SomeService: SomeServiceProtocol { ... }
Never depend on concrete service types — always use the protocol.
File Organization Order
- Imports
- Type declaration + stored properties
- Initializers
- Public/internal methods
- Private methods
- Extensions (prefer separate files for large protocol conformances)
Commit Checklist Before Submitting Swift Changes
- File stays under 300 lines (if split, both files build)
- No new
.sharedaccess in views or services - No new direct
Defaults[.]outside NotchSettings.swift - New state classes use
@Observable @MainActor final class - New services have a protocol
-
bazelisk build //Apps/machNotch:machNotchpasses
Codex Invocation
Use this skill for Swift file edits and reviews. Codex does not enforce Claude paths or user-invocable metadata, so the file-scope trigger is preserved in the description.
When not to use it
- →When developing Swift code that does not need to adhere to mach-mono quality standards
- →When working on files that are explicitly allowed exceptions, such as `NSWorkspace` for singletons
Limitations
- →The skill is specific to Swift code quality rules for mach-mono.
- →The skill applies rules to `.swift` files only.
How it compares
This skill automatically checks Swift code against a specific set of architectural and style rules, unlike manual code reviews that rely on human memory.
Compared to similar skills
swift-code-quality side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| swift-code-quality (this skill) | 0 | 3mo | No flags | Beginner |
| swift-concurrency-expert | 4 | 5mo | No flags | Advanced |
| ios-dev-guidelines | 3 | 6mo | No flags | Beginner |
| swiftui-performance-developer | 1 | 6mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
swift-concurrency-expert
Dimillian
Swift Concurrency review and remediation for Swift 6.2+. Use when asked to review Swift Concurrency usage, improve concurrency compliance, or fix Swift concurrency compiler errors in a feature or file.
ios-dev-guidelines
anyproto
Context-aware routing to Swift/iOS development patterns, architecture, and best practices. Use when working with .swift files, ViewModels, Coordinators, refactoring, or discussing Swift/SwiftUI patterns.
swiftui-performance-developer
anyproto
Audit and improve SwiftUI runtime performance through code review and Instruments guidance. Use for diagnosing slow rendering, janky scrolling, excessive view updates, or layout thrash in SwiftUI apps.
tests-developer
anyproto
Smart router to testing patterns and practices. Use when writing unit tests, creating mocks, testing edge cases, or working with Swift Testing and XCTest frameworks.
feature-toggle-developer
anyproto
Guides systematic removal of feature toggles from the codebase with automated cleanup detection. Use when removing feature flags, enabling toggles permanently, or cleaning up unused code after toggle removal.
analytics-developer
anyproto
Context-aware routing to the Anytype iOS analytics system. Use when adding analytics events, tracking user routes, or working with AnytypeAnalytics and AnalyticsConstants.