agentsclimarketplace

Ios performance battery patterns

Skill patrickserrano/lacquer/profiles/ios/skills/ios-performance-battery-patterns

Go CLI + profile templates that standardize how Claude Code works across every project

Install
npx -y skills add patrickserrano/lacquer --skill ios-performance-battery-patterns

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Use when touching widgets, animations, networking configuration, or background/observer cleanup — battery and performance patterns for WidgetKit timelines, SwiftUI animations, Low Power Mode handling, URLSession config, and NotificationCenter/Task cleanup under `@Observable`.

SKILL.md

2.3 KB, as published. Nobody here has run it

Battery & Performance Patterns

Apply these whenever touching widgets, animations, networking, or background work.

Widgets

  • Limit Timeline entries to ≤ 2 (current + one next-day refresh). More entries run the provider repeatedly and drain battery.
  • Use .atEnd reload policy — let WidgetKit decide when to refresh.

Animations

  • Always stop animations in .onDisappear. Animations left running off-screen still consume CPU/GPU.
  • Bind repeating animations to a @State var isAnimating = false: set true in .onAppear, false in .onDisappear, and pass value: isAnimating to withAnimation.
  • Use .repeatCount(N) instead of .repeatForever for attention animations.

Low Power Mode

Guard expensive operations before they start:

guard !ProcessInfo.processInfo.isLowPowerModeEnabled else { return }

Apply to: image preloading, background downloads, video prefetch, heavy sync.

Network

let config = URLSessionConfiguration.default
config.allowsConstrainedNetworkAccess = false  // respect Low Data Mode
config.allowsExpensiveNetworkAccess = false    // avoid cellular when Wi-Fi preferred
config.waitsForConnectivity = true             // queue rather than fail when offline

Observer & Task Cleanup

@Observable macro-generated storage prevents nonisolated deinit from removing NotificationCenter observers. Use reference-type boxes instead:

final class NotificationObserverBox {
    private var tokens: [NSObjectProtocol] = []
    func add(_ token: NSObjectProtocol) { tokens.append(token) }
    deinit { tokens.forEach { NotificationCenter.default.removeObserver($0) } }
}

final class TaskBox {
    private var cancel: (() -> Void)?
    func store<Success, Failure>(_ task: Task<Success, Failure>) { cancel = { task.cancel() } }
    deinit { cancel?() }
}

For MPRemoteCommandCenter: store addTarget return values; call removeTarget(nil) on each in deinit.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.