.claude/skills/swift-macos-quality/SKILL.md
Swift macOS code quality standards — architecture, patterns, and anti-patterns for native macOS apps
npx skillsauth add mohitmujawdiya/dagabaaz swift-macos-qualityInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Apply these standards to all Swift code in this project.
No @unchecked Sendable without thread-safe internals. If a class is @unchecked Sendable, it MUST protect all mutable state with NSLock, os_unfair_lock, or an actor. Document which lock protects which state.
Prefer final class everywhere. Only omit final when subclassing is intentionally designed for. This project has no inheritance — everything is final.
No force-unwraps (!) except for IBOutlet-style patterns. Use guard let or optional chaining. Implicitly unwrapped optionals (Type!) are only acceptable for properties set during a guaranteed lifecycle phase (e.g., applicationDidFinishLaunching).
No mixed concurrency models. Never use DispatchQueue.main.async inside a @MainActor context — you're already on the main actor. Use Task { @MainActor in } from non-MainActor contexts to dispatch to main.
Callbacks from background threads to @MainActor objects must use Task { @MainActor in }. Never DispatchQueue.main.async to call into @MainActor-isolated code.
Delegate/output objects must be strongly retained. Apple frameworks often weakly reference delegates. If you create a delegate object, store it in a property. (Example: SCStream does not retain SCStreamOutput — the AudioStreamDelegate must be stored.)
Clean up on teardown. Remove notification observers, invalidate URLSessions, remove audio taps, unregister hotkeys. Use applicationWillTerminate or deinit.
Guard against duplicate setup. If show() or start() can be called multiple times, guard against creating duplicate windows/streams/connections. Check state before creating new resources.
Use enum for namespaces (types with only static members). Never use struct for stateless utility types — enum with no cases prevents accidental instantiation.
Prefer String(text.dropFirst(n)) over text.replacingOccurrences(of:) for prefix stripping. It's O(1) vs O(n) and communicates intent better.
Use Unicode escapes for special characters in code (\u{2325} for ⌥) rather than literal emoji/symbols, to avoid encoding issues across editors.
MARK comments for logical sections. Keep them consistent: // MARK: - Section Name.
Custom error types with LocalizedError conformance. Every module should have its own error enum. Always provide errorDescription.
No silent try? for operations that can meaningfully fail. Log the error at minimum. try? is only acceptable for truly optional operations (e.g., creating a directory that may already exist).
Audio processing callbacks are hot paths. Minimize allocations — no dictionary creation per frame, no string interpolation, no closure captures that cause retain/release churn. Pre-allocate buffers where possible.
calculateAudioLevel should be a static method — it needs no instance state and being static makes this clear.
development
WebSocket and Gemini Live API patterns — connection management, audio streaming, and response handling
data-ai
Swift concurrency patterns for this project — async/await, Sendable, thread safety, and MainActor usage
tools
Notch overlay UI patterns — NSPanel setup, SwiftUI overlay views, screen-sharing hiding, and display adaptation
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.