/apple-apps:instrumenting-accessibility-identifiersfrom Apple Apps
Adds or audits typed accessibility identifiers and XCUITest selectors in SwiftUI or UIKit. Creates compiler-checked automation contracts for UI testing and screenshot automation.
Ships in Apple Apps. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Create or migrate a compiler-checked accessibility-identifier contract that works across SwiftUI, UIKit, XCUITest, and screenshot automation.
Resolve bundled scripts/, assets/, and reference paths relative to this skill directory, not the consumer repository.
Read references/architecture.md before implementing or reviewing this pattern. Read references/migration.md when the repository already contains raw identifiers. Before finishing, check the work against references/review-checklist.md.
AccessibilityIdentifier non-generic. Owner typing belongs at construction time, not in every shared component API.ExpressibleByStringLiteral to the core module. A deprecated migration-only conformance may exist in an isolated file and must have an explicit removal plan.identifier == rawValue with an NSPredicate. Do not implement the typed subscript by forwarding to a string subscript or broad identifier-style lookup.@testable import for the automation contract. Types consumed by UI tests must be public and live in an importable library/module.Determine these facts from the repository before editing:
Run the bundled read-only inventory when useful:
python3 scripts/audit_accessibility_identifiers.py /path/to/repository
Do not raise the deployment target, Swift tools version, or language mode merely to install this pattern. Match the repository unless the user explicitly requests an upgrade. Do not introduce macros, code generation, page-object architecture, or a new dependency unless the repository already standardizes it or the user explicitly requests it.
Use this order:
AccessibilityUI and AccessibilityUIForTest products.Never make AccessibilityUI depend on app or feature modules. Screen contracts and compact screen factories belong in the owning feature module or a separate app-specific identifier-contract module.
For a modular app, a public view or view controller may conform directly to AccessibilityInstrumented. For a monolithic executable target, an internal owner, or any type the UI-test target cannot import, use a standalone public namespace in a shared library instead of forcing the concrete UI type public.
Use assets/AccessibilityPackage as the baseline only when creating new infrastructure. Adapt names, deployment target, language mode, file headers, access control, and repository conventions rather than copying blindly.
The production-facing module must provide:
AccessibilityIdentifierAccessibilityIdentifierComponentAccessibilityIdentifierScopeAccessibilityElementAccessibilityInstrumentedAccessibilityIdentifierNamespaceThe canonical generated form is:
Scope_element
Scope_element_component
Use stable UpperCamelCase scopes and stable lowerCamelCase element roles. Dynamic components must come from stable, non-sensitive identities and pass through AccessibilityIdentifierComponent.
Prefer a nested enum when the owner is non-generic, public, and importable by consumers:
extension LoginView: AccessibilityInstrumented {
public enum AccessibilityUIElement: String, AccessibilityElement {
case emailField
case passwordField
case submitButton
}
public static let accessibilityIdentifierScope =
AccessibilityIdentifierScope("LoginView")
}
Use a standalone namespace when the owner is generic, internal, app-executable-only, or otherwise unsuitable as the public contract:
public enum LoginAccessibility: AccessibilityInstrumented {
public enum AccessibilityUIElement: String, AccessibilityElement {
case emailField
case passwordField
case submitButton
}
public static let accessibilityIdentifierScope =
AccessibilityIdentifierScope("LoginView")
}
Normal app spelling:
LoginView.accessibilityIdentifiers[.submitButton]
LoginAccessibility.accessibilityIdentifiers[.submitButton]
A compact screen-specific factory is optional and recommended for high-traffic UI tests:
public extension AccessibilityIdentifier {
static func loginView(_ element: LoginView.AccessibilityUIElement) -> Self {
LoginView.accessibilityIdentifier(for: element)
}
}
Do not create a dependency cycle to obtain the compact spelling.
SwiftUI:
Button, TextField, SecureField, NavigationLink, or the actual tappable row/container.Text inside a Button.UIKit:
prepareForReuse() when configuration can omit or change them.UIBarButtonItem, cells, controls, and semantic containers only when automation needs them.Shared components accept AccessibilityIdentifier?, never String?, and forward it to the concrete interactive element. Shared components do not invent screen identity.
The test-only module must provide:
app.buttons[.loginView(.submitButton)]
or:
app.buttons[LoginView.accessibilityIdentifiers[.submitButton]]
Implement lookup with a predicate on the identifier attribute and return firstMatch. Keep existence helpers small and assertion messages identifier-focused.
Preserve existing raw identifier values during the first migration pass when renaming them would create unrelated test churn. Encode those values behind typed factories, then normalize names in a separate deliberate change.
Replace in this order:
Do not instrument every view. Keep the public automation surface curated around stable workflow anchors.
Create an app-level catalog of all static identifiers and tests for validity and uniqueness. The catalog must be maintained explicitly; Swift cannot reliably discover every conforming type automatically.
Add a repository-appropriate lint rule that blocks raw .accessibilityIdentifier("...") calls and raw accessibilityIdentifier = "..." assignments outside the core package and explicit migration files. Prefer SwiftSyntax for mature codebases; a custom regex rule is acceptable as a starter.
Run the narrowest available checks first, then the repository-standard checks:
swift test for a standalone package when applicable.Inspect the final diff for accidental public API expansion, app-to-test dependencies, raw strings, sensitive dynamic components, and identifiers attached to the wrong semantic element.
State:
Do not claim that identifier instrumentation proves the UI is accessible.
agents/openai.yaml (opens in a new tab)assets/AccessibilityPackage/Package.swift (opens in a new tab)assets/AccessibilityPackage/Sources/AccessibilityUI/AccessibilityIdentifier.swift (opens in a new tab)assets/AccessibilityPackage/Sources/AccessibilityUI/AccessibilityIdentifierComponent.swift (opens in a new tab)assets/AccessibilityPackage/Sources/AccessibilityUI/AccessibilityIdentifierScope.swift (opens in a new tab)assets/AccessibilityPackage/Sources/AccessibilityUI/AccessibilityInstrumented.swift (opens in a new tab)assets/AccessibilityPackage/Sources/AccessibilityUI/SwiftUI+AccessibilityIdentifier.swift (opens in a new tab)assets/AccessibilityPackage/Sources/AccessibilityUI/UIKit+AccessibilityIdentifier.swift (opens in a new tab)assets/AccessibilityPackage/Sources/AccessibilityUIForTest/XCUIElementQuery+AccessibilityIdentifier.swift (opens in a new tab)assets/AccessibilityPackage/Tests/AccessibilityUITests/AccessibilityIdentifierTests.swift (opens in a new tab)references/architecture.md (opens in a new tab)references/migration.md (opens in a new tab)references/review-checklist.md (opens in a new tab)scripts/audit_accessibility_identifiers.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub kylehughes/agent-plugins-for-making-good-software --plugin apple-apps7 skills in this plugin
/configuring-ios-contentConfigure UIKit cell content, backgrounds, empty states, and SwiftUI hosting. Use proactively for cell registration, configuration updates, reuse, or legacy cell-label migration./implementing-app-intentsBuild or debug App Intents, entities, queries, and system integrations. Use proactively for Siri, Shortcuts, Spotlight, widgets, controls, or Apple Intelligence integration./localizing-stringsLocalize Apple-platform UI text with string catalogs and bundle-aware APIs. Use proactively for new user-facing strings, plurals, interpolation, or hardcoded-string extraction./presenting-ios-modalsBuild or review SwiftUI and UIKit modal sheets, navigation chrome, button roles, detents, and dismissal. Use proactively for modal flows; not ordinary navigation or general styling./recording-ios-simulator-videosRecord and compress iOS Simulator video for UI tests, bug reproductions, or PR demos. Use when a video artifact is needed; not screenshots or physical-device capture./simplifying-apple-platform-codeSimplify Swift and Apple-platform code while preserving SDK, lifecycle, concurrency, and deployment contracts. Use proactively for requested cleanup with simplifying-code when available.Other plugins' skills for the same job