existential-birds/beagle / plugins/beagle-ios/skills/widgetkit-code-review
widgetkit-code-review
VerifiedReviews WidgetKit code for timeline management, view composition, configurable intents, and performance. Use when reviewing code with import WidgetKit, TimelineProvider, Widget protocol, or @main struct Widget.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 3.6 KB |
| references/intents.md | markdown | 4.1 KB |
| references/performance.md | markdown | 4.5 KB |
| references/timeline.md | markdown | 4.2 KB |
| references/views.md | markdown | 2.9 KB |
references/views.md
View on GitHub# Widget Views
## Widget Families
**Home Screen:** `systemSmall`, `systemMedium`, `systemLarge`, `systemExtraLarge` (iPad only)
**Lock Screen (iOS 16+):** `accessoryCircular`, `accessoryRectangular`, `accessoryInline`
```swift
.supportedFamilies([.systemSmall, .systemMedium, .accessoryCircular, .accessoryRectangular])
```
## View Composition
Use `@Environment(\.widgetFamily)` for adaptive layouts:
```swift
@Environment(\.widgetFamily) var widgetFamily
var body: some View {
switch widgetFamily {
case .systemSmall: CompactView()
case .accessoryCircular: CircularWidgetView()
case .accessoryInline: Text(entry.summary)
default: DetailedView()
}
}
```
- Use `@Environment(\.widgetRenderingMode)` to detect Lock Screen vibrant mode
- `AccessoryWidgetBackground()` works for `accessoryCircular`/`accessoryRectangular` only
- Use `ViewThatFits` for content that may truncate
## containerBackground
**Required for iOS 17+.** Widgets show error without this modifier.
```swift
Text("Content")
.containerBackground(for: .widget) { Color.blue }
```
**Backwards compatibility:**
```swift
extension View {
func widgetBackground(_ bg: some View) -> some View {
if #available(iOSApplicationExtension 17.0, *) {
return containerBackground(for: .widget) { bg }
} else { return background(bg) }
}
}
```
**Configuration modifiers:**
- `.containerBackgroundRemovable(false)` - Prevent removal in StandBy
- `.contentMarginsDisabled()` - Opt out of automatic margins
## Deep Linking
| Size | Method | Notes |
|------|--------|-------|
| `systemSmall` | `widgetURL()` | Entire widget is one tap target |
| `systemMedium`/`Large` | `Link` or `widgetURL()` | Multiple tappable regions |
```swift
// Small widgets: entire widget taps
.widgetURL(URL(string: "myapp://item/\(entry.id)")!)
// Medium/Large: multiple targets
Link(destination: URL(string: "myapp://section1")!) { Text("Section 1") }
```
Handle in app with `.onOpenURL { url in handleDeepLink(url) }`
## Critical Anti-Patterns
| Issue | Problem |
|-------|---------|
| Missing `containerBackground` | iOS 17 shows error instead of widget |
| `Link` in `systemSmall` | Silently fails, only `widgetURL` works |
| `Button` in widgets | Never works, use `Link` or `widgetURL` |
| Same view for all families | Content truncated or wasted space |
| `AccessoryWidgetBackground` in `accessoryInline` | Renders empty view |
| No URL validation in `onOpenURL` | Security risk from malformed deep links |
## Review Questions
1. Does the widget use `containerBackground(for:)` for iOS 17+ compatibility?
2. Are Lock Screen families handled with appropriate compact layouts?
3. Is `widgetURL` used for `systemSmall` instead of `Link`?
4. Does the code avoid `Button` views (never work in widgets)?
5. Is `AccessoryWidgetBackground` excluded from `accessoryInline` contexts?
6. Are deep link URLs validated before navigation?
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |