swift-review
Skill7 starsChanged 10 months agoMITView on GitHub
Reviews Swift/Xcode codebases, pull requests, local changes, or individual files against Swift best practices including Google's Swift Style Guide, Apple's API Design Guidelines, build performance, memory management, and testing standards. Use this skill whenever the user asks to review Swift code, audit a Swift PR, check Swift style, review an Xcode project, or mentions swift code review, swift lint, swift best practices review, or swift code quality. Also trigger when reviewing .swift files, Package.swift, or Xcode project changes — even if the user just says "review this" or "check this code" and the context involves Swift.
In this repository30 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- apple-cktool-jsSkill
- apple-cktoolSkill
- audit-training-experimentSkill
- awkSkill
- close-out-ml-experimentSkill
- compare-models-blindlySkill
- conventional-commitsSkill
- design-resumable-model-evaluationSkill
- gogopowermanagerSkill
- ios-design-reviewSkill
- mikrotik-routerosSkill
- obsidian-dailySkill
- orbstack-cliSkill
- package-private-ml-artifactsSkill
- prepare-training-corpusSkill
- proxmox-adminSkill
- review-ios-ui-apple-higSkill
- review-training-data-qualitySkill
- run-hugging-face-training-smokeSkill
- sedSkill
- select-and-verify-best-checkpointSkill
- send-to-minionSkill
- technical-writerSkill
- tmuxinatorSkill
- topydoSkill
- unhobble-agent-contextSkill
- validate-structured-model-outputSkill
- write-a-promptSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. About 0 are common, 7 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 36
When reviewing diffs, always read surrounding context (the full file or function) to understand intent — don't review isolated hunks.
- Very specific: line 46
Read references/api-design.md for the complete rules.
- Very specific: line 57
No abbreviations unless universally understood (min, max, URL)
- Very specific: line 84
No force-unwrap (!) without a comment explaining the invariant
- Very specific: line 85
No implicitly unwrapped optionals except @IBOutlet and test fixtures
- Very specific: line 88
Prefer let over var when value doesn't change
- Very specific: line 89
Prefer value types (struct, enum) over class when no identity needed
- Distinctive: line 98
No complex expressions that slow type-checker (break into smaller statements)
- Very specific: line 101
No unnecessary @objc or dynamic unless needed for Objective-C interop
- Very specific: line 103
Prefer final on classes not designed for inheritance (enables compiler optimizations)
- Distinctive: line 105
No excessive protocol conformance in extensions across files (merge where logical)
- Very specific: line 112
No retain cycles in closures — use [weak self] or [unowned self] appropriately
- Distinctive: line 119
No strong reference chains between parent and child objects
- Very specific: line 128
Test methods named descriptively: test_<condition>_<expectedResult>
- Distinctive: line 130
No test interdependencies — each test stands alone
- Distinctive: line 135
No network calls in unit tests — use protocols and mocks
- Very specific: line 153
No data races — nonisolated used intentionally
- Distinctive: line 186
Keep findings actionable. Don't flag things that are clearly intentional project conventions unless they cause real problems.
≈ “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
Swift Code Review
Review Swift code against industry best practices drawn from Google's Swift Style Guide, Apple's API Design Guidelines, Apple's performance and memory documentation, and real-world patterns from Apple's open-source projects.
Determine Review Scope
Figure out what to review based on the user's request:
| Request | How to get the code |
| "Review this PR" / PR URL | gh pr diff <number> or read the diff |
| "Review my changes" | git diff (unstaged) and git diff --cached (staged) |
| "Review this file" / path | Read the file(s) directly |
| "Review the codebase" | Glob for **/*.swift files, prioritize by size/complexity |
| Xcode project review | Also check *.xcodeproj, Package.swift, build settings |
When reviewing diffs, always read surrounding context (the full file or function) to understand intent — don't review isolated hunks.
Review Checklist
Work through these categories in order. For each finding, cite the file, line, and the specific guideline being violated. Skip categories that don't apply to the scope.
1. Naming & API Design
Read references/api-design.md for the complete rules.
Key checks:
- Types use
UpperCamelCase, everything else useslowerCamelCase - Methods read as grammatical English at the call site:
x.insert(y, at: z) - Names describe roles, not types:
greetingnotstring - Mutating/nonmutating pairs follow the
-ed/-ingconvention - Boolean properties read as assertions:
isEmpty,isValid - Factory methods start with
make - Protocol names use nouns for "what it is",
-able/-iblefor capabilities - Argument labels form grammatical phrases with the method name
- No abbreviations unless universally understood (
min,max,URL)
2. Code Style & Formatting
Read references/code-style.md for the complete rules.
Key checks:
- 100-character line limit
- K&R brace style (opening brace on same line)
- No semicolons
- One statement per line
//comments only, never/* */- One variable per
let/vardeclaration - Trailing commas in multiline array/dictionary literals
- Imports grouped: standard modules, then individual declarations, then
@testable // MARK:comments to organize type members- Shorthand syntax for arrays
[Element], dictionaries[Key: Value], optionalsT?
3. Swift Patterns & Idioms
Read references/swift-patterns.md for the complete rules.
Key checks:
guardfor early exits instead of nestedifblocksfor-whereinstead offor+ singleifbodyOptionalover sentinel values (-1, empty string)- Errors thrown, not merged with return types
- No force-unwrap (
!) without a comment explaining the invariant - No implicitly unwrapped optionals except
@IBOutletand test fixtures - Explicit access control where it differs from
internal - Nested types for scoping (error types, flag enums inside their parent)
- Prefer
letovervarwhen value doesn't change - Prefer value types (
struct,enum) overclasswhen no identity needed - Protocol extensions for default implementations, not base classes
- Computed properties omit
getwhen read-only
4. Build Performance
Read references/performance.md for the complete rules.
Key checks:
- No complex expressions that slow type-checker (break into smaller statements)
- Explicit types on complex closures and collection literals
- Minimize use of
AnyObject,Any— prefer concrete or generic types - No unnecessary
@objcordynamicunless needed for Objective-C interop - Module boundaries are clean — no circular dependencies
- Prefer
finalon classes not designed for inheritance (enables compiler optimizations) - Large expressions broken into smaller sub-expressions with explicit types
- No excessive protocol conformance in extensions across files (merge where logical)
5. Memory Management
Read references/memory-management.md for the complete rules.
Key checks:
- No retain cycles in closures — use
[weak self]or[unowned self]appropriately weakpreferred overunownedunless lifetime is guaranteed- Delegates declared as
weak var - Large resources freed in
deinitor on memory warnings - Discardable resource caches use
NSCachewith count/cost limits; deterministic maps or non-discardable data may use bounded dictionaries - Autoreleasepool used in tight loops creating many temporary objects
- No strong reference chains between parent and child objects
- Image and data caches have size limits
- Observation tokens stored and invalidated properly
6. Testing
Read references/testing.md for the complete rules.
Key checks:
- Test methods named descriptively:
test_<condition>_<expectedResult> - One assertion concept per test (test may have setup + multiple related asserts)
- No test interdependencies — each test stands alone
setUp()/tearDown()used for shared fixtures, not duplicated in every test- Async code tested with expectations or Swift concurrency
- UI tests separated from unit tests
- Edge cases covered: nil, empty, boundary values, error paths
- No network calls in unit tests — use protocols and mocks
- Force-unwrap permitted in tests (fails the test if nil, which is desired)
7. Documentation
Key checks:
- Public API has
///doc comments with summary, parameters, returns, throws - Doc comments use verb phrases for methods, noun phrases for properties
- No
/** */block comment syntax Parameter,Returns,Throwstags in that order- Complex algorithms have inline comments explaining why, not what
8. Concurrency (if applicable)
Key checks:
@Sendableclosures don't capture mutable state- Actors used for mutable shared state instead of locks
MainActorfor UI updates- No data races —
nonisolatedused intentionally - Structured concurrency (
async let,TaskGroup) preferred over unstructuredTask {} - Cancellation handled properly
Output Format
Structure the review as:
## Summary
<1-2 sentence overall assessment>
## Findings
### Critical
<issues that will cause bugs, crashes, or data loss>
### Important
<style violations, performance issues, missing tests>
### Suggestions
<minor improvements, alternative approaches>
## What's Done Well
<2-3 things the code does right — always include this>For each finding, include:
- File and line:
Sources/Auth/TokenManager.swift:42 - Category: which checklist item it falls under
- Issue: what's wrong
- Fix: concrete code suggestion or direction
Keep findings actionable. Don't flag things that are clearly intentional project conventions unless they cause real problems.
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.

