New advertisers: 50% off your first month with code FIRSTMONTHSee slots

Swift style conventions covering naming, golden-path control flow, spacing, and access control for readable code.

skills.sh installs
1.5K
GitHub stars
233
last updated
Aug 21, 2026
View on GitHub

What it does

  • Covers naming, golden-path control flow, code organization, spacing, self usage, closures, and memory management
  • Includes preferred and avoided examples for guard early returns, MARK-grouped extensions, and [weak self] captures
  • Enforces full spelling of abbreviations except URL, ID, and UUID, and explicit private over fileprivate
  • Designed for writing Swift code that compiles without warnings and reads consistently across a codebase

Install

$ npx -y skills add johnrogers/claude-swift-engineering --skill swift-style -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Swift Style Guide

Code style conventions for clean, readable Swift code.

Core Principles

Clarity > Brevity > Consistency

Code should compile without warnings.

Naming

  • UpperCamelCase — Types, protocols
  • lowerCamelCase — Everything else
  • Clarity at call site
  • No abbreviations except universal (URL, ID)
// Preferred
let maximumWidgetCount = 100
func fetchUser(byID id: String) -> User

Golden Path

Left-hand margin is the happy path. Don't nest if statements.

// Preferred
func process(value: Int?) throws -> Result {
    guard let value = value else {
        throw ProcessError.nilValue
    }
    guard value > 0 else {
        throw ProcessError.invalidValue
    }
    return compute(value)
}

Code Organization

Use extensions and MARK comments:

class MyViewController: UIViewController {
    // Core implementation
}

// MARK: - UITableViewDataSource
extension MyViewController: UITableViewDataSource { }

Spacing

  • Braces open on same line, close on new line
  • One blank line between methods
  • Colon: no space before, one space after

Self

Avoid self unless required by compiler.

Details

Repository
github.com/johnrogers/claude-swift-engineering
Categories
Code Review & Quality, Mobile Apps

More from johnrogers/claude-swift-engineering

All 10

Similar to Swift Style

More Code Review & Quality