agentsclimarketplace

Swift performance pro

Skill laxrajpurohit/swift-skills-pro/swift-performance-pro/skills/swift-performance-pro

Modern, original agent skills for Swift and Apple-platform development

Install
npx -y skills add laxrajpurohit/swift-skills-pro --skill swift-performance-pro

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

  • 5 stars5 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 diagnosing or fixing performance — SwiftUI render cost, memory and retain cycles, slow lists, launch time, and using Instruments.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

2.8 KB, as published. Nobody here has run it

Swift Performance Pro

Find and fix performance problems with evidence, not guesses. Measure first.

When to use

  • Janky scrolling, slow launch, high memory, or battery drain.
  • Reviewing code for performance regressions.
  • Planning an Instruments session.

Trigger: /swift-performance-pro.

Core principles

  • Measure before optimizing — use Instruments (Time Profiler, Allocations, SwiftUI, Leaks), not intuition.
  • Keep SwiftUI body cheap and pure; recomputation is frequent.
  • Do heavy work off the main actor.
  • Don't optimize what you haven't proven is hot.

SwiftUI render cost

Keep body free of side effects and heavy compute.

❌ Sorting on every render

var body: some View {
    List(items.sorted { $0.date > $1.date }) { Row($0) }   // re-sorts each pass
}

✅ Sort once in the model

// model exposes already-sorted `items`
var body: some View { List(model.items) { Row($0) } }

Narrow observation so unrelated changes don't redraw everything. Split big views into small subviews so SwiftUI can diff precisely.

Lists

  • LazyVStack/List for long content, not eager VStack in a ScrollView.
  • Stable Identifiable IDs — index-based identity forces full rebuilds.
  • Avoid AnyView in row builders; it defeats SwiftUI's diffing.

Memory & retain cycles

❌ Strong self capture in a stored closure

manager.onUpdate = { self.refresh() }   // cycle: manager → closure → self

manager.onUpdate = { [weak self] in self?.refresh() }

Verify deinit runs. Use Instruments → Leaks / Allocations to confirm.

Off the main actor

let image = UIImage(data: hugeData)   // decode on main → dropped frames

let image = await Task.detached { UIImage(data: hugeData) }.value

Downsample large images to the display size instead of loading full-resolution.

Launch time

  • Defer non-critical work out of init/onAppear; load it in .task.
  • Avoid synchronous disk/network on the launch path.
  • Audit with Instruments → App Launch.

Common mistakes checklist

  • Sorting/filtering/heavy compute inside body.
  • Eager VStack where LazyVStack/List is needed.
  • Index-based identity forcing full list rebuilds.
  • AnyView in hot row builders.
  • Strong self in stored closures (retain cycle).
  • Image decode / disk / network on the main actor or launch path.
  • Optimizing without an Instruments trace proving the hotspot.

Output format (when reviewing)

Per issue: file:line, the cost, before/after, and which Instrument confirms it. Lead with main-thread blockers.

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.