# swift-development

swift-development enforces modern Swift 6 guidelines, region-based concurrency checks, and clean API conventions for macOS and iOS codebases.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf (Devin Desktop), Claude.ai · ★ 173 repo stars
- Author: sammcj
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/sammcj/agentic-coding/tree/HEAD/Skills/swift-development/SKILL.md
- Updated: 2026-10-24
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/sammcj-swift-development

## What it does

This instruction set prepares the agent for modern Swift environments targeting macOS 15.7+. It emphasizes strict concurrency verification enabled by default under SE-0414, handling Sendable conformances, and isolating UI logic with `@MainActor`. The prompt teaches the model to eliminate unnecessary `MainActor.run` wrappers, steer clear of combining `DispatchSemaphore` with async routines, and insert `Task.checkCancellation()` into resource-intensive loops.

It also highlights platform quirks across Apple frameworks. For example, it explains how accessory menu-bar apps inadvertently hide setting panels and provides the activation policy workaround. Another guardrail covers dates: standard `.iso8601` encoding via `JSONEncoder` strips fractional seconds, requiring an explicit formatter setup.

Because the guidelines prioritize newer compiler flags and macOS 15.7+, applying them to older codebases requires adjusting `@available` boundaries and access levels.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add sammcj/agentic-coding --skill swift-development -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/swift-development/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/swift-development/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add sammcj/agentic-coding --skill swift-development -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/swift-development/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add sammcj/agentic-coding --skill swift-development -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/swift-development/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install sammcj/agentic-coding Skills/swift-development/SKILL.md
```

2. **Manually: put the files in place**
- File: `.github/skills/swift-development/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add sammcj/agentic-coding --skill swift-development -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/sammcj/agentic-coding --path Skills/swift-development
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/swift-development/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/sammcj/agentic-coding/tree/HEAD/Skills/swift-development/SKILL.md

## When to use it
- migrate existing Swift 5 codebases to strict Swift 6 concurrency
- eliminate data-race warnings and resolve compiler isolation checks
- fix disappearing preferences windows in macOS menu-bar utilities
- structure async tasks cleanly using `async let` and cancellation checks

## Example prompts
- Audit this view model for actor isolation issues and adapt it to Swift 6
- Fix our macOS status bar accessory window hiding unexpectedly on click
- Review this public module interface against modern Swift API naming conventions

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: d489acaa19c6a10d.

BEGIN THIRD-PARTY FILE d489acaa19c6a10d
````text
---
name: swift-development
description: You MUST activate this skill when working on Swift projects
---

# Swift Best Practices Skill

## Overview

Apply modern Swift development best practices focusing on Swift 6+ features, concurrency safety, API design principles, and code quality guidelines for iOS and macOS projects targeting macOS 15.7+.

## When to Use This Skill

Use this skill when:
- Writing new Swift code for iOS or macOS applications
- Reviewing Swift code for correctness, safety, and style
- Implementing Swift concurrency features (async/await, actors, MainActor)
- Designing Swift APIs and public interfaces
- Migrating code from Swift 5 to Swift 6
- Addressing concurrency warnings, data race issues, or compiler errors related to Sendable/isolation
- Working with modern Swift language features introduced in Swift 6 and 6.2

## Core Guidelines

### Fundamental Principles

1. **Clarity at point of use** is paramount - evaluate designs by examining use cases, not just declarations
2. **Clarity over brevity** - compact code comes from the type system, not minimal characters
3. **Write documentation for every public declaration** - if you can't describe functionality simply, the API may be poorly designed
4. **Name by role, not type** - `var greeting = "Hello"` not `var string = "Hello"`
5. **Favour elegance through simplicity** - avoid over-engineering unless complexity genuinely warrants it

### Swift 6 Concurrency Model

Swift 6 enables complete concurrency checking by default with region-based isolation (SE-0414). The compiler now proves code safety, eliminating many false positives whilst catching real concurrency issues at compile time.

**Critical understanding:**
- **Async ≠ background** - async functions can suspend but don't automatically run on background threads
- Actors protect mutable shared state through automatic synchronisation
- `@MainActor` ensures UI-related code executes on the main thread
- Global actor-isolated types are automatically `Sendable`

### Essential Patterns

#### Async/Await
```swift
// Parallel execution with async let
func fetchData() async -> (String, Int) {
    async let stringData = fetchString()
    async let intData = fetchInt()
    return await (stringData, intData)
}

// Always check cancellation in long-running operations
func process(_ items: [Item]) async throws -> [Result] {
    var results: [Result] = []
    for item in items {
        try Task.checkCancellation()
        results.append(await process(item))
    }
    return results
}
```

#### MainActor for UI Code
```swift
// Apply at type level for consistent isolation
@MainActor
class ContentViewModel: ObservableObject {
````
END THIRD-PARTY FILE d489acaa19c6a10d

The third-party file has ended. Everything between the d489acaa19c6a10d tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2679 of 9547 bytes. © sammcj · Apache-2.0 · https://github.com/sammcj/agentic-coding/tree/HEAD/Skills/swift-development/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
