Back to skills
SKILL.md
Swift
ASecurityWrite safe Swift code avoiding memory leaks, optional traps, and concurrency bugs.
- 2 stars
- 0 votes
- 0 copies
- 0 views
- Added November 11, 2026
Works with
Security analysis
100/100Pro scans all 10 files and shows the line behind each finding
npx -y skills add johnalbertini14-glitch/openclaw-skills --skill swift --agent claude-codeAre you the author of Swift?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/johnalbertini14-glitch-swift)---
name: Swift
slug: swift
version: 1.0.1
description: Write safe Swift code avoiding memory leaks, optional traps, and concurrency bugs.
metadata: {"clawdbot":{"emoji":"π¦
","requires":{"bins":["swift"]},"os":["darwin","linux"]}}
---
## Quick Reference
| Topic | File |
|-------|------|
| Optionals, nil safety, force unwrap | `optionals.md` |
| Retain cycles, weak refs, closures | `memory.md` |
| async/await, actors, Sendable, value types | `concurrency.md` |
| JSON encoding/decoding traps | `codable.md` |
| Protocols, collections, strings, errors, build | `types.md` |
| SwiftUI state (@State, @Binding, Combine) | `swiftui.md` |
| Property wrappers, actors, result builders, macros | `advanced.md` |
| XCTest pitfalls, SPM gotchas | `testing.md` |
## Critical Rules
### Memory & Safety
- Force unwrap `!` crashes on nil β use `guard let` or `if let` instead
- Closures capturing `self` strongly create retain cycles β use `[weak self]` in escaping closures
- Delegates must be `weak` β strong delegate = object never deallocates
- `try!` crashes on any error β never use in production paths
- `removeFirst()` crashes on empty β use `popFirst()` for safety
### Concurrency
- `async let` starts immediately β not when you `await`
- Actor reentrancy at every `await` β state may change between suspension points
- `@MainActor` doesn't guarantee immediate main thread β it's queued
- `Sendable` conformance violations crash at runtime β compiler warnings are errors
### Types & Collections
- Protocol extensions don't override β static dispatch ignores subclass implementation
- Mutating struct in collection requires reassignment β `array[0].mutate()` doesn't work
- `String.Index` from one string invalid on another β even if contents match
### SwiftUI
- `@StateObject` owns, `@ObservedObject` borrows β recreating view loses ObservedObject state
- `@EnvironmentObject` crashes if not injected β no compile-time check
- View identity change resets all `@State` β changing ID loses state
### Build
- `print()` builds strings even in release β remove or use os_log
- Generic code bloat β specialized for each type, increases binary size
Files in this skill
- SKILL.md
- _meta.json
- advanced.md
- codable.md
- concurrency.md
- memory.md
- optionals.md
- swiftui.md
- testing.md
- types.md
Attribution
Related skills
View all in development βComments
Loading commentsβ¦
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.