Copilot instructions
.github/instructions/swift.instructions.mdCopilot instructions
Quality
81/100
Scores the file, not the repository.Length
618 words
22 headings · 9 code blocksRepository
19
— · pushed 151 days agoLast changed
3 days ago
First indexed 3 days ago.12345# Swift Coding Style67> This file extends [common/coding-style.md](../common/coding-style.md) with Swift specific content.89## Formatting1011- **SwiftFormat** for auto-formatting, **SwiftLint** for style enforcement12- `swift-format` is bundled with Xcode 16+ as an alternative1314## Immutability1516- Prefer `let` over `var` — define everything as `let` and only change to `var` if the compiler requires it17- Use `struct` with value semantics by default; use `class` only when identity or reference semantics are needed1819## Naming2021Follow [Apple API Design Guidelines](https://www.swift.org/documentation/api-design-guidelines/):2223- Clarity at the point of use — omit needless words24- Name methods and properties for their roles, not their types25- Use `static let` for constants over global constants2627## Error Handling2829Use typed throws (Swift 6+) and pattern matching:3031```swift32func load(id: String) throws(LoadError) -> Item {33 guard let data = try? read(from: path) else {34 throw .fileNotFound(id)35 }36 return try decode(data)37}38```3940## Concurrency4142Enable Swift 6 strict concurrency checking. Prefer:4344- `Sendable` value types for data crossing isolation boundaries45- Actors for shared mutable state46- Structured concurrency (`async let`, `TaskGroup`) over unstructured `Task {}`474849# Swift Patterns5051> This file extends [common/patterns.md](../common/patterns.md) with Swift specific content.5253## Protocol-Oriented Design5455Define small, focused protocols. Use protocol extensions for shared defaults:5657```swift58protocol Repository: Sendable {59 associatedtype Item: Identifiable & Sendable60 func find(by id: Item.ID) async throws -> Item?61 func save(_ item: Item) async throws62}63```6465## Value Types6667- Use structs for data transfer objects and models68- Use enums with associated values to model distinct states:6970```swift71enum LoadState<T: Sendable>: Sendable {72 case idle73 case loading74 case loaded(T)75 case failed(Error)76}77```7879## Actor Pattern8081Use actors for shared mutable state instead of locks or dispatch queues:8283```swift84actor Cache<Key: Hashable & Sendable, Value: Sendable> {85 private var storage: [Key: Value] = [:]8687 func get(_ key: Key) -> Value? { storage[key] }88 func set(_ key: Key, value: Value) { storage[key] = value }89}90```9192## Dependency Injection9394Inject protocols with default parameters — production uses defaults, tests inject mocks:9596```swift97struct UserService {98 private let repository: any UserRepository99100 init(repository: any UserRepository = DefaultUserRepository()) {101 self.repository = repository102 }103}104```105106## References107108See skill: `swift-actor-persistence` for actor-based persistence patterns.109See skill: `swift-protocol-di-testing` for protocol-based DI and testing.110111112# Swift Security113114> This file extends [common/security.md](../common/security.md) with Swift specific content.115116## Secret Management117118- Use **Keychain Services** for sensitive data (tokens, passwords, keys) — never `UserDefaults`119- Use environment variables or `.xcconfig` files for build-time secrets120- Never hardcode secrets in source — decompilation tools extract them trivially121122```swift123let apiKey = ProcessInfo.processInfo.environment["API_KEY"]124guard let apiKey, !apiKey.isEmpty else {125 fatalError("API_KEY not configured")126}127```128129## Transport Security130131- App Transport Security (ATS) is enforced by default — do not disable it132- Use certificate pinning for critical endpoints133- Validate all server certificates134135## Input Validation136137- Sanitize all user input before display to prevent injection138- Use `URL(string:)` with validation rather than force-unwrapping139- Validate data from external sources (APIs, deep links, pasteboard) before processing140141142# Swift Testing143144> This file extends [common/testing.md](../common/testing.md) with Swift specific content.145146## Framework147148Use **Swift Testing** (`import Testing`) for new tests. Use `@Test` and `#expect`:149150```swift151@Test("User creation validates email")152func userCreationValidatesEmail() throws {153 #expect(throws: ValidationError.invalidEmail) {154 try User(email: "not-an-email")155 }156}157```158159## Test Isolation160161Each test gets a fresh instance — set up in `init`, tear down in `deinit`. No shared mutable state between tests.162163## Parameterized Tests164165```swift166@Test("Validates formats", arguments: ["json", "xml", "csv"])167func validatesFormat(format: String) throws {168 let parser = try Parser(format: format)169 #expect(parser.isValid)170}171```172173## Coverage174175```bash176swift test --enable-code-coverage177```178179## Reference180181See skill: `swift-protocol-di-testing` for protocol-based dependency injection and mock patterns with Swift Testing.
Also in j7-dev/everything-github-copilot
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| j7-dev/everything-github-copilot.codex/AGENTS.md · 19 | AGENTS.md | securityagent-behaviour | 59/100 | 3 days ago | |
| j7-dev/everything-github-copilot.github/instructions/python.instructions.md · 19 | Copilot instructions | testlint-formatstyletypes+2 | 85/100 | 3 days ago | |
| j7-dev/everything-github-copilot.github/instructions/typescript.instructions.md · 19 | Copilot instructions | testlint-formatstyletypes+4 | 62/100 | 3 days ago | |
| j7-dev/everything-github-copilotAGENTS.md · 19 | AGENTS.md | buildteststylearch+4 | 77/100 | 3 days ago | |
| j7-dev/everything-github-copilot.github/copilot-instructions.md · 19 | Copilot instructions | buildtestlint-formatstyle+6 | 76/100 | 3 days ago | |
| j7-dev/everything-github-copilot.github/instructions/go.instructions.md · 19 | Copilot instructions | testlint-formatstyletesting-strategy+1 | 77/100 | 3 days ago | |
| j7-dev/everything-github-copilotCLAUDE.md · 19 | CLAUDE.md | testarchagent-behaviour | 81/100 | 3 days ago | |
| j7-dev/everything-github-copilotskills/react-best-practices/AGENTS.md · 19 | AGENTS.md | buildlint-formatstylearch+8 | 64/100 | 3 days ago |
Diff against .codex/AGENTS.md Diff against .github/instructions/python.instructions.md Diff against .github/instructions/typescript.instructions.md Diff against AGENTS.md Diff against .github/copilot-instructions.md Diff against .github/instructions/go.instructions.md Diff against CLAUDE.md Diff against skills/react-best-practices/AGENTS.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| chihebnabil/lovable-boilerplate.github/instructions/global.instructions.md · 63 | Copilot instructions | buildlint-formatstylearch+4 | 100/100 | 3 days ago | |
| louislam/uptime-kuma.github/copilot-instructions.md · 90k | Copilot instructions | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.github/copilot-instructions.md · 17 | Copilot instructions | setupbuildtestlint-format+7 | 100/100 | 3 days ago | |
| JCodesMore/ai-website-cloner-template.github/copilot-instructions.md · 31k | Copilot instructions | buildlint-formatstylearch+3 | 97/100 | 2 days ago | |
| bagisto/bagisto.github/copilot-instructions.md · 28k | Copilot instructions | setupbuildteststyle+5 | 97/100 | 3 days ago | |
| darkmatter/nixmac.github/copilot-instructions.md · 24 | Copilot instructions | setupbuildtestlint-format+8 | 96/100 | 3 days ago | |
| nerolis-lab/nerolis-lab.github/copilot-instructions.md · 32 | Copilot instructions | setupbuildtestlint-format+11 | 96/100 | 3 days ago | |
| thangaram611/second-brain.github/copilot-instructions.md · 0 | Copilot instructions | setupteststylearch+4 | 96/100 | 3 days ago |
