coding-best-practices

Reviews Swift 6+ macOS code against SOLID principles, SwiftData patterns, and modern concurrency practices.

Updated Mar 12, 2026
One-click install
npx skills add https://github.com/RavitejaKarra24/dotfiles --skill coding-best-practices-ravitejakarra24
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: coding-best-practices
Source: https://github.com/RavitejaKarra24/dotfiles/tree/main/agents/.agents/skills/macos-development/coding-best-practices
Command: npx skills add https://github.com/RavitejaKarra24/dotfiles --skill coding-best-practices-ravitejakarra24

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Reviewing macOS Swift code for modern idioms, architecture violations, and concurrency safety is time-consuming and easy to get wrong, especially with Swift 6 strict concurrency and evolving SwiftUI/SwiftData APIs. This Skill provides a structured, checklist-driven review process that catches critical issues like memory leaks, retain cycles, and race conditions while suggesting concrete fixes. ## Core Features & Use Cases - Systematic Code Review: Evaluates Swift code across five modules covering language idioms, SOLID/DRY architecture, SwiftData persistence, code organization, and async/await concurrency. - Prioritized Feedback: Categorizes findings as Critical (security, crashes, leaks), Important (architecture violations), or Nice-to-have (style), each with a concrete code fix. - macOS-Specific Guidance: Flags hand-rolled equivalents of baseline SwiftUI APIs like NavigationSplitView, MenuBarExtra, and formStyle(.grouped), plus focus/keyboard navigation pitfalls. - Use Case: Paste a SwiftUI view model that uses completion handlers and a singleton network manager, and receive a structured review recommending async/await conversion, dependency injection via protocols, and @MainActor isolation with example code. ## Quick Start Ask the assistant to review your Swift file or macOS component for best practices, mentioning the target macOS version and any specific concerns like concurrency or SwiftData usage.

Frequently Asked Questions about coding-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I review Swift code for SOLID principle violations?

Review each class for single responsibility, check that abstractions use protocols instead of concrete dependencies, and verify subtypes honor their base contracts. Common violations include view controllers doing networking and parsing, and fat protocols forcing empty implementations.

Should I use SwiftData or Core Data for a new macOS app?

Use SwiftData for new projects since it provides a modern @Model macro API, @Query integration with SwiftUI, and simpler migration via VersionedSchema. Core Data remains appropriate for legacy migrations, fetched results controllers with complex predicates, or features SwiftData does not yet support.

How do I fix Swift 6 strict concurrency warnings?

Mark UI-related classes with @MainActor, convert mutable shared state into actors, and make types crossing concurrency boundaries conform to Sendable. Replace completion handlers with async/await and use task groups for parallel work instead of unstructured tasks.

When should I use an actor instead of a class in Swift?

Use an actor whenever reference-type state is mutated from multiple concurrency contexts, since actor isolation prevents data races without manual locks. Classes remain appropriate for @MainActor UI objects, inheritance-based frameworks like AppKit, and immutable Sendable configuration types.

What causes retain cycles in Swift closures and how do I fix them?

Retain cycles occur when a closure strongly captures self while self also owns the closure, such as in NotificationCenter observers. Fix them with [weak self] capture lists and guard let self, or use unowned only when the captured object is guaranteed to outlive the closure.