Swift Format Style Workflow
Purpose
Keep Swift formatting and style enforcement explicit, consistent, and aligned with the repository.
Use this skill before and after source organization or modernization cleanup. Hand off to apple-dev-skills when the work becomes Xcode build phases, Xcode source editor behavior, project-file mutation, or Apple app validation.
Repository Inspection
Inspect:
.swiftformat
.swiftlint.yml
Package.swift
.github/workflows/
- Git hooks or hook installers
- Makefile, justfile, scripts, or CI helpers
- README, CONTRIBUTING, AGENTS, or package docs
- Xcode project or XcodeGen files only when the repo uses them
Tool Responsibility
- Treat SwiftFormat as the primary owner of whitespace, wrapping, sorting, and mechanical formatting shape.
- Treat SwiftLint as a complementary signal layer for clarity, maintainability, safety, naming, documentation expectations, and project-specific hazards.
- Do not let both tools fight over the same formatting rule.
- Prefer checked-in project-root config files for shared repositories.
- Prefer repo-pinned or package-managed tooling over untracked developer-local drift when the repo already has that pattern.
Gale Style Defaults
- Keep fluent chains compact when they read clearly.
- Do not explode readable chains into one line per tiny operation unless the chain needs diagnostic boundaries.
- Prefer shorthand closure syntax, key paths, and trailing closures when the meaning remains obvious.
- Prefer dense but readable Swift over ceremony.
- Let source organization and named intermediate values carry meaning instead of padding code with comments.
Workflow
- Classify the request:
- formatter setup
- linter setup
- style repair
- CI or hook alignment
- pre-cleanup baseline
- post-cleanup normalization
- Inspect existing config before proposing changes.
- Choose one enforcement path:
- local CLI check
- Git pre-commit hook
- CI check
- Xcode build phase handoff
- SwiftPM plugin handoff
- Run or recommend the narrowest useful command:
swiftformat --lint .
swiftformat .
swiftlint lint
- If source files will be split or moved, hand off to
swift-source-organization-workflow, then run formatting again.
Output Shape
Return:
Style state: config files and enforcement surfaces observed.
Tool split: what SwiftFormat owns and what SwiftLint owns.
Changes: config, hook, CI, or source edits.
Commands: exact commands run or recommended.
Validation: pass, fail, or skipped with concrete reason.
Guardrails
- Do not hand-format Swift when SwiftFormat is available and configured.
- Do not add SwiftLint rules as a casual cleanup without checking current repo tolerance.
- Do not introduce formatter churn unrelated to the requested work.
- Do not claim Xcode build-phase or source-editor behavior without using Apple Dev docs and handoffs.
- Do not override existing project style with a generic template.
1---2name: swift-format-style-workflow3description: Align SwiftFormat, SwiftLint, formatter and linter responsibility, checked-in style config, Git hooks, and CI formatting policy for Swift repositories. Use for shared Swift style and formatting before source-organization or modernization passes.4license: Apache-2.05---67# Swift Format Style Workflow89## Purpose1011Keep Swift formatting and style enforcement explicit, consistent, and aligned with the repository.1213Use this skill before and after source organization or modernization cleanup. Hand off to `apple-dev-skills` when the work becomes Xcode build phases, Xcode source editor behavior, project-file mutation, or Apple app validation.1415## Repository Inspection1617Inspect:1819- `.swiftformat`20- `.swiftlint.yml`21- `Package.swift`22- `.github/workflows/`23- Git hooks or hook installers24- Makefile, justfile, scripts, or CI helpers25- README, CONTRIBUTING, AGENTS, or package docs26- Xcode project or XcodeGen files only when the repo uses them2728## Tool Responsibility2930- Treat SwiftFormat as the primary owner of whitespace, wrapping, sorting, and mechanical formatting shape.31- Treat SwiftLint as a complementary signal layer for clarity, maintainability, safety, naming, documentation expectations, and project-specific hazards.32- Do not let both tools fight over the same formatting rule.33- Prefer checked-in project-root config files for shared repositories.34- Prefer repo-pinned or package-managed tooling over untracked developer-local drift when the repo already has that pattern.3536## Gale Style Defaults3738- Keep fluent chains compact when they read clearly.39- Do not explode readable chains into one line per tiny operation unless the chain needs diagnostic boundaries.40- Prefer shorthand closure syntax, key paths, and trailing closures when the meaning remains obvious.41- Prefer dense but readable Swift over ceremony.42- Let source organization and named intermediate values carry meaning instead of padding code with comments.4344## Workflow45461. Classify the request:47 - formatter setup48 - linter setup49 - style repair50 - CI or hook alignment51 - pre-cleanup baseline52 - post-cleanup normalization532. Inspect existing config before proposing changes.543. Choose one enforcement path:55 - local CLI check56 - Git pre-commit hook57 - CI check58 - Xcode build phase handoff59 - SwiftPM plugin handoff604. Run or recommend the narrowest useful command:61 - `swiftformat --lint .`62 - `swiftformat .`63 - `swiftlint lint`645. If source files will be split or moved, hand off to `swift-source-organization-workflow`, then run formatting again.6566## Output Shape6768Return:69701. `Style state`: config files and enforcement surfaces observed.712. `Tool split`: what SwiftFormat owns and what SwiftLint owns.723. `Changes`: config, hook, CI, or source edits.734. `Commands`: exact commands run or recommended.745. `Validation`: pass, fail, or skipped with concrete reason.7576## Guardrails7778- Do not hand-format Swift when SwiftFormat is available and configured.79- Do not add SwiftLint rules as a casual cleanup without checking current repo tolerance.80- Do not introduce formatter churn unrelated to the requested work.81- Do not claim Xcode build-phase or source-editor behavior without using Apple Dev docs and handoffs.82- Do not override existing project style with a generic template.