← LeaderboardThe Skill Leaderboard

swiftui-audit

This skill should be used when the user asks to "audit SwiftUI code", "scan a SwiftUI project for deprecated API", "find SwiftUI anti-patterns", or run a static SwiftUI check before a review or release.

Published by fcakyon ↗fcakyon/claude-codex-settings

Try your first task

A source-grounded starter task has not been verified for this skill yet.

SKILL.md

name: swiftui-auditdescription: This skill should be used when the user asks to "audit SwiftUI code", "scan a SwiftUI project for deprecated API", "find SwiftUI anti-patterns", or run a static SwiftUI check before a review or release.

SwiftUI audit

Run the bundled auditor first. It finds a small set of patterns that can be recognized from source text alone, then the swiftui-best-practices skill covers everything that needs judgment.

node scripts/swiftui-audit.mjs <app-or-package-dir> [--json] [--target ios=17,macos=14] [--include-tests]
  • Node with no dependencies. The tests pass on Node 24 (Linux) and Node 22 (macOS).
  • The deployment target comes from platforms: in Package.swift or *_DEPLOYMENT_TARGET in project.pbxproj, inside the scan root or its nearest parent that has one. With several targets, the lowest per platform wins. --target overrides it. The output names the source, or says the target is unknown.
  • Comments and string contents are masked before matching, so commented-out code and text in literals never match.
  • .build, DerivedData, Pods, Carthage, SourcePackages, checkouts, node_modules, *.xcodeproj, directories ending in Tests and files ending in Tests.swift are skipped. --include-tests scans tests too.
  • Exit code 1 means findings were printed, 0 means none, 2 means a usage error.

Rules

Each finding gives the file, line, rule, the code, the problem and the next action. fix means the replacement is mechanical. review means the next action starts with "Needs human context" and names the fact to check before changing anything.

RuleLevelFlagsKept off when
index-identityreviewForEach(x.indices, ...), ForEach(0..<x.count, ...) or enumerated() with id: \.offsetelement IDs, literal ranges, for loops
text-concatenationreviewText + Text chains (one finding per chain) and Text("a" + b)+ inside interpolation, Text(verbatim:), + not next to a literal
foreground-colorfix.foregroundColor() modifierinside a reported Text + chain, target below iOS 15 / macOS 12
view-argument-overloadfix.background(Circle()), .overlay(MyView()), .mask(...) with a built-in or project-declared View or Shapestyle arguments, in: shapes, closures, unknown types
onchange-single-parameterfix.onChange(of:) { value in } and perform:zero or two parameters, initial:, target below iOS 17 / macOS 14
animation-without-valuefix.animation(x) modifier without value:TimelineView(.animation...), $binding.animation(), transitions, the .animation(x) { } body form
corner-radius-modifierfix.cornerRadius() modifierRoundedRectangle(cornerRadius:) and other labels
state-not-privatereview@State or @StateObject without privateprivate and private(set)

Next actions follow the deployment target. corner-radius-modifier suggests .rect(cornerRadius:) from iOS 17 / macOS 14 and RoundedRectangle below. index-identity keeps Array(x.enumerated()) below iOS 26 / macOS 26.

Acting on findings

  1. Apply fix findings in small batches and build after each one. Change only the reported expression.
  2. For each review finding, read the collection or property it names. Leave it as is when the stated condition does not hold, and say so in the review.
  3. Report the rest with swiftui-best-practices. Do not rewrite code that the auditor did not report only because a pattern exists. Examples are ObservableObject, GeometryReader and compatibility code for older targets.

Limits

For an app that reuses a manually managed AppKit window, trace close, Dock reopen and updater relaunch. Set isReleasedWhenClosed = false on a window that those callbacks retain and reuse. Exercise close and reopen on the same instance.

  • Matching is lexical. It does not resolve types, so view-argument-overload recognizes only built-in views and View or Shape types declared in the scanned files, and skips variables.
  • Binding(get:set:) is not a rule. Most real setters have side effects or roll back on failure, so a safe replacement always needs a person.
  • Regex literals are not masked, and a + between two values that are both stored Text variables is missed.
  • A clean run proves only that these eight patterns are absent. It is not a SwiftUI review.

Tests

node --test plugins/swift-skills/skills/swiftui-audit/tests/swiftui-audit.test.mjs