swift
Skill15 starsChanged 9 months agoMITView on GitHub
Google's official Swift style guide. Covers naming conventions, optionals, protocols, error handling, access control, formatting, and Swift best practices.
13 other projects use a version of this.
Adopted by
Most recently taken up by
- rogue-dev-studio/ai-agents-roguetheir own version, first seen Nov 1, 2026
- hmj1026/dhpktheir own version, first seen Nov 1, 2026
- joshuaramkissoon/claude-skillstheir own version, first seen Oct 25, 2026
- tiago-oliveira-ca/zenodotus-harnesstheir own version, first seen Oct 25, 2026
- g-cqd/skillstheir own version, first seen Oct 23, 2026
- G1Joshi/Agent-Skillstheir own version, first seen Oct 13, 2026
Used with
Projects with it also use react.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
VercelSkillreact
React renderer for json-render that turns JSON specs into React components. Use when working with @json-render/react, building React UIs from JSON, creating component catalogs, or rendering AI-generated specs.
Also in 3 projects that use this
Other versions13 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 13
- Mindrally/skills★ 275same name
- margelo/react-native-skills★ 172same name
- wendylabsinc/claude-skills★ 62same name
- nimadorostkar/Claude-Skills-collection★ 33same name
- G1Joshi/Agent-Skills★ 15same name
- g-cqd/skills★ 2same name
- hmj1026/dhpk★ 2same name
- kimtth/agent-skill-100-lines-or-less★ 2same name
- rogue-dev-studio/ai-agents-rogue★ 2same name
- cocart-headless/cocart-skills★ 1same name
3 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository17 other files it gives its agents.
- angularjsSkill
- common-lispSkill
- cppSkill
- csharpSkill
- goSkill
- html-cssSkill
- javascriptSkill
- javaSkill
- jsonSkill
- markdownSkill
- objective-cSkill
- pythonSkill
- rSkill
- shellSkill
- google-styleguides-skillsSkill
- typescriptSkill
- vim-scriptSkill
The file
Files
Google Swift Style Guide
Official Google Swift coding standards for consistent, maintainable iOS/macOS code.
Golden Rules
- Clear, descriptive names — readability at the call site
- Prefer
letovervar— immutability by default - Use optionals properly — avoid force unwrapping (
!) - Protocol-oriented programming — prefer protocols over inheritance
guardfor early returns — reduce nesting with early exits- Use type inference — let Swift infer types when obvious
- SwiftLint for consistency — automate style enforcement
Quick Reference
Naming Conventions
| Element | Convention | Example |
| Types (class/struct/enum/protocol) | UpperCamelCase | UserService |
| Functions/Methods | lowerCamelCase | getUserById |
| Variables/Properties | lowerCamelCase | userCount |
| Constants | lowerCamelCase | maxRetries |
| Enums | UpperCamelCase | Direction |
| Enum cases | lowerCamelCase | .up, .down, .left |
| Type aliases | UpperCamelCase | CompletionHandler |
Variables and Constants
// ✓ CORRECT - prefer let (immutable)
let userName = "Alice"
let maxRetries = 3
// ✓ CORRECT - var only when value changes
var retryCount = 0
retryCount += 1
// ✓ CORRECT - type inference (no need to repeat type)
let users: [User] = [] // OK: collection type is clear
let count = users.count // inferred as IntOptionals
// ✓ CORRECT - if let for optional binding
if let user = getUser(id: 42) {
print(user.name)
}
// ✓ CORRECT - guard for early return
func processUser(id: Int) {
guard let user = getUser(id: id) else {
print("User not found")
return
}
// user is non-optional here
display(user)
}
// ✓ CORRECT - nil coalescing
let name = user?.name ?? "Unknown"
// ✗ INCORRECT - force unwrap
let user = getUser(id: 42)! // crashes if nilStructs and Classes
// ✓ CORRECT - prefer struct for value types
struct User {
let id: Int
var name: String
var email: String
}
// ✓ CORRECT - class for reference semantics / inheritance
final class UserService {
private let repository: UserRepository
init(repository: UserRepository) {
self.repository = repository
}
func getUser(id: Int) async throws -> User {
return try await repository.find(id: id)
}
}Protocols
// ✓ CORRECT - protocol for abstraction
protocol UserRepository {
func find(id: Int) async throws -> User
func save(_ user: User) async throws
}
// ✓ CORRECT - protocol extension for default behavior
extension UserRepository {
func findAll() async throws -> [User] {
return []
}
}
// ✓ CORRECT - composing protocols
typealias UserStore = UserRepository & CodableError Handling
// ✓ CORRECT - typed errors with enum
enum UserError: Error {
case notFound(id: Int)
case invalidData(String)
case networkFailure(underlying: Error)
}
// ✓ CORRECT - throw and catch
func fetchUser(id: Int) throws -> User {
guard let user = database[id] else {
throw UserError.notFound(id: id)
}
return user
}
// ✓ CORRECT - do-catch
do {
let user = try fetchUser(id: 42)
display(user)
} catch UserError.notFound(let id) {
print("User \(id) not found")
} catch {
print("Unexpected error: \(error)")
}Async/Await
// ✓ CORRECT - async/await (Swift 5.5+)
func loadUsers() async throws -> [User] {
let data = try await networkClient.get("/api/users")
return try JSONDecoder().decode([User].self, from: data)
}
// ✓ CORRECT - task for concurrent work
Task {
do {
let users = try await loadUsers()
await MainActor.run { self.users = users }
} catch {
await MainActor.run { self.error = error }
}
}Access Control
// ✓ CORRECT - explicit access control
public struct User {
public let id: Int
public var name: String
internal var metadata: [String: String]
private var _internalState: Bool
}
// ✓ CORRECT - use final to prevent subclassing
public final class AuthService {
// ...
}Formatting
// ✓ CORRECT - trailing closures
users.forEach { user in
print(user.name)
}
let activeUsers = users.filter { $0.isActive }
let names = users.map { $0.name }
// ✓ CORRECT - 2-space indentation, opening brace on same line
func process() {
if condition {
doSomething()
}
}Common Mistakes
| Mistake | Correct Approach |
Force unwrapping (!) | Use if let, guard let, or nil coalescing |
var everywhere | Use let by default; var only when mutating |
| Class for everything | Prefer struct for value semantics |
| No error handling | Use throws / do-catch |
| Inheritance over protocols | Favor protocol composition |
| No access control | Explicitly mark public, internal, private |
| Implicit self in closures | Use [weak self] to avoid retain cycles |
When to Use This Guide
- Writing new Swift code
- Refactoring existing Swift
- Code reviews
- Setting up SwiftLint rules
- Onboarding new team members
Install
npx skills add testdino-hq/google-styleguides-skills/swiftFull Guide
See swift.md for complete details, examples, and edge cases.
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.

