awesome-claude-notes / rules
loulanyue/awesome-claude-notes/.cursor/rules/swift-patterns.md
Swift patterns extending common rules
Cursor rule272 starsChanged 6 months ago
What's in it
- Swift Patterns
- Protocol-Oriented Design
- Value Types
- Actor Pattern
- Dependency Injection
- References
---
description: "Swift patterns extending common rules"
globs: ["**/*.swift", "**/Package.swift"]
alwaysApply: false
---
# Swift Patterns
> This file extends the common patterns rule with Swift specific content.
## Protocol-Oriented Design
Define small, focused protocols. Use protocol extensions for shared defaults:
```swift
protocol Repository: Sendable {
associatedtype Item: Identifiable & Sendable
func find(by id: Item.ID) async throws -> Item?
func save(_ item: Item) async throws
}
```
## Value Types
- Use structs for data transfer objects and models
- Use enums with associated values to model distinct states:
```swift
enum LoadState<T: Sendable>: Sendable {
case idle
case loading
case loaded(T)
case failed(Error)
}
```
## Actor Pattern
Use actors for shared mutable state instead of locks or dispatch queues:
```swift
actor Cache<Key: Hashable & Sendable, Value: Sendable> {
private var storage: [Key: Value] = [:]
func get(_ key: Key) -> Value? { storage[key] }
func set(_ key: Key, value: Value) { storage[key] = value }
}
```
## Dependency Injection
Inject protocols with default parameters -- production uses defaults, tests inject mocks:
```swift
struct UserService {
private let repository: any UserRepository
init(repository: any UserRepository = DefaultUserRepository()) {
self.repository = repository
}
}
```
## References
See skill: `swift-actor-persistence` for actor-based persistence patterns.
See skill: `swift-protocol-di-testing` for protocol-based DI and testing.
More agent context in loulanyue/awesome-claude-notes
178 other files this repository gives its agents, the first 60 shown.
AGENTS.md
CLAUDE.md
Cursor rule
- .cursor/rules/common-agents.md
- .cursor/rules/common-coding-style.md
- .cursor/rules/common-development-workflow.md
- .cursor/rules/common-git-workflow.md
- .cursor/rules/common-hooks.md
- .cursor/rules/common-patterns.md
- .cursor/rules/common-performance.md
- .cursor/rules/common-security.md
- .cursor/rules/common-testing.md
- .cursor/rules/golang-coding-style.md
- .cursor/rules/golang-hooks.md
- .cursor/rules/golang-patterns.md
- .cursor/rules/golang-security.md
- .cursor/rules/golang-testing.md
- .cursor/rules/kotlin-coding-style.md
- .cursor/rules/kotlin-hooks.md
- .cursor/rules/kotlin-patterns.md
- .cursor/rules/kotlin-security.md
- .cursor/rules/kotlin-testing.md
- .cursor/rules/php-coding-style.md
- .cursor/rules/php-hooks.md
- .cursor/rules/php-patterns.md
- .cursor/rules/php-security.md
- .cursor/rules/php-testing.md
- .cursor/rules/python-coding-style.md
- .cursor/rules/python-hooks.md
- .cursor/rules/python-patterns.md
- .cursor/rules/python-security.md
- .cursor/rules/python-testing.md
- .cursor/rules/swift-coding-style.md
- .cursor/rules/swift-hooks.md
- .cursor/rules/swift-security.md
- .cursor/rules/swift-testing.md
- .cursor/rules/typescript-coding-style.md
- .cursor/rules/typescript-hooks.md
- .cursor/rules/typescript-patterns.md
- .cursor/rules/typescript-security.md
- .cursor/rules/typescript-testing.md
llms.txt
Skill
- article-writing.cursor/skills/article-writing/SKILL.md
- bun-runtime.cursor/skills/bun-runtime/SKILL.md
- content-engine.cursor/skills/content-engine/SKILL.md
- documentation-lookup.cursor/skills/documentation-lookup/SKILL.md
- frontend-slides.cursor/skills/frontend-slides/SKILL.md
- investor-materials.cursor/skills/investor-materials/SKILL.md
- investor-outreach.cursor/skills/investor-outreach/SKILL.md
- market-research.cursor/skills/market-research/SKILL.md
- mcp-server-patterns.cursor/skills/mcp-server-patterns/SKILL.md
- nextjs-turbopack.cursor/skills/nextjs-turbopack/SKILL.md
- agent-evalskills/agent-eval/SKILL.md
- agent-harness-constructionskills/agent-harness-construction/SKILL.md
- agentic-engineeringskills/agentic-engineering/SKILL.md
- ai-first-engineeringskills/ai-first-engineering/SKILL.md
- ai-regression-testingskills/ai-regression-testing/SKILL.md
- android-clean-architectureskills/android-clean-architecture/SKILL.md
- api-designskills/api-design/SKILL.md
Also found in 19 other repositories
The same file, byte for byte, in the weekly crawl of public GitHub; the 10 with the most stars.
- affaan-m/ECC246k
- tpavanipradeep/everything-claude-code104
- mturac/everything-openai-codex89
- mit-network/everything-claude-code76
- Fmarzochi/EGC52
- ysyecust/everything-claude-code44
- j7-dev/everything-github-copilot19
- Infopibe/everything-claude-code8
- yapota2018/affaan-m-everything-claude-code4
- ArogyaReddy/https-github.com-affaan-m-everything-claude-code12
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
No reports yet. Be the first to say whether it worked.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool public_context_discussion, action report. How to connect one.

