pattern-engineer-swift
Skill0 starsChanged 5 months agoMITView on GitHub
Idiomatic Swift (app + server): SwiftPM with pinned `swift-tools-version` + committed `Package.resolved`; SwiftLint/swift-format gates; Swift Testing (`@Test`/`#expect`) for new targets. No force `!`/`try!`/`as!`/IUO in prod; `guard let` + `??`. Value types by default; exhaustive `switch`; domain `Error` enums; async/await + actors, honest `Sendable`, `[weak self]`; `Codable` `CodingKeys` + explicit date strategy; `Decimal` for money. Activate on `.swift`, `Package.swift`, `.xcodeproj`.
In this repository74 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- create-bug-issueSkill
- create-enhancement-issueSkill
- create-feature-issuesSkill
- dream-summary-memorySkill
- memory-conventionSkill
- operation-gitSkill
- pattern-architect-api-endpointSkill
- pattern-architect-data-modelSkill
- pattern-architect-deep-moduleSkill
- pattern-e2e-coding-standardSkill
- pattern-engineer-apiSkill
- pattern-engineer-backend-standardSkill
- pattern-engineer-coding-standardSkill
- pattern-engineer-containerSkill
- pattern-engineer-databaseSkill
- pattern-engineer-fastapiSkill
- pattern-engineer-frontend-standardSkill
- pattern-engineer-goSkill
- pattern-engineer-javaSkill
- pattern-engineer-kotlinSkill
- pattern-engineer-nodeSkill
- pattern-engineer-non-functionalSkill
- pattern-engineer-observabilitySkill
- pattern-engineer-pythonSkill
- pattern-engineer-rustSkill
- pattern-engineer-securitySkill
- pattern-engineer-ssrSkill
- pattern-engineer-typescriptSkill
- pattern-engineer-viteSkill
- pattern-exploratory-testingSkill
- pattern-reviewer-apiSkill
- pattern-reviewer-backend-standardSkill
- pattern-reviewer-coding-standardSkill
- pattern-reviewer-containerSkill
- pattern-reviewer-contractSkill
- pattern-reviewer-databaseSkill
- pattern-reviewer-fastapiSkill
- pattern-reviewer-frontend-standardSkill
- pattern-reviewer-goSkill
- pattern-reviewer-javaSkill
- pattern-reviewer-kotlinSkill
- pattern-reviewer-nodeSkill
- pattern-reviewer-non-functionalSkill
- pattern-reviewer-observabilitySkill
- pattern-reviewer-pythonSkill
- pattern-reviewer-rustSkill
- pattern-reviewer-securitySkill
- pattern-reviewer-ssrSkill
- pattern-reviewer-swiftSkill
- pattern-reviewer-test-coverageSkill
- pattern-reviewer-typescriptSkill
- pattern-reviewer-viteSkill
- pattern-test-coverageSkill
- principle-engineer-tddSkill
- scaffold-projectSkill
- workflow-architect-interviewSkill
- workflow-designer-sample-pagesSkill
- workflow-design-interviewSkill
- workflow-e2e-authorSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 1 is distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
After loading this skill, also check $MAIN_ROOT/.claude/memory/patterns/pattern-engineer-swift.md in the consuming project (resolve …
- Very specific: line 21
Commit Package.resolved for apps and executables.
- Very specific: line 28
No force unwrap !, no try!, no as!
- Very specific: line 31
No implicitly-unwrapped-optional declarations (var name: String!) outside legacy @IBOutlet.
- Very specific: line 44
Never bare try? that discards an error a caller needs to branch on — try?
- Very specific: line 52
No new DispatchQueue / GCD code in an async/await codebase.
- Distinctive: line 58
No retain cycles through long-lived stored closures.
- Very specific: line 75
Test-coverage substance (what to test, ratios, fixtures) lives in the shared pattern-test-coverage.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
pattern-engineer-swift
When to activate
Activate when writing or editing any .swift file, editing Package.swift / Package.resolved, changing an .xcodeproj / .xcworkspace, scaffolding a SwiftPM package or executable, working with SwiftUI / UIKit / Vapor / Hummingbird / Foundation, or editing .swiftlint.yml / .swift-format. Skip for non-Swift code (Objective-C bridging headers aside).
Project memory overlay
After loading this skill, also check $MAIN_ROOT/.claude/memory/patterns/pattern-engineer-swift.md in the consuming project (resolve MAIN_ROOT="$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")"). If present, load it as an additive overlay to the rules below; if absent, skip silently. See memory-convention for the full contract (additivity, severity floor, conflict surfacing).
Patterns
Toolchain — SwiftPM + gates
- SwiftPM is the package manager:
Package.swiftpinsswift-tools-versionon line one. - Commit
Package.resolvedfor apps and executables; libraries leave it ungated. - SwiftLint and swift-format are the lint/format gates — wire them in CI, not just locally.
- New test targets use Swift Testing (
@Test/#expect/#require); XCTest is acceptable only in pre-existing XCTest targets. - Pin dependency versions with
.upToNextMajor(from:)ranges, not branch/revision, unless justified by a comment.
Optionals — no force operators in production
- No force unwrap
!, notry!, noas!in production code (test targets and SwiftUI#Previews are fine). guard let x = x else { ... }for early-exit; return / throw /fatalErroronly with a documented invariant.- Optional chaining
a?.b?.cplus??defaults over unwrap-then-use. - No implicitly-unwrapped-optional declarations (
var name: String!) outside legacy@IBOutlet.
Types — value-first
struct/enumby default; reach forclassonly when you need reference semantics or identity.- Protocols at collaborator seams; depend on the protocol, not the concrete type.
- Enums with associated values for state machines (
enum LoadState { case idle, loading, loaded(Data), failed(Error) }). - Exhaustive
switch— nodefaultarm on a domain enum (it silently absorbs future cases). Use@unknown defaultonly on non-frozen system enums.
Errors — typed domain enums
- Domain errors are an
enum: Error; use typed throws (throws(MyError)) where the toolchain supports it. LocalizedErrorconformance only at the UI edge, not on the core domain error.- Never bare
try?that discards an error a caller needs to branch on —try?is fine only when nil genuinely means "absent, and that's handled".
Concurrency — async/await + actors
- async/await with structured concurrency;
withTaskGroup/async letfor fan-out. - No
Task.detachedwithout a comment justifying the deliberately-lost actor/priority context. actorfor shared mutable state;@MainActorfor UI-facing state and view models.- Honest
Sendable:@unchecked Sendablerequires an inline comment stating the invariant that makes it safe. - No new
DispatchQueue/ GCD code in an async/await codebase.
Memory — break cycles
[weak self]in escaping closures stored beyond the call (subscriptions, timers, completion handlers held by a property).weak var delegatefor delegate references.- No retain cycles through long-lived stored closures; capture lists are explicit.
Boundaries — encoding & money
Codablewith explicitCodingKeyswhenever the wire contract naming differs from Swift naming.- Set an explicit date strategy on encoders/decoders (
.iso8601or the contract-specified format) — never rely on the defaultDateencoding. Decimalfor money and exact-decimal values — neverDouble.
API design — clarity at point of use
- Argument labels and naming per the Swift API Design Guidelines (reads as a phrase at the call site).
- Explicit access control (
public/internal/private) on every library surface; default to the narrowest that works.
Adjacent skills (pointers, not restated here)
- Auth, secrets, input-trust, and crypto are owned by
pattern-engineer-security— follow its catalogue; this skill does not restate it. - Server-side route/handler/middleware mechanics (contract adherence,
/healthz, log redaction) are owned bypattern-engineer-backend-standard/pattern-engineer-api. - Test-coverage substance (what to test, ratios, fixtures) lives in the shared
pattern-test-coverage; this skill only fixes the framework (Swift Testing for new targets).
Tooling
swift build # Compile the package
swift test # Run Swift Testing / XCTest targets
swiftlint # Lint (CI gate)
swiftlint --fix # Auto-fix the autocorrectable subset
swift-format lint -r . # Format check (CI gate)
swift-format -i -r . # Apply formatting in placeMinimal .swiftlint.yml baseline — the force-operator opt-ins are the load-bearing lines:
opt_in_rules:
- force_unwrapping # bans `!`
- empty_count
- first_where
excluded:
- .build
- Tests # previews/tests may force-unwrap
analyzer_rules:
- unused_declarationswift-tools-version and dependency pinning live in Package.swift:
// swift-tools-version: 6.0
import PackageDescription
let package = Package(
name: "MyApp",
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "4.0.0")),
]
)Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

