Swift Modernization Cleanup Workflow
Purpose
Modernize existing Swift code without leaving cleanup half-done.
This is the top-level shared Swift repair workflow for poor-quality implementations, drifted source trees, unclear APIs, imperative pipeline tangles, old concurrency patterns, broad files, and weak validation.
Ownership
- Use this skill for shared Swift language cleanup.
- Use
apple-dev-skillsfor Apple framework behavior, Xcode execution, project membership, UI previews, signing, simulators, devices, and Apple docs gates. - Use
server-side-swiftfor Vapor, Hummingbird, SwiftNIO service hosting, persistence, Docker, Fly.io, auth, observability, and deployment.
Workflow
- Inspect before changing:
AGENTS.md- README or CONTRIBUTING
Package.swift.swiftformat.swiftlint.yml- Xcode or XcodeGen files when present
- CI workflows
- existing validation commands
- Establish the formatting baseline through
swift-format-style-workflow. - Inventory cleanup targets:
- oversized files
- mixed responsibilities
- unclear public or internal APIs
- callback-heavy or nested async code
- mutable shared state
- imperative parser, loader, or transform pipelines
- weak error shapes and log messages
- duplicate helpers
- stale TODO/FIXME comments
- missing or weak tests around changed behavior
- Plan coherent slices:
- source organization
- API shape and naming
- functional data pipelines
- concurrency boundaries
- error and logging quality
- tests
- docs handoffs
- Apply complete passes:
- avoid tiny partial edits when adjacent cleanup is part of the same concern
- split files when concern boundaries are real
- remove duplicate paths and stale wrappers
- keep behavior validation close to each slice
- Format again after structural changes.
- Validate serially with the narrowest useful commands.
Modernization Defaults
- Prefer Swift concurrency over callback pyramids when the target platform and repository support it.
- Prefer value flow over hidden mutation.
- Prefer functional pipelines for transformation-heavy code.
- Prefer
swift-error-handling-style-workflowfor broad failure-shape cleanup, typed throws decisions, domain error modeling, Cocoa bridging, and diagnostics. - Prefer typed domain models over dictionaries, strings, or loosely coupled tuples.
- Prefer small support files with one clear job.
- Prefer tests around behavior before and after risky cleanup.
- Prefer human-readable errors that explain what operation failed and what to inspect next.
Output Shape
Return:
Cleanup state: the current risks and code smells.Slice plan: ordered cleanup slices and why each belongs.Changes: files and responsibilities changed.Handoffs: Apple, server-side, docs, project, or deployment owners.Validation: commands run, results, and manual gaps.
Guardrails
- Do not start with broad rewrites before reading repo guidance and validation commands.
- Do not leave compatibility shims, duplicate code paths, or transitional wrappers unless Gale explicitly approves.
- Do not silently change public API compatibility or deployment behavior.
- Do not run multiple SwiftPM or Xcode build/test commands concurrently.
- Do not claim runtime behavior is validated when only formatting or static checks ran.