rules-swift

Enforce Swift coding and testing rules aligned with Apple API Design Guidelines.

4|1|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/NSObjects/specpowers --skill rules-swift
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rules-swift
Source: https://github.com/NSObjects/specpowers/tree/main/skills/rules-swift
Command: npx skills add https://github.com/NSObjects/specpowers --skill rules-swift

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevents Swift code from drifting away from Apple API conventions and ensures Swift-specific rules override the universal guidance so teams ship consistent, readable code.

Core Features & Use Cases

  • Naming & Style Enforcement: Prescribes PascalCase for types, camelCase for functions, guard-heavy logic, swift-format/SwiftLint formatting, and well-structured files with MARK sections.
  • Type Safety & Error Handling: Encourages value types, optionals, throwing errors with typed enums, Result usage, and explicit guard statements to keep failure paths clear.
  • Testing, Immutability & Concurrency Guidance: Supports XCTest or Swift Testing workflows, default immutability with let, and modern async/await, actors, and TaskGroup patterns while avoiding retain cycles and force unwraps.

Quick Start

Use the rules-swift skill to audit a Swift module and highlight naming, formatting, and concurrency patterns that do not align with Apple conventions.

Frequently Asked Questions about rules-swift

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

FAQPage Schema
How do I enforce Swift naming conventions and formatting rules in a code review?

Enforce Swift coding rules by applying PascalCase for types, camelCase for functions, guard-heavy logic, and swift-format formatting to keep code aligned with Apple API Design Guidelines. Structuring files with MARK sections also keeps modules readable and consistent.

What is the best way to handle error handling and optionals in Swift projects?

The best way to handle Swift errors is using throwing errors with typed enums, Result usage, and explicit guard statements. You should prefer value types and default immutability with let while avoiding force unwraps to keep failure paths clear and safe.

How do I prevent retain cycles when using async/await and actors in Swift?

Prevent retain cycles in Swift concurrency by adopting modern async/await, actors, and TaskGroup patterns while explicitly avoiding force unwraps. Documenting override rationales for concurrency rules ensures your asynchronous code remains safe and consistent.

Does this Swift style guidance work with both XCTest and Swift Testing workflows?

Yes, this Swift style guidance supports both XCTest and Swift Testing workflows. It enforces testing rules that keep Swift projects consistent with Apple API Design Guidelines regardless of the testing framework you choose for your modules.

Why should I prefer structs and immutability when writing Swift code?

You should prefer structs and immutability in Swift to ensure type safety and prevent unintended side effects. Using let for default immutability and favoring value types keeps your code predictable while aligning with Apple API Design Guidelines.

When do I need to override universal coding rules for Swift specific patterns?

You need to override universal coding rules for Swift when your project requires specific naming, formatting, testing, error handling, immutability, or concurrency patterns. Documenting the override rationales ensures your Swift code stays aligned with Apple API Design Guidelines.