swift_style

Original🇺🇸 English
Translated

Swift style guidelines covering naming conventions, code organization, and best practices for writing idiomatic Swift code.

3installs
Added on

NPX Install

npx skill4agent add swiftzilla/skills swift_style

Swift Style

This skill provides comprehensive style guidelines for writing clean, idiomatic, and maintainable Swift code.

Overview

Swift style guidelines cover naming conventions, access control, type selection, and code organization patterns that make your code more readable and professional.

Available References

Naming & Conventions

  • Variables and Constants -
    var
    vs
    let
    , naming conventions, immutability
  • Functions - Function naming, parameter labels, return types

Types & Protocols

  • Types - Struct vs Class vs Enum, value vs reference semantics
  • Protocols - Protocol-Oriented Programming (POP), composition, extensions

Code Organization

  • Access Control -
    public
    ,
    private
    ,
    internal
    ,
    fileprivate
    ,
    open

Quick Reference

Naming Conventions

CategoryCaseExample
Types & ProtocolsUpperCamelCase
String
,
UIViewController
Variables, FunctionslowerCamelCase
userID
,
fetchData()
Boolean Properties
is
,
has
,
should
isEmpty
,
hasPermission
ConstantslowerCamelCase
maxConnections

Type Selection Guide

Need identity or reference semantics?
├── YES → Use Class
└── NO → Need inheritance?
    ├── YES → Use Class
    └── NO → Modeling finite states?
        ├── YES → Use Enum
        └── NO → Use Struct (default)

Access Levels

ModifierVisibilityUse When
private
Enclosing declarationStrict encapsulation
fileprivate
Same fileFile-local helpers
internal
(default)
Same moduleImplementation details
public
EverywherePublic API
open
Everywhere + subclassableExtensible frameworks

Best Practices

  1. Default to structs - Use simplest type that expresses intent
  2. Use
    let
    by default
    - Only use
    var
    when mutation needed
  3. Prefer protocols over inheritance - More flexible composition
  4. Keep functions focused - Single responsibility
  5. Use access control - Expose only what's necessary
  6. Follow naming conventions - Descriptive, Swifty names

For More Information

Each reference file contains detailed information, code examples, and best practices for specific topics. Visit https://swiftzilla.dev for comprehensive Swift documentation.