|
| 1 | +When performing a code review, respond in English. |
| 2 | + |
| 3 | +## Architecture & Patterns |
| 4 | + |
| 5 | +When performing a code review, ensure no ViewModels are used in SwiftUI code. If ViewModels are found, suggest refactoring to use native SwiftUI data flow patterns with @Observable objects: `@Observable class BusinessLogic { }` and inject via `.environment(businessLogic)`, retrieve with `@Environment(BusinessLogic.self)`. |
| 6 | + |
| 7 | +When performing a code review, verify that business logic is extracted into @Observable objects when shared across multiple views. If business logic is found directly in views, suggest creating an @Observable class: |
| 8 | +```swift |
| 9 | +@Observable class UserManager { |
| 10 | + var users: [User] = [] |
| 11 | + func loadUsers() async { /* logic */ } |
| 12 | +} |
| 13 | +``` |
| 14 | + |
| 15 | +When performing a code review, ensure proper dependency injection using `.environment()` and `@Environment`. If manual dependency passing is found, suggest: `.environment(dependency)` in parent view and `@Environment(Dependency.self) var dependency` in child view. |
| 16 | + |
| 17 | +When performing a code review, check that views are decomposed into small, focused components. If large views with mixed concerns are found, suggest breaking them into smaller, single-purpose components with descriptive names. |
| 18 | + |
| 19 | +## State Management |
| 20 | + |
| 21 | +When performing a code review, verify proper use of @State for local view state. If inappropriate state management is found, suggest: `@State private var isLoading = false` for local state that belongs to the view. |
| 22 | + |
| 23 | +When performing a code review, ensure @Binding is used correctly for two-way data flow between parent and child views. If direct state manipulation is found across view boundaries, suggest: `@Binding var selectedItem: Item` in child view. |
| 24 | + |
| 25 | +When performing a code review, check that @Observable is used for shared business logic objects. If singleton patterns or global state are found, suggest refactoring to @Observable objects with proper injection. |
| 26 | + |
| 27 | +When performing a code review, verify that state mutations happen on the main actor. If background thread UI updates are found, suggest: `await MainActor.run { /* UI updates */ }` or `@MainActor` annotations. |
| 28 | + |
| 29 | +## Modern iOS APIs & Features |
| 30 | + |
| 31 | +When performing a code review, ensure iOS 18/26 features have proper availability checks. If modern APIs are used without guards, suggest: |
| 32 | +```swift |
| 33 | +if #available(iOS 18.0, *) { |
| 34 | + // Use iOS 18+ features |
| 35 | +} else { |
| 36 | + // Fallback implementation |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +When performing a code review, check for proper implementation of iOS 26 Liquid Glass effects. If outdated visual effects are used, suggest migrating to new Liquid Glass APIs with availability checks. |
| 41 | + |
| 42 | +When performing a code review, verify that enhanced scrolling and text capabilities from iOS 18/26 are used appropriately. If legacy implementations are found, suggest modernizing with new APIs. |
| 43 | + |
| 44 | +## Async & Lifecycle |
| 45 | + |
| 46 | +When performing a code review, ensure .task modifier is used instead of .onAppear for async operations. If .onAppear with async code is found, suggest: |
| 47 | +```swift |
| 48 | +.task { |
| 49 | + await loadData() |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +When performing a code review, verify understanding of .task vs .onAppear lifecycle differences. If incorrect usage is found, explain that .task automatically cancels when view disappears and suggest appropriate usage. |
| 54 | + |
| 55 | +When performing a code review, check that async operations in views use environment objects. If complex async logic is in view extensions, suggest moving to @Observable business logic objects: |
| 56 | +```swift |
| 57 | +extension MyView { |
| 58 | + func loadData() async { |
| 59 | + await environment.businessLogic.loadData() |
| 60 | + } |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +## Component Design & Reusability |
| 65 | + |
| 66 | +When performing a code review, ensure components are truly independent and reusable. If tightly coupled components are found, suggest refactoring to accept generic data types and use proper @Binding or environment injection. |
| 67 | + |
| 68 | +When performing a code review, verify that each component has a single responsibility. If multi-purpose components are found, suggest breaking them down: `UserCard`, `UserList`, `UserDetail` instead of one large `UserView`. |
| 69 | + |
| 70 | +When performing a code review, check that composition is preferred over complex view hierarchies. If deeply nested views are found, suggest flattening with reusable components. |
| 71 | + |
| 72 | +## Code Quality & Style |
| 73 | + |
| 74 | +When performing a code review, ensure descriptive names are used for components and state properties. If unclear names are found, suggest: `isLoadingUsers` instead of `loading`, `UserProfileCard` instead of `Card`. |
| 75 | + |
| 76 | +When performing a code review, verify that SwiftUI conventions are followed. If non-standard patterns are found, suggest Apple's recommended approaches from official documentation. |
| 77 | + |
| 78 | +When performing a code review, check that small business logic in view extensions is appropriate. If complex business logic is found in views, suggest extracting to @Observable objects. |
| 79 | + |
| 80 | +When performing a code review, ensure proper separation of concerns between UI and business logic. If mixed responsibilities are found, suggest clear boundaries with injected dependencies. |
| 81 | + |
| 82 | +## Performance & Best Practices |
| 83 | + |
| 84 | +When performing a code review, verify that expensive operations are not performed directly in view body. If heavy computations are found, suggest moving to @Observable objects or using proper caching mechanisms. |
| 85 | + |
| 86 | +When performing a code review, check for proper use of @ViewBuilder and custom view builders. If repetitive view code is found, suggest creating reusable view builders. |
| 87 | + |
| 88 | +When performing a code review, ensure that unnecessary view updates are avoided. If frequent recomputations are found, suggest proper state granularity and @Observable property organization. |
| 89 | + |
| 90 | +## Error Handling & Edge Cases |
| 91 | + |
| 92 | +When performing a code review, verify proper error handling in async operations. If unhandled errors are found, suggest proper do-catch blocks and user feedback mechanisms. |
| 93 | + |
| 94 | +When performing a code review, check that loading states and empty states are properly handled. If missing states are found, suggest comprehensive state management: |
| 95 | +```swift |
| 96 | +enum LoadingState<T> { |
| 97 | + case idle, loading, loaded(T), error(Error) |
| 98 | +} |
| 99 | +``` |
| 100 | + |
| 101 | +When performing a code review, ensure accessibility is considered in custom components. If accessibility features are missing, suggest proper accessibility modifiers and labels. |
| 102 | + |
| 103 | +## Documentation & Testing |
| 104 | + |
| 105 | +When performing a code review, verify that complex business logic in @Observable objects is properly documented. If undocumented logic is found, suggest adding clear comments explaining the purpose and behavior. |
| 106 | + |
| 107 | +When performing a code review, check that components are designed for testability. If hard-to-test code is found, suggest refactoring with proper dependency injection and observable patterns. |
| 108 | + |
| 109 | +When performing a code review, ensure that modern SwiftUI patterns are used correctly according to Apple's latest best practices. If outdated patterns are found, suggest consulting Apple's official documentation and updating to current recommendations. |
| 110 | + |
| 111 | + |
| 112 | +## Lightning & Bitcoin Specific |
| 113 | + |
| 114 | +When performing a code review, verify that Bitcoin/Lightning operations are properly handled in the service layer. |
| 115 | + |
| 116 | +When performing a code review, verify that proper Bitcoin and Lightning technical terms are used when naming code components |
0 commit comments