pumuki 6.3.52 → 6.3.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/docs/codex-skills/swift-concurrency.md +246 -0
- package/docs/codex-skills/swiftui-expert-skill.md +263 -0
- package/docs/codex-skills/windsurf-rules-android.md +341 -0
- package/docs/codex-skills/windsurf-rules-backend.md +262 -0
- package/docs/codex-skills/windsurf-rules-frontend.md +208 -0
- package/docs/codex-skills/windsurf-rules-ios.md +916 -0
- package/docs/governance/BRANCH_PROTECTION_GUIDE.md +50 -0
- package/docs/governance/CODE_STANDARDS.md +73 -0
- package/docs/governance/CONTRIBUTING.md +92 -0
- package/docs/mcp/MCP_AGENT_CONTEXT_CONSUMPTION.md +188 -0
- package/docs/mcp/MCP_EVIDENCE_CONTEXT_SERVER.md +244 -0
- package/docs/mcp/MCP_SERVERS.md +280 -0
- package/docs/mcp/ai-evidence-v2.1-contract.md +98 -0
- package/docs/operations/OPERATIONS.md +74 -0
- package/docs/operations/RELEASE_NOTES.md +642 -0
- package/docs/operations/framework-menu-option-1-walkthrough.md +65 -0
- package/docs/product/API_REFERENCE.md +372 -0
- package/docs/product/ARCHITECTURE.md +190 -0
- package/docs/product/CONFIGURATION.md +366 -0
- package/docs/product/DEPENDENCIES.md +54 -0
- package/docs/product/HOW_IT_WORKS.md +160 -0
- package/docs/product/INSTALLATION.md +270 -0
- package/docs/product/TESTING.md +114 -0
- package/docs/product/USAGE.md +791 -0
- package/integrations/config/skillsCustomRules.ts +4 -0
- package/integrations/evidence/repoState.ts +2 -0
- package/integrations/evidence/schema.ts +1 -0
- package/integrations/gate/evaluateAiGate.ts +3 -1
- package/integrations/lifecycle/cli.ts +6 -0
- package/integrations/lifecycle/packageInfo.ts +6 -0
- package/integrations/lifecycle/watch.ts +29 -3
- package/integrations/mcp/autoExecuteAiStart.ts +3 -1
- package/package.json +6 -1
- package/scripts/package-manifest-lib.ts +7 -0
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@ Install and bootstrap:
|
|
|
34
34
|
npm install --save-exact pumuki
|
|
35
35
|
npx --yes pumuki bootstrap --enterprise --agent=codex
|
|
36
36
|
npx --yes pumuki status
|
|
37
|
+
npx --yes pumuki doctor --json
|
|
37
38
|
```
|
|
38
39
|
|
|
39
40
|
Fallback (equivalent in pasos separados):
|
|
@@ -80,6 +81,16 @@ Expected behavior:
|
|
|
80
81
|
- `PRE_PUSH`: blocks if branch has no upstream tracking reference.
|
|
81
82
|
- `CI`: requires a valid diff range context (not `HEAD..HEAD` with ambiguous range).
|
|
82
83
|
|
|
84
|
+
Version drift quick check:
|
|
85
|
+
|
|
86
|
+
- `status --json` and `doctor --json` expose `version.effective`, `version.runtime`, `version.consumerInstalled`, `version.lifecycleInstalled`, `version.driftWarning`, and `version.alignmentCommand`.
|
|
87
|
+
- If `driftWarning` is not `null`, align the consumer with:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm install --save-exact pumuki@6.3.52
|
|
91
|
+
npx --yes pumuki update --latest
|
|
92
|
+
```
|
|
93
|
+
|
|
83
94
|
## Why Pumuki
|
|
84
95
|
|
|
85
96
|
Modern teams need fast feedback with strict governance. Pumuki combines:
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: swift-concurrency
|
|
3
|
+
description: 'Expert guidance on Swift Concurrency best practices, patterns, and implementation. Use when developers mention: (1) Swift Concurrency, async/await, actors, or tasks, (2) "use Swift Concurrency" or "modern concurrency patterns", (3) migrating to Swift 6, (4) data races or thread safety issues, (5) refactoring closures to async/await, (6) @MainActor, Sendable, or actor isolation, (7) concurrent code architecture or performance optimization, (8) concurrency-related linter warnings (SwiftLint or similar; e.g. async_without_await, Sendable/actor isolation/MainActor lint).'
|
|
4
|
+
---
|
|
5
|
+
# Swift Concurrency
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This skill provides expert guidance on Swift Concurrency, covering modern async/await patterns, actors, tasks, Sendable conformance, and migration to Swift 6. Use this skill to help developers write safe, performant concurrent code and navigate the complexities of Swift's structured concurrency model.
|
|
10
|
+
|
|
11
|
+
## Agent Behavior Contract (Follow These Rules)
|
|
12
|
+
|
|
13
|
+
1. Analyze the project/package file to find out which Swift language mode (Swift 5.x vs Swift 6) and which Xcode/Swift toolchain is used when advice depends on it.
|
|
14
|
+
2. Before proposing fixes, identify the isolation boundary: `@MainActor`, custom actor, actor instance isolation, or nonisolated.
|
|
15
|
+
3. Do not recommend `@MainActor` as a blanket fix. Justify why main-actor isolation is correct for the code.
|
|
16
|
+
4. Prefer structured concurrency (child tasks, task groups) over unstructured tasks. Use `Task.detached` only with a clear reason.
|
|
17
|
+
5. If recommending `@preconcurrency`, `@unchecked Sendable`, or `nonisolated(unsafe)`, require:
|
|
18
|
+
- a documented safety invariant
|
|
19
|
+
- a follow-up ticket to remove or migrate it
|
|
20
|
+
6. For migration work, optimize for minimal blast radius (small, reviewable changes) and add verification steps.
|
|
21
|
+
7. Course references are for deeper learning only. Use them sparingly and only when they clearly help answer the developer's question.
|
|
22
|
+
|
|
23
|
+
## Recommended Tools for Analysis
|
|
24
|
+
|
|
25
|
+
When analyzing Swift projects for concurrency issues:
|
|
26
|
+
|
|
27
|
+
1. **Project Settings Discovery**
|
|
28
|
+
- Use `Read` on `Package.swift` for SwiftPM settings (tools version, strict concurrency flags, upcoming features)
|
|
29
|
+
- Use `Grep` for `SWIFT_STRICT_CONCURRENCY` or `SWIFT_DEFAULT_ACTOR_ISOLATION` in `.pbxproj` files
|
|
30
|
+
- Use `Grep` for `SWIFT_UPCOMING_FEATURE_` to find enabled upcoming features
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## Project Settings Intake (Evaluate Before Advising)
|
|
35
|
+
|
|
36
|
+
Concurrency behavior depends on build settings. Always try to determine:
|
|
37
|
+
|
|
38
|
+
- Default actor isolation (is the module default `@MainActor` or `nonisolated`?)
|
|
39
|
+
- Strict concurrency checking level (minimal/targeted/complete)
|
|
40
|
+
- Whether upcoming features are enabled (especially `NonisolatedNonsendingByDefault`)
|
|
41
|
+
- Swift language mode (Swift 5.x vs Swift 6) and SwiftPM tools version
|
|
42
|
+
|
|
43
|
+
### Manual checks (no scripts)
|
|
44
|
+
|
|
45
|
+
- SwiftPM:
|
|
46
|
+
- Check `Package.swift` for `.defaultIsolation(MainActor.self)`.
|
|
47
|
+
- Check `Package.swift` for `.enableUpcomingFeature("NonisolatedNonsendingByDefault")`.
|
|
48
|
+
- Check for strict concurrency flags: `.enableExperimentalFeature("StrictConcurrency=targeted")` (or similar).
|
|
49
|
+
- Check tools version at the top: `// swift-tools-version: ...`
|
|
50
|
+
- Xcode projects:
|
|
51
|
+
- Search `project.pbxproj` for:
|
|
52
|
+
- `SWIFT_DEFAULT_ACTOR_ISOLATION`
|
|
53
|
+
- `SWIFT_STRICT_CONCURRENCY`
|
|
54
|
+
- `SWIFT_UPCOMING_FEATURE_` (and/or `SWIFT_ENABLE_EXPERIMENTAL_FEATURES`)
|
|
55
|
+
|
|
56
|
+
If any of these are unknown, ask the developer to confirm them before giving migration-sensitive guidance.
|
|
57
|
+
|
|
58
|
+
## Quick Decision Tree
|
|
59
|
+
|
|
60
|
+
When a developer needs concurrency guidance, follow this decision tree:
|
|
61
|
+
|
|
62
|
+
1. **Starting fresh with async code?**
|
|
63
|
+
- Read `references/async-await-basics.md` for foundational patterns
|
|
64
|
+
- For parallel operations → `references/tasks.md` (async let, task groups)
|
|
65
|
+
|
|
66
|
+
2. **Protecting shared mutable state?**
|
|
67
|
+
- Need to protect class-based state → `references/actors.md` (actors, @MainActor)
|
|
68
|
+
- Need thread-safe value passing → `references/sendable.md` (Sendable conformance)
|
|
69
|
+
|
|
70
|
+
3. **Managing async operations?**
|
|
71
|
+
- Structured async work → `references/tasks.md` (Task, child tasks, cancellation)
|
|
72
|
+
- Streaming data → `references/async-sequences.md` (AsyncSequence, AsyncStream)
|
|
73
|
+
|
|
74
|
+
4. **Working with legacy frameworks?**
|
|
75
|
+
- Core Data integration → `references/core-data.md`
|
|
76
|
+
- General migration → `references/migration.md`
|
|
77
|
+
|
|
78
|
+
5. **Performance or debugging issues?**
|
|
79
|
+
- Slow async code → `references/performance.md` (profiling, suspension points)
|
|
80
|
+
- Testing concerns → `references/testing.md` (XCTest, Swift Testing)
|
|
81
|
+
|
|
82
|
+
6. **Understanding threading behavior?**
|
|
83
|
+
- Read `references/threading.md` for thread/task relationship and isolation
|
|
84
|
+
|
|
85
|
+
7. **Memory issues with tasks?**
|
|
86
|
+
- Read `references/memory-management.md` for retain cycle prevention
|
|
87
|
+
|
|
88
|
+
## Triage-First Playbook (Common Errors -> Next Best Move)
|
|
89
|
+
|
|
90
|
+
- SwiftLint concurrency-related warnings
|
|
91
|
+
- Use `references/linting.md` for rule intent and preferred fixes; avoid dummy awaits as “fixes”.
|
|
92
|
+
- SwiftLint `async_without_await` warning
|
|
93
|
+
- Remove `async` if not required; if required by protocol/override/@concurrent, prefer narrow suppression over adding fake awaits. See `references/linting.md`.
|
|
94
|
+
- "Sending value of non-Sendable type ... risks causing data races"
|
|
95
|
+
- First: identify where the value crosses an isolation boundary
|
|
96
|
+
- Then: use `references/sendable.md` and `references/threading.md` (especially Swift 6.2 behavior changes)
|
|
97
|
+
- "Main actor-isolated ... cannot be used from a nonisolated context"
|
|
98
|
+
- First: decide if it truly belongs on `@MainActor`
|
|
99
|
+
- Then: use `references/actors.md` (global actors, `nonisolated`, isolated parameters) and `references/threading.md` (default isolation)
|
|
100
|
+
- "Class property 'current' is unavailable from asynchronous contexts" (Thread APIs)
|
|
101
|
+
- Use `references/threading.md` to avoid thread-centric debugging and rely on isolation + Instruments
|
|
102
|
+
- XCTest async errors like "wait(...) is unavailable from asynchronous contexts"
|
|
103
|
+
- Use `references/testing.md` (`await fulfillment(of:)` and Swift Testing patterns)
|
|
104
|
+
- Core Data concurrency warnings/errors
|
|
105
|
+
- Use `references/core-data.md` (DAO/`NSManagedObjectID`, default isolation conflicts)
|
|
106
|
+
|
|
107
|
+
## Core Patterns Reference
|
|
108
|
+
|
|
109
|
+
### When to Use Each Concurrency Tool
|
|
110
|
+
|
|
111
|
+
**async/await** - Making existing synchronous code asynchronous
|
|
112
|
+
```swift
|
|
113
|
+
// Use for: Single asynchronous operations
|
|
114
|
+
func fetchUser() async throws -> User {
|
|
115
|
+
try await networkClient.get("/user")
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**async let** - Running multiple independent async operations in parallel
|
|
120
|
+
```swift
|
|
121
|
+
// Use for: Fixed number of parallel operations known at compile time
|
|
122
|
+
async let user = fetchUser()
|
|
123
|
+
async let posts = fetchPosts()
|
|
124
|
+
let profile = try await (user, posts)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Task** - Starting unstructured asynchronous work
|
|
128
|
+
```swift
|
|
129
|
+
// Use for: Fire-and-forget operations, bridging sync to async contexts
|
|
130
|
+
Task {
|
|
131
|
+
await updateUI()
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Task Group** - Dynamic parallel operations with structured concurrency
|
|
136
|
+
```swift
|
|
137
|
+
// Use for: Unknown number of parallel operations at compile time
|
|
138
|
+
await withTaskGroup(of: Result.self) { group in
|
|
139
|
+
for item in items {
|
|
140
|
+
group.addTask { await process(item) }
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Actor** - Protecting mutable state from data races
|
|
146
|
+
```swift
|
|
147
|
+
// Use for: Shared mutable state accessed from multiple contexts
|
|
148
|
+
actor DataCache {
|
|
149
|
+
private var cache: [String: Data] = [:]
|
|
150
|
+
func get(_ key: String) -> Data? { cache[key] }
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**@MainActor** - Ensuring UI updates on main thread
|
|
155
|
+
```swift
|
|
156
|
+
// Use for: View models, UI-related classes
|
|
157
|
+
@MainActor
|
|
158
|
+
class ViewModel: ObservableObject {
|
|
159
|
+
@Published var data: String = ""
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Common Scenarios
|
|
164
|
+
|
|
165
|
+
**Scenario: Network request with UI update**
|
|
166
|
+
```swift
|
|
167
|
+
Task { @concurrent in
|
|
168
|
+
let data = try await fetchData() // Background
|
|
169
|
+
await MainActor.run {
|
|
170
|
+
self.updateUI(with: data) // Main thread
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Scenario: Multiple parallel network requests**
|
|
176
|
+
```swift
|
|
177
|
+
async let users = fetchUsers()
|
|
178
|
+
async let posts = fetchPosts()
|
|
179
|
+
async let comments = fetchComments()
|
|
180
|
+
let (u, p, c) = try await (users, posts, comments)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Scenario: Processing array items in parallel**
|
|
184
|
+
```swift
|
|
185
|
+
await withTaskGroup(of: ProcessedItem.self) { group in
|
|
186
|
+
for item in items {
|
|
187
|
+
group.addTask { await process(item) }
|
|
188
|
+
}
|
|
189
|
+
for await result in group {
|
|
190
|
+
results.append(result)
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Swift 6 Migration Quick Guide
|
|
196
|
+
|
|
197
|
+
Key changes in Swift 6:
|
|
198
|
+
- **Strict concurrency checking** enabled by default
|
|
199
|
+
- **Complete data-race safety** at compile time
|
|
200
|
+
- **Sendable requirements** enforced on boundaries
|
|
201
|
+
- **Isolation checking** for all async boundaries
|
|
202
|
+
|
|
203
|
+
For detailed migration steps, see `references/migration.md`.
|
|
204
|
+
|
|
205
|
+
## Reference Files
|
|
206
|
+
|
|
207
|
+
Load these files as needed for specific topics:
|
|
208
|
+
|
|
209
|
+
- **`async-await-basics.md`** - async/await syntax, execution order, async let, URLSession patterns
|
|
210
|
+
- **`tasks.md`** - Task lifecycle, cancellation, priorities, task groups, structured vs unstructured
|
|
211
|
+
- **`threading.md`** - Thread/task relationship, suspension points, isolation domains, nonisolated
|
|
212
|
+
- **`memory-management.md`** - Retain cycles in tasks, memory safety patterns
|
|
213
|
+
- **`actors.md`** - Actor isolation, @MainActor, global actors, reentrancy, custom executors, Mutex
|
|
214
|
+
- **`sendable.md`** - Sendable conformance, value/reference types, @unchecked, region isolation
|
|
215
|
+
- **`linting.md`** - Concurrency-focused lint rules and SwiftLint `async_without_await`
|
|
216
|
+
- **`async-sequences.md`** - AsyncSequence, AsyncStream, when to use vs regular async methods
|
|
217
|
+
- **`core-data.md`** - NSManagedObject sendability, custom executors, isolation conflicts
|
|
218
|
+
- **`performance.md`** - Profiling with Instruments, reducing suspension points, execution strategies
|
|
219
|
+
- **`testing.md`** - XCTest async patterns, Swift Testing, concurrency testing utilities
|
|
220
|
+
- **`migration.md`** - Swift 6 migration strategy, closure-to-async conversion, @preconcurrency, FRP migration
|
|
221
|
+
|
|
222
|
+
## Best Practices Summary
|
|
223
|
+
|
|
224
|
+
1. **Prefer structured concurrency** - Use task groups over unstructured tasks when possible
|
|
225
|
+
2. **Minimize suspension points** - Keep actor-isolated sections small to reduce context switches
|
|
226
|
+
3. **Use @MainActor judiciously** - Only for truly UI-related code
|
|
227
|
+
4. **Make types Sendable** - Enable safe concurrent access by conforming to Sendable
|
|
228
|
+
5. **Handle cancellation** - Check Task.isCancelled in long-running operations
|
|
229
|
+
6. **Avoid blocking** - Never use semaphores or locks in async contexts
|
|
230
|
+
7. **Test concurrent code** - Use proper async test methods and consider timing issues
|
|
231
|
+
|
|
232
|
+
## Verification Checklist (When You Change Concurrency Code)
|
|
233
|
+
|
|
234
|
+
- Confirm build settings (default isolation, strict concurrency, upcoming features) before interpreting diagnostics.
|
|
235
|
+
- After refactors:
|
|
236
|
+
- Run tests, especially concurrency-sensitive ones (see `references/testing.md`).
|
|
237
|
+
- If performance-related, verify with Instruments (see `references/performance.md`).
|
|
238
|
+
- If lifetime-related, verify deinit/cancellation behavior (see `references/memory-management.md`).
|
|
239
|
+
|
|
240
|
+
## Glossary
|
|
241
|
+
|
|
242
|
+
See `references/glossary.md` for quick definitions of core concurrency terms used across this skill.
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
**Note**: This skill is based on the comprehensive [Swift Concurrency Course](https://www.swiftconcurrencycourse.com?utm_source=github&utm_medium=agent-skill&utm_campaign=skill-footer) by Antoine van der Lee.
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: swiftui-expert-skill
|
|
3
|
+
description: Write, review, or improve SwiftUI code following best practices for state management, view composition, performance, modern APIs, Swift concurrency, and iOS 26+ Liquid Glass adoption. Use when building new SwiftUI features, refactoring existing views, reviewing code quality, or adopting modern SwiftUI patterns.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SwiftUI Expert Skill
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
Use this skill to build, review, or improve SwiftUI features with correct state management, modern API usage, Swift concurrency best practices, optimal view composition, and iOS 26+ Liquid Glass styling. Prioritize native APIs, Apple design guidance, and performance-conscious patterns. This skill focuses on facts and best practices without enforcing specific architectural patterns.
|
|
10
|
+
|
|
11
|
+
## Workflow Decision Tree
|
|
12
|
+
|
|
13
|
+
### 1) Review existing SwiftUI code
|
|
14
|
+
- Check property wrapper usage against the selection guide (see `references/state-management.md`)
|
|
15
|
+
- Verify modern API usage (see `references/modern-apis.md`)
|
|
16
|
+
- Verify view composition follows extraction rules (see `references/view-structure.md`)
|
|
17
|
+
- Check performance patterns are applied (see `references/performance-patterns.md`)
|
|
18
|
+
- Verify list patterns use stable identity (see `references/list-patterns.md`)
|
|
19
|
+
- Inspect Liquid Glass usage for correctness and consistency (see `references/liquid-glass.md`)
|
|
20
|
+
- Validate iOS 26+ availability handling with sensible fallbacks
|
|
21
|
+
|
|
22
|
+
### 2) Improve existing SwiftUI code
|
|
23
|
+
- Audit state management for correct wrapper selection (prefer `@Observable` over `ObservableObject`)
|
|
24
|
+
- Replace deprecated APIs with modern equivalents (see `references/modern-apis.md`)
|
|
25
|
+
- Extract complex views into separate subviews (see `references/view-structure.md`)
|
|
26
|
+
- Refactor hot paths to minimize redundant state updates (see `references/performance-patterns.md`)
|
|
27
|
+
- Ensure ForEach uses stable identity (see `references/list-patterns.md`)
|
|
28
|
+
- Suggest image downsampling when `UIImage(data:)` is used (as optional optimization, see `references/image-optimization.md`)
|
|
29
|
+
- Adopt Liquid Glass only when explicitly requested by the user
|
|
30
|
+
|
|
31
|
+
### 3) Implement new SwiftUI feature
|
|
32
|
+
- Design data flow first: identify owned vs injected state (see `references/state-management.md`)
|
|
33
|
+
- Use modern APIs (no deprecated modifiers or patterns, see `references/modern-apis.md`)
|
|
34
|
+
- Use `@Observable` for shared state (with `@MainActor` if not using default actor isolation)
|
|
35
|
+
- Structure views for optimal diffing (extract subviews early, keep views small, see `references/view-structure.md`)
|
|
36
|
+
- Separate business logic into testable models (see `references/layout-best-practices.md`)
|
|
37
|
+
- Apply glass effects after layout/appearance modifiers (see `references/liquid-glass.md`)
|
|
38
|
+
- Gate iOS 26+ features with `#available` and provide fallbacks
|
|
39
|
+
|
|
40
|
+
## Core Guidelines
|
|
41
|
+
|
|
42
|
+
### State Management
|
|
43
|
+
- **Always prefer `@Observable` over `ObservableObject`** for new code
|
|
44
|
+
- **Mark `@Observable` classes with `@MainActor`** unless using default actor isolation
|
|
45
|
+
- **Always mark `@State` and `@StateObject` as `private`** (makes dependencies clear)
|
|
46
|
+
- **Never declare passed values as `@State` or `@StateObject`** (they only accept initial values)
|
|
47
|
+
- Use `@State` with `@Observable` classes (not `@StateObject`)
|
|
48
|
+
- `@Binding` only when child needs to **modify** parent state
|
|
49
|
+
- `@Bindable` for injected `@Observable` objects needing bindings
|
|
50
|
+
- Use `let` for read-only values; `var` + `.onChange()` for reactive reads
|
|
51
|
+
- Legacy: `@StateObject` for owned `ObservableObject`; `@ObservedObject` for injected
|
|
52
|
+
- Nested `ObservableObject` doesn't work (pass nested objects directly); `@Observable` handles nesting fine
|
|
53
|
+
|
|
54
|
+
### Modern APIs
|
|
55
|
+
- Use `foregroundStyle()` instead of `foregroundColor()`
|
|
56
|
+
- Use `clipShape(.rect(cornerRadius:))` instead of `cornerRadius()`
|
|
57
|
+
- Use `Tab` API instead of `tabItem()`
|
|
58
|
+
- Use `Button` instead of `onTapGesture()` (unless need location/count)
|
|
59
|
+
- Use `NavigationStack` instead of `NavigationView`
|
|
60
|
+
- Use `navigationDestination(for:)` for type-safe navigation
|
|
61
|
+
- Use two-parameter or no-parameter `onChange()` variant
|
|
62
|
+
- Use `ImageRenderer` for rendering SwiftUI views
|
|
63
|
+
- Use `.sheet(item:)` instead of `.sheet(isPresented:)` for model-based content
|
|
64
|
+
- Sheets should own their actions and call `dismiss()` internally
|
|
65
|
+
- Use `ScrollViewReader` for programmatic scrolling with stable IDs
|
|
66
|
+
- Avoid `UIScreen.main.bounds` for sizing
|
|
67
|
+
- Avoid `GeometryReader` when alternatives exist (e.g., `containerRelativeFrame()`)
|
|
68
|
+
|
|
69
|
+
### Swift Best Practices
|
|
70
|
+
- Use modern Text formatting (`.format` parameters, not `String(format:)`)
|
|
71
|
+
- Use `localizedStandardContains()` for user-input filtering (not `contains()`)
|
|
72
|
+
- Prefer static member lookup (`.blue` vs `Color.blue`)
|
|
73
|
+
- Use `.task` modifier for automatic cancellation of async work
|
|
74
|
+
- Use `.task(id:)` for value-dependent tasks
|
|
75
|
+
|
|
76
|
+
### View Composition
|
|
77
|
+
- **Prefer modifiers over conditional views** for state changes (maintains view identity)
|
|
78
|
+
- Extract complex views into separate subviews for better readability and performance
|
|
79
|
+
- Keep views small for optimal performance
|
|
80
|
+
- Keep view `body` simple and pure (no side effects or complex logic)
|
|
81
|
+
- Use `@ViewBuilder` functions only for small, simple sections
|
|
82
|
+
- Prefer `@ViewBuilder let content: Content` over closure-based content properties
|
|
83
|
+
- Separate business logic into testable models (not about enforcing architectures)
|
|
84
|
+
- Action handlers should reference methods, not contain inline logic
|
|
85
|
+
- Use relative layout over hard-coded constants
|
|
86
|
+
- Views should work in any context (don't assume screen size or presentation style)
|
|
87
|
+
|
|
88
|
+
### Performance
|
|
89
|
+
- Pass only needed values to views (avoid large "config" or "context" objects)
|
|
90
|
+
- Eliminate unnecessary dependencies to reduce update fan-out
|
|
91
|
+
- Check for value changes before assigning state in hot paths
|
|
92
|
+
- Avoid redundant state updates in `onReceive`, `onChange`, scroll handlers
|
|
93
|
+
- Minimize work in frequently executed code paths
|
|
94
|
+
- Use `LazyVStack`/`LazyHStack` for large lists
|
|
95
|
+
- Use stable identity for `ForEach` (never `.indices` for dynamic content)
|
|
96
|
+
- Ensure constant number of views per `ForEach` element
|
|
97
|
+
- Avoid inline filtering in `ForEach` (prefilter and cache)
|
|
98
|
+
- Avoid `AnyView` in list rows
|
|
99
|
+
- Consider POD views for fast diffing (or wrap expensive views in POD parents)
|
|
100
|
+
- Suggest image downsampling when `UIImage(data:)` is encountered (as optional optimization)
|
|
101
|
+
- Avoid layout thrash (deep hierarchies, excessive `GeometryReader`)
|
|
102
|
+
- Gate frequent geometry updates by thresholds
|
|
103
|
+
- Use `Self._printChanges()` to debug unexpected view updates
|
|
104
|
+
|
|
105
|
+
### Liquid Glass (iOS 26+)
|
|
106
|
+
**Only adopt when explicitly requested by the user.**
|
|
107
|
+
- Use native `glassEffect`, `GlassEffectContainer`, and glass button styles
|
|
108
|
+
- Wrap multiple glass elements in `GlassEffectContainer`
|
|
109
|
+
- Apply `.glassEffect()` after layout and visual modifiers
|
|
110
|
+
- Use `.interactive()` only for tappable/focusable elements
|
|
111
|
+
- Use `glassEffectID` with `@Namespace` for morphing transitions
|
|
112
|
+
|
|
113
|
+
## Quick Reference
|
|
114
|
+
|
|
115
|
+
### Property Wrapper Selection (Modern)
|
|
116
|
+
| Wrapper | Use When |
|
|
117
|
+
|---------|----------|
|
|
118
|
+
| `@State` | Internal view state (must be `private`), or owned `@Observable` class |
|
|
119
|
+
| `@Binding` | Child modifies parent's state |
|
|
120
|
+
| `@Bindable` | Injected `@Observable` needing bindings |
|
|
121
|
+
| `let` | Read-only value from parent |
|
|
122
|
+
| `var` | Read-only value watched via `.onChange()` |
|
|
123
|
+
|
|
124
|
+
**Legacy (Pre-iOS 17):**
|
|
125
|
+
| Wrapper | Use When |
|
|
126
|
+
|---------|----------|
|
|
127
|
+
| `@StateObject` | View owns an `ObservableObject` (use `@State` with `@Observable` instead) |
|
|
128
|
+
| `@ObservedObject` | View receives an `ObservableObject` |
|
|
129
|
+
|
|
130
|
+
### Modern API Replacements
|
|
131
|
+
| Deprecated | Modern Alternative |
|
|
132
|
+
|------------|-------------------|
|
|
133
|
+
| `foregroundColor()` | `foregroundStyle()` |
|
|
134
|
+
| `cornerRadius()` | `clipShape(.rect(cornerRadius:))` |
|
|
135
|
+
| `tabItem()` | `Tab` API |
|
|
136
|
+
| `onTapGesture()` | `Button` (unless need location/count) |
|
|
137
|
+
| `NavigationView` | `NavigationStack` |
|
|
138
|
+
| `onChange(of:) { value in }` | `onChange(of:) { old, new in }` or `onChange(of:) { }` |
|
|
139
|
+
| `fontWeight(.bold)` | `bold()` |
|
|
140
|
+
| `GeometryReader` | `containerRelativeFrame()` or `visualEffect()` |
|
|
141
|
+
| `showsIndicators: false` | `.scrollIndicators(.hidden)` |
|
|
142
|
+
| `String(format: "%.2f", value)` | `Text(value, format: .number.precision(.fractionLength(2)))` |
|
|
143
|
+
| `string.contains(search)` | `string.localizedStandardContains(search)` (for user input) |
|
|
144
|
+
|
|
145
|
+
### Liquid Glass Patterns
|
|
146
|
+
```swift
|
|
147
|
+
// Basic glass effect with fallback
|
|
148
|
+
if #available(iOS 26, *) {
|
|
149
|
+
content
|
|
150
|
+
.padding()
|
|
151
|
+
.glassEffect(.regular.interactive(), in: .rect(cornerRadius: 16))
|
|
152
|
+
} else {
|
|
153
|
+
content
|
|
154
|
+
.padding()
|
|
155
|
+
.background(.ultraThinMaterial, in: RoundedRectangle(cornerRadius: 16))
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Grouped glass elements
|
|
159
|
+
GlassEffectContainer(spacing: 24) {
|
|
160
|
+
HStack(spacing: 24) {
|
|
161
|
+
GlassButton1()
|
|
162
|
+
GlassButton2()
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Glass buttons
|
|
167
|
+
Button("Confirm") { }
|
|
168
|
+
.buttonStyle(.glassProminent)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Review Checklist
|
|
172
|
+
|
|
173
|
+
### State Management
|
|
174
|
+
- [ ] Using `@Observable` instead of `ObservableObject` for new code
|
|
175
|
+
- [ ] `@Observable` classes marked with `@MainActor` (if needed)
|
|
176
|
+
- [ ] Using `@State` with `@Observable` classes (not `@StateObject`)
|
|
177
|
+
- [ ] `@State` and `@StateObject` properties are `private`
|
|
178
|
+
- [ ] Passed values NOT declared as `@State` or `@StateObject`
|
|
179
|
+
- [ ] `@Binding` only where child modifies parent state
|
|
180
|
+
- [ ] `@Bindable` for injected `@Observable` needing bindings
|
|
181
|
+
- [ ] Nested `ObservableObject` avoided (or passed directly to child views)
|
|
182
|
+
|
|
183
|
+
### Modern APIs (see `references/modern-apis.md`)
|
|
184
|
+
- [ ] Using `foregroundStyle()` instead of `foregroundColor()`
|
|
185
|
+
- [ ] Using `clipShape(.rect(cornerRadius:))` instead of `cornerRadius()`
|
|
186
|
+
- [ ] Using `Tab` API instead of `tabItem()`
|
|
187
|
+
- [ ] Using `Button` instead of `onTapGesture()` (unless need location/count)
|
|
188
|
+
- [ ] Using `NavigationStack` instead of `NavigationView`
|
|
189
|
+
- [ ] Avoiding `UIScreen.main.bounds`
|
|
190
|
+
- [ ] Using alternatives to `GeometryReader` when possible
|
|
191
|
+
- [ ] Button images include text labels for accessibility
|
|
192
|
+
|
|
193
|
+
### Sheets & Navigation (see `references/sheet-navigation-patterns.md`)
|
|
194
|
+
- [ ] Using `.sheet(item:)` for model-based sheets
|
|
195
|
+
- [ ] Sheets own their actions and dismiss internally
|
|
196
|
+
- [ ] Using `navigationDestination(for:)` for type-safe navigation
|
|
197
|
+
|
|
198
|
+
### ScrollView (see `references/scroll-patterns.md`)
|
|
199
|
+
- [ ] Using `ScrollViewReader` with stable IDs for programmatic scrolling
|
|
200
|
+
- [ ] Using `.scrollIndicators(.hidden)` instead of initializer parameter
|
|
201
|
+
|
|
202
|
+
### Text & Formatting (see `references/text-formatting.md`)
|
|
203
|
+
- [ ] Using modern Text formatting (not `String(format:)`)
|
|
204
|
+
- [ ] Using `localizedStandardContains()` for search filtering
|
|
205
|
+
|
|
206
|
+
### View Structure (see `references/view-structure.md`)
|
|
207
|
+
- [ ] Using modifiers instead of conditionals for state changes
|
|
208
|
+
- [ ] Complex views extracted to separate subviews
|
|
209
|
+
- [ ] Views kept small for performance
|
|
210
|
+
- [ ] Container views use `@ViewBuilder let content: Content`
|
|
211
|
+
|
|
212
|
+
### Performance (see `references/performance-patterns.md`)
|
|
213
|
+
- [ ] View `body` kept simple and pure (no side effects)
|
|
214
|
+
- [ ] Passing only needed values (not large config objects)
|
|
215
|
+
- [ ] Eliminating unnecessary dependencies
|
|
216
|
+
- [ ] State updates check for value changes before assigning
|
|
217
|
+
- [ ] Hot paths minimize state updates
|
|
218
|
+
- [ ] No object creation in `body`
|
|
219
|
+
- [ ] Heavy computation moved out of `body`
|
|
220
|
+
|
|
221
|
+
### List Patterns (see `references/list-patterns.md`)
|
|
222
|
+
- [ ] ForEach uses stable identity (not `.indices`)
|
|
223
|
+
- [ ] Constant number of views per ForEach element
|
|
224
|
+
- [ ] No inline filtering in ForEach
|
|
225
|
+
- [ ] No `AnyView` in list rows
|
|
226
|
+
|
|
227
|
+
### Layout (see `references/layout-best-practices.md`)
|
|
228
|
+
- [ ] Avoiding layout thrash (deep hierarchies, excessive GeometryReader)
|
|
229
|
+
- [ ] Gating frequent geometry updates by thresholds
|
|
230
|
+
- [ ] Business logic separated into testable models
|
|
231
|
+
- [ ] Action handlers reference methods (not inline logic)
|
|
232
|
+
- [ ] Using relative layout (not hard-coded constants)
|
|
233
|
+
- [ ] Views work in any context (context-agnostic)
|
|
234
|
+
|
|
235
|
+
### Liquid Glass (iOS 26+)
|
|
236
|
+
- [ ] `#available(iOS 26, *)` with fallback for Liquid Glass
|
|
237
|
+
- [ ] Multiple glass views wrapped in `GlassEffectContainer`
|
|
238
|
+
- [ ] `.glassEffect()` applied after layout/appearance modifiers
|
|
239
|
+
- [ ] `.interactive()` only on user-interactable elements
|
|
240
|
+
- [ ] Shapes and tints consistent across related elements
|
|
241
|
+
|
|
242
|
+
## References
|
|
243
|
+
- `references/state-management.md` - Property wrappers and data flow (prefer `@Observable`)
|
|
244
|
+
- `references/view-structure.md` - View composition, extraction, and container patterns
|
|
245
|
+
- `references/performance-patterns.md` - Performance optimization techniques and anti-patterns
|
|
246
|
+
- `references/list-patterns.md` - ForEach identity, stability, and list best practices
|
|
247
|
+
- `references/layout-best-practices.md` - Layout patterns, context-agnostic views, and testability
|
|
248
|
+
- `references/modern-apis.md` - Modern API usage and deprecated replacements
|
|
249
|
+
- `references/sheet-navigation-patterns.md` - Sheet presentation and navigation patterns
|
|
250
|
+
- `references/scroll-patterns.md` - ScrollView patterns and programmatic scrolling
|
|
251
|
+
- `references/text-formatting.md` - Modern text formatting and string operations
|
|
252
|
+
- `references/image-optimization.md` - AsyncImage, image downsampling, and optimization
|
|
253
|
+
- `references/liquid-glass.md` - iOS 26+ Liquid Glass API
|
|
254
|
+
|
|
255
|
+
## Philosophy
|
|
256
|
+
|
|
257
|
+
This skill focuses on **facts and best practices**, not architectural opinions:
|
|
258
|
+
- We don't enforce specific architectures (e.g., MVVM, VIPER)
|
|
259
|
+
- We do encourage separating business logic for testability
|
|
260
|
+
- We prioritize modern APIs over deprecated ones
|
|
261
|
+
- We emphasize thread safety with `@MainActor` and `@Observable`
|
|
262
|
+
- We optimize for performance and maintainability
|
|
263
|
+
- We follow Apple's Human Interface Guidelines and API design patterns
|