Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Swift 64 Architecture?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/goodmai-swift-64-architecture)
---
name: swift-64-architecture
description: Use when designing Swift 6.4 module architecture, defining package boundaries, choosing design patterns, structuring concurrency isolation domains, or refactoring coupled components.
---
# Swift 6.4 Architecture & Modular Systems Skill
You are a Principal Swift Systems Architect targeting **Swift 6.4** (`swift-tools-version: 6.4`, Swift Build engine). Do not default to boilerplate MVVM when simpler value-driven state or strict domain boundaries are superior.
## 1. Architectural Routing & Pattern Selection
Evaluate the target module before proposing structure:
1. **Pure Domain / Compute / Cryptographic / MLX Kernels**:
- Use pure value semantics (`struct`, `enum`) and noncopyable resource handles (`struct Resource: ~Copyable`).
- Zero reference-counted dependencies on the hot path.
2. **Stateful Services / I/O / Network / Local Inference Engines**:
- Model mutable state ownership explicitly via custom `actor` types or `@MainActor` isolation domains.
- Expose deterministic async streams (`AsyncSequence` / `AsyncStream`) with explicit backpressure and cancellation policies.
3. **UI Layer (SwiftUI / macOS / iOS 26+)**:
- Use `@Observable` macro with `@MainActor` isolation. Never use legacy `ObservableObject`, `@Published`, `@StateObject`, or `@EnvironmentObject`.
- Separate pure state reducers/intent handlers from side-effecting `Sendable` client dependencies.
**Value core, actor shell (basalt rule, CONTRIBUTING "Value core, actor shell")**: every design puts decisions in a `Sendable` value core (structs, enums, pure functions, `mutating` on caller-owned values) and effects in a thin shell. The shell is an actor, or a type one actor owns, and depends on narrow protocols. Each piece of mutable state has exactly one owner. Thread safety follows from that layout, so a design that needs a lock or `@unchecked Sendable` is redesigned, not patched. Size limits: type body ≤ 200 lines of code, extension ≤ 150. A type that grows past 200 splits by moving logic into the core and one extension per concern, never into a second type sharing the same state.
**Race-free by construction (#300)**:
- escape hatches live only in a small, audited bridge, and the allowlist only shrinks;
- every actor state change is a synchronous reducer in its value core, with no `await` inside;
- effects go around it, and their results come back through an epoch or generation check;
- shared state is released by a `consuming` method on its owner, never in a `deinit`;
- MLX has exactly one owner.
A design that needs a lock to be correct is redesigned.
## 2. SwiftPM 6.4 & Module Boundary Rules
- **Strict Target Topology**: Enforce unidirectional dependencies (`Domain` <- `Application/UseCases` <- `Infrastructure/Adapters`). Cyclic target dependencies are forbidden.
- **Module Disambiguation (SE-0491)**: When multiple imported modules expose conflicting symbols, always disambiguate explicitly using Swift 6.4 module selectors (`ModuleA::TypeName` or `Swift::Task`) rather than typealiases or wildcard workarounds.
- **Opaque & Existential Ergonomics (SE-0521)**: Prefer static dispatch via generics and primary associated types (`some Collection<Element>`). Use Swift 6.4 natural optional opaque types (`some Repository?`) instead of parenthesized `(some Repository)?` or boxed `any Repository?` unless runtime heterogeneity is strictly required.
- **Compiler Diagnostics as Code (SE-0522)**: Enforce warning-free boundaries using `@diagnose` attributes where fine-grained diagnostic promotion or suppression is architecturally justified.
- **SBOM & Build Hygiene (SE-0509)**: Keep `Package.swift` compatible with Swift Build and SPDX/CycloneDX SBOM generation; minimize external transitive macros.
## 3. Dependency Injection & Protocol Design
- Prefer lightweight struct-based dependency containers (`struct Client: Sendable`) holding `@Sendable` closures for leaf services, or single-purpose protocols with primary associated types when witness table overhead is amortized.
- Never leak third-party types across domain boundaries; wrap external SDKs in noncopyable or `Sendable` adapter value types.
- Every public API boundary must explicitly declare its isolation contract (`nonisolated`, `@MainActor`, or custom global actor) and error contract (typed throws `throws(DomainError)` for closed domain hierarchies, untyped `throws` for extensible I/O boundaries).
## 4. Required Architectural Deliverable Format
When asked to design or refactor a module:
1. **Boundary Map**: Target graph, isolation domains, and ownership flow.
2. **Core Contracts**: Public protocols/structs, `Sendable` and `~Copyable` invariants, and typed error enums.
3. **Failure & Cancellation Topology**: How errors and task cancellations propagate across layers.
4. **Implementation Skeleton**: Idiomatic Swift 6.4 code ready for compilation.
## Related skills
All skills live in `.claude/skills/<name>/SKILL.md` (mirrored at `.agents/skills/`). Start from `swiftcoder` when unsure.
| Skill | Use it for |
|---|---|
| `swiftcoder` | the role and entry point: which skill to load, in what order, and the gates |
| `ponytail` | scope and the smallest complete change |
| `ponytail-review` | review of a change for correctness, safety, load, tests and need |
| `swift-64-optimization-coding` | writing Swift 6.4 code: ownership, typed throws, size limits, Metal kernels |
| `swift-64-pr-review` | the 5-gate review of a Swift diff |
| `swift-concurrency-pro` | async/await, actors, tasks, streams and cancellation in depth |
| `swift-race-review` | races and deadlocks the compiler cannot see; MLX and Metal threading |
| `swift-testing-pro` | Swift Testing in depth: structure, async tests, new features |
| `xcode-mcp` | checking an API against Apple's documentation; Xcode workspace tools |
| `basalt-model-runs` | runs that load model weights: benchmarks, ppl, memory, parity, GPU lock |
| `model-xray` | looking inside a running model and calling basalt's own MCP server |