Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Swift Pro

ASecurity

Idiomatic Swift: value types, optionals, protocols, structured concurrency, and SwiftUI/UIKit patterns. Use when writing, reviewing, or structuring Swift apps.

2 stars
0 votes
0 copies
0 views
Added 9/29/2026
ai-agentsgoswifttestingdebuggingapiperformance

Works with

api

Security Analysis

A100/100

Scanned 9/29/2026

$npx -y skills add aicodedecode/awesome-muse-skills --skill swift-pro --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Swift Pro?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Swift Pro
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/aicodedecode-swift-pro/badge)](https://www.skillsdirectory.com/skills/aicodedecode-swift-pro)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: swift-pro
description: Idiomatic Swift: value types, optionals, protocols, structured concurrency, and SwiftUI/UIKit patterns. Use when writing, reviewing, or structuring Swift apps.
category: development
---

# Swift Pro

## Overview

Swift rewards **safety by construction**: optionals instead of nulls, value types by default,
protocols over inheritance, and a compiler that catches entire bug families. Professional Swift
means leaning into these — modeling with structs and enums, handling optionals explicitly, using
structured concurrency instead of callback pyramids, and writing code the compiler can verify.

The through-line: make invalid states unrepresentable, handle the absent case explicitly, and let
the type system do the worrying.

## When to use

- Writing or reviewing Swift code for idiom and safety.
- Structuring iOS/macOS apps (SwiftUI or UIKit).
- Choosing value vs reference types, or designing protocol abstractions.
- Using async/await, actors, and structured concurrency.
- Debugging optionals, retain cycles, or concurrency issues.

## Core concepts

- **Value types by default.** `struct` for data and domain models — copied on assignment, no
  shared-mutable-state surprises, thread-safe by construction. `class` only when you need identity,
  shared mutable state, or inheritance (rare). Enums with associated values model states beautifully.
- **Optionals are explicit.** `if let`/`guard let` for unwrapping, `map`/`flatMap` for transforms,
  nil-coalescing for defaults. Force-unwrap (`!`) only for true invariants (IBOutlets after load)
  — never on network data or user input. Implicitly-unwrapped optionals are a code smell outside
  narrow cases.
- **Protocols + extensions.** Protocol-oriented design: small protocols, default implementations
  via extensions, composition over inheritance. But don't protocol-everything preemptively —
  concrete types first, protocols when you have two conformers or a testing seam.
- **Structured concurrency.** `async`/`await` for asynchronous work, `Task` groups for fan-out,
  `actor` for isolated mutable state. Say goodbye to callback pyramids and manual GCD queue
  hopping. Respect `@MainActor` for UI updates; don't block the main actor.
- **Error handling with `throws`.** Typed throws (Swift 6) for precise error modeling; `do/catch`
  at boundaries, `try?`/`try!` only where failure is truly uninteresting/impossible. `Result`
  type when errors are values to pass around rather than control flow.
- **Memory: ARC + weak/strong discipline.** Retain cycles via closures capturing `self` strongly —
  `[weak self]` in escaping closures that outlive their context. Value types sidestep most of this;
  reference cycles are a class-design problem.

## Practical workflow

1. **Model first.** Structs for data, enums with associated values for states/results, protocols
   for the seams you'll actually test or vary.
2. **Handle absence explicitly.** No force-unwraps on external data; `guard let` early for
   preconditions; meaningful defaults via `??`.
3. **Write async code structurally.** `async` functions, `TaskGroup` for parallel work, actors for
   shared mutable state. Migrate legacy completion handlers with `withCheckedContinuation` at the
   boundary.
4. **Organize by feature.** Group related models, views, and logic (`Features/Checkout/`) rather
   than by type (`Models/`, `Views/`). Keep views dumb; move logic to view models or domain types.
5. **Test the logic, not the framework.** Unit-test domain types, view models, and parsers with
   XCTest/Swift Testing; UI tests only for critical journeys. Inject dependencies via protocols
   for testability.
6. **Mind the platform.** Respect main-actor isolation, handle background/foreground transitions,
   test on device for performance and memory, and profile with Instruments before optimizing.

Idiomatic snippets:

```swift
// Enum states + async/await + guard
enum LoadState<T> {
    case idle, loading, loaded(T), failed(Error)
}

func refresh() async {
    state = .loading
    do {
        let items = try await store.fetchItems()
        state = .loaded(items)
    } catch {
        state = .failed(error)
    }
}

// Weak capture in escaping closures
service.onUpdate = { [weak self] items in
    guard let self else { return }
    self.items = items
}
```

## Common pitfalls

- **Force-unwrap roulette.** `!` on optionals from JSON, user input, or casts — crashes in
  production. Every `!` should have a justification a reviewer can verify.
- **Massive view controllers / views.** 1,000-line view files doing networking, parsing, and
  layout. Extract: view models for state, services for I/O, small composable views.
- **Retain cycles.** Closures capturing `self` strongly in long-lived objects (timers, network
  callbacks, notification observers). `[weak self]` + `guard let self` is the reflex.
- **Blocking the main thread.** Synchronous networking, JSON parsing of large payloads, or image
  processing on main — jank and watchdog kills. Move to background, update UI on main actor.
- **Over-protocoling.** A protocol for every struct "for testability" before there's a second
  implementation. Concrete types are simpler; add protocols at real seams.
- **Ignoring Swift 6 concurrency checking.** Data races flagged by the compiler are real bugs.
  Adopt `Sendable`, respect actor isolation — don't silence with `@unchecked Sendable` without
  understanding why.
- **Stringly-typed APIs.** String constants for states, notification names as raw strings.
  Enums, typed notification wrappers, and `#function`-based identifiers prevent typo-bugs.

Attribution

aicodedecodeaicodedecode
View sourceSee grades on GitHubMore from aicodedecode →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698461 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →