MCPInstall

swift-security

Use when working with iOS/macOS Keychain Services (SecItem queries, kSecClass, OSStatus errors), biometric authentication (LAContext, Face ID, Touch ID), CryptoKit (AES-GCM, ChaChaPoly, ECDSA, ECDH, HPKE, ML-KEM), Secure Enclave, secure credential storage (OAuth tokens, API keys), certificate pinning (SecTrust, SPKI), keychain sharing across apps/extensions, migrating secrets from UserDefaults or plists, or OWASP MASVS/MASTG mobile compliance on Apple platforms.

Installs
3K
Last 24h
+17
Trending rank
#6542
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/dpearson2699/swift-ios-skills --skill swift-security
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads swift-security automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Swift Security

Use this skill for client-side Apple platform security work: Keychain Services, access control, biometric-gated secrets, CryptoKit, Secure Enclave keys, credential storage, certificate trust, keychain sharing, legacy secret migration, security testing, and OWASP mobile compliance mapping.

Default to iOS 17+ and Swift concurrency examples when the deployment target is unknown. Keep iOS 13+ compatibility notes when the user asks for older targets. Treat iOS 26 CryptoKit post-quantum APIs as availability-gated.

Contents

Workflow

Classify the request before loading references.

  1. Review existing code: run the Review Checklist, then load common-anti-patterns.md plus the domain reference for each failing area. Report severity, evidence, and the corrected pattern.
  2. Improve or migrate code: identify the migration type, load the migration and target-domain references, preserve existing data, verify the new item, then remove legacy storage only after success.
  3. Implement new security code: load the minimum domain references, use the provided correct patterns, include OSStatus handling and tests, then run the relevant checklist.

Do not load every reference file by default. This skill is intentionally split for progressive disclosure; load only the files needed by the user's task.

Minimum Safe Keychain Write

Use separate add, identity, and update dictionaries; handle every OSStatus:

func saveSecret(_ data: Data, account: String) throws {
    let identity: [CFString: Any] = [
        kSecClass: kSecClassGenericPassword,
        kSecAttrService: "com.example.app",
        kSecAttrAccount: account,
    ]
    var add = identity
    add[kSecValueData] = data
    add[kSecAttrAccessible] = kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly

    switch SecItemAdd(add as CFDictionary, nil) {
    case errSecSuccess:
        return
    case errSecDuplicateItem:
        let status = SecItemUpdate(
            identity as CFDictionary,
            [kSecValueData: data] as CFDictionary
        )
        guard status == errSecSuccess else { throw KeychainError(status: status) }
    case let status:
        throw KeychainError(status: status)
    }
}

Load keychain-fundamentals.md for read, delete, access-control, locked-device, and test patterns.

Reference Loading

If the task involvesLoad
General keychain CRUD or OSStatus handlingkeychain-fundamentals.md
Choosing kSecClass or item identitykeychain-item-classes.md
Accessibility classes or SecAccessControlkeychain-access-control.md
Face ID, Touch ID, or biometric-gated secretsbiometric-authentication.md
Secure Enclave keyssecure-enclave.md
Hashing, HMAC, AES-GCM, ChaChaPoly, HKDF, PBKDF2cryptokit-symmetric.md
Signing, ECDH, HPKE, ML-KEM, ML-DSAcryptokit-public-key.md
OAuth tokens, API keys, logout, refresh rotationcredential-storage-patterns.md
App/extension keychain sharingkeychain-sharing.md
Certificate trust, SPKI pinning, mTLScertificate-trust.md
UserDefaults/plist/NSCoding migrationmigration-legacy-stores.md
Unit, integration, simulator, device, or CI teststesting-security-code.md
OWASP MASVS/MASTG or enterprise audit mappingcompliance-owasp-mapping.md
Full security reviewcommon-anti-patterns.md, then each touched domain reference

Security Invariants

Use directive language only for these security invariants and the matching anti-patterns in common-anti-patterns.md. For architecture choices outside this list, use advisory language.

  • Never store tokens, passwords, API keys, signing keys, or refresh tokens in UserDefaults, Info.plist, .xcconfig, source code, logs, files, or NSCoding archives. Use Keychain or fetch secrets at runtime.
  • Never ignore OSStatus. Every SecItemAdd, SecItemCopyMatching, SecItemUpdate, and SecItemDelete path must handle success and expected failures such as errSecDuplicateItem, errSecItemNotFound, and errSecInteractionNotAllowed.
  • Never use LAContext.evaluatePolicy() as the only gate for a secret. Bind protected secrets to keychain items with SecAccessControl, then let keychain access trigger LocalAuthentication.
  • Always set kSecAttrAccessible or kSecAttrAccessControl explicitly when adding keychain items.
  • Always use add-or-update for persistent keychain writes. Do not delete-then-add as a normal update path.
  • Keep SecItem* work off the main actor. Use an actor or serial queue for keychain access.
  • On macOS AppKit targets, target the data protection keychain with kSecUseDataProtectionKeychain: true unless deliberately working with legacy file-based keychain items.
  • Never reuse an AES-GCM nonce with the same key.
  • Never use raw ECDH SharedSecret bytes as a symmetric key. Derive with HKDF or X9.63 derivation.
  • Never use Insecure.MD5 or Insecure.SHA1 for security purposes.

Sibling Boundaries

This skill owns client-side storage, cryptographic primitives, hardware-backed keys, and trust evaluation. Route adjacent work deliberately:

  • Use authentication for Sign in with Apple, passkeys, OAuth UI flows, ASAuthorizationController, credential state, and account sign-in UX.
  • Use cryptokit for primitive CryptoKit API syntax and examples when storage, key lifecycle, protocol/trust design, Secure Enclave policy, certificate trust, misuse review, or compliance is not part of the task.
  • Keep application-level E2E encryption security reviews here when the work involves key ownership, derivation, storage, rotation/recovery, Secure Enclave, HPKE/PQC migration, protocol trust boundaries, or misuse analysis.
  • Use device-integrity for DeviceCheck and App Attest attestation/assertion flows.
  • Use ios-networking for URLSession, request pipelines, ATS configuration, retries, caching, reachability, and transport architecture.
  • Use app-store-review for privacy manifests, ATT, App Review guideline compliance, and submission readiness.

This skill may mention those areas only to identify a security handoff.

Review Checklist

Use this checklist for code reviews and migration plans. Mark each item pass, fail, or not applicable; for each failure, cite the reference file and severity.

  • Secrets are not stored in UserDefaults, plists, source, logs, files, or archives.
  • Every SecItem* call checks OSStatus and handles common recoverable errors.
  • Biometric access to secrets is keychain-bound with SecAccessControl, not a standalone Bool from LAContext.evaluatePolicy().
  • Keychain add dictionaries set an explicit accessibility policy.
  • Keychain writes use add-or-update rather than delete-then-add.
  • Keychain work is isolated from UI/main-actor code.
  • The selected kSecClass matches the item type and primary-key attributes.
  • CryptoKit code avoids nonce reuse, raw shared-secret use, weak hashes, and hardcoded keys.
  • Custom encryption designs identify key ownership, derivation, storage, rotation/recovery, availability gates, and protocol/trust boundaries.
  • Secure Enclave code checks availability, handles simulator/device differences, persists only dataRepresentation, and designs for device-bound keys.
  • App/extension sharing uses full Team ID access groups and matching entitlements on every target.
  • Certificate trust uses current SecTrust APIs, validates hostname/policy, and uses SPKI or CA pinning when pinning is required.
  • macOS keychain code intentionally chooses data protection or file-based keychain behavior.
  • Tests cover success, duplicate, missing item, locked-device, simulator/device, and migration paths where applicable.
  • OWASP MASVS/MASTG mappings are included when compliance is requested.

Common Mistakes

  • Generating partial keychain examples without duplicate handling or errSecItemNotFound handling.
  • Adding biometric UI but leaving the secret readable without keychain access control.
  • Choosing kSecAttrAccessibleWhenUnlocked implicitly by omitting the attribute.
  • Using kSecAttrAccessibleAlways or kSecAttrAccessibleAlwaysThisDeviceOnly, both deprecated.
  • Mixing kSecAttrAccessible and kSecAttrAccessControl on the same add query.
  • Treating Secure Enclave keys as importable, exportable, syncable, or suitable for symmetric encryption.
  • Claiming SHA-3, ML-KEM, ML-DSA, or X-Wing CryptoKit APIs are available before iOS 26.
  • Treating HPKE as available before iOS 17.
  • Implementing certificate pinning by hashing only raw key bytes instead of the correct SPKI representation.
  • Expanding this skill into account-login, networking, App Attest, or App Store review guidance instead of handing off to sibling skills.

Output Rules

  • For security findings, state severity: CRITICAL for exploitable secret or cryptography failures, HIGH for silent security boundary/data-loss issues, and MEDIUM for brittle or incomplete hardening.
  • Include wrong and corrected code examples for implementation reviews when a concrete anti-pattern is present.
  • Include minimum iOS/macOS availability when recommending versioned APIs.
  • Cite the reference file that supports each substantive security pattern.
  • For keychain code, include OSStatus handling and explicit accessibility in examples.
  • For implementation or migration answers, end with ## Reference Files and list the loaded references with a one-line purpose.
  • Do not invent WWDC session numbers or source citations. If a claim is not present in the loaded references or official Apple documentation, say it needs verification.

References

  • keychain-fundamentals.md - SecItem CRUD, OSStatus handling, add-or-update, macOS data protection keychain.
  • keychain-item-classes.md - kSecClass selection, primary keys, certificates, identities.
  • keychain-access-control.md - Accessibility constants, SecAccessControl, background access, data protection.
  • biometric-authentication.md - Keychain-bound biometrics, LAContext, enrollment-change handling.
  • secure-enclave.md - Secure Enclave constraints, persistence, biometric keys, iOS 26 PQ APIs.
  • cryptokit-symmetric.md - SHA, HMAC, AES-GCM, ChaChaPoly, HKDF, PBKDF2.
  • cryptokit-public-key.md - Signing, key agreement, HPKE, ML-KEM, ML-DSA, key formats.
  • credential-storage-patterns.md - OAuth tokens, API keys, rotation, logout cleanup.
  • keychain-sharing.md - Access groups, extensions, iCloud sync, macOS access groups.
  • certificate-trust.md - SecTrust, SPKI/CA pinning, NSPinnedDomains, client certificates.
  • migration-legacy-stores.md - UserDefaults/plist/NSCoding migration and cleanup.
  • common-anti-patterns.md - Review backbone for insecure generated code.
  • testing-security-code.md - Protocol mocks, real keychain tests, CI/device split.
  • compliance-owasp-mapping.md - OWASP Mobile Top 10, MASVS, MASTG evidence mapping.

FAQ

What does the swift-security skill do?

Use when working with iOS/macOS Keychain Services (SecItem queries, kSecClass, OSStatus errors), biometric authentication (LAContext, Face ID, Touch ID), CryptoKit (AES-GCM, ChaChaPoly, ECDSA, ECDH, HPKE, ML-KEM), Secure Enclave, secure credential storage (OAuth tokens, API keys), certificate pinning (SecTrust, SPKI), keychain sharing across apps/extensions, migrating secrets from UserDefaults or plists, or OWASP MASVS/MASTG mobile compliance on Apple platforms.

How do I install swift-security?

Run npx skills add https://github.com/dpearson2699/swift-ios-skills --skill swift-security in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/swift-security/ (personal) or .claude/skills/swift-security/ (project).

Which AI agents can use swift-security?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is swift-security safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains swift-security?

It is published by dpearson2699 in dpearson2699/swift-ios-skills. It has 3,001 recorded installs.

More from dpearson2699/swift-ios-skills

View all →

swiftui-animation

dpearson2699/swift-ios-skills

Implement, diagnose, or review SwiftUI motion using explicit and scoped implicit animations, springs, transitions, PhaseAnimator, KeyframeAnimator, matched geometry or navigation zoom, SF Symbol effects, and custom Animation types. Use when views should animate on state changes, insertion, removal, navigation, or multi-step choreography, or when motion must respect Reduce Motion and Swift concurrency.

Mobile5.5K installs

ios-accessibility

dpearson2699/swift-ios-skills

Build and audit SwiftUI, UIKit, and AppKit accessibility for VoiceOver, Voice Control, Switch Control, Full Keyboard Access, Dynamic Type, focus restoration, labels/traits/actions, traversal, custom rotors, NSAccessibility, XCTest checks, adaptive system preferences, and App Store accessibility declarations. Use when implementing accessible UI, fixing an accessibility audit, testing assistive-technology behavior, or substantiating App Store Accessibility Nutrition Labels.

Mobile5K installs

swiftui-performance

dpearson2699/swift-ios-skills

Profile, diagnose, and remediate SwiftUI runtime performance using code review, Instruments, and repeatable measurements. Use when a SwiftUI screen renders slowly, scrolling or animations hitch, view bodies update excessively, list identity churns, layout work spikes, or broad Observation dependencies raise CPU cost. Covers evidence-based triage, SwiftUI Instruments lanes, lazy-container guardrails, state lifetime, and before/after verification.

Mobile4.6K installs

swiftui-patterns

dpearson2699/swift-ios-skills

Builds and reviews SwiftUI views with modern MV architecture, state, composition, isolated previews, and migration guidance. Covers @Observable ownership, @State/@Bindable/@Environment wiring, view decomposition, ViewModifiers, environment values, .task loading, iOS 26+ handoffs, Writing Tools, clipboard availability, and performance. Use when structuring SwiftUI state, managing @Observable, composing views, previewing meaningful UI states, or correcting SwiftUI patterns.

Mobile4.6K installs

app-store-review

dpearson2699/swift-ios-skills

Audits App Store submission readiness and rejection risk across current review guidelines, PrivacyInfo.xcprivacy and required-reason APIs, privacy labels, ATT, StoreKit payments, metadata, entitlements, widgets, and Live Activities. Use when preparing a submission, responding to rejection, reconciling privacy evidence, or separating upload blockers from cleanup.

Mobile4.6K installs

ios-networking

dpearson2699/swift-ios-skills

Build, review, or improve networking code in iOS/macOS apps using URLSession with async/await, structured concurrency, and modern Swift patterns. Use when working with REST APIs, downloading files, uploading data, WebSocket connections, pagination, retry logic, request middleware, caching, background transfers, or network reachability monitoring. Also use when handling HTTP requests, API clients, network error handling, or data fetching in Swift apps.

Mobile4.4K installs

Popular mobile skills

View category →

design-mobile-apps

designed-by-ai/skills

Design mobile app screens with Sleek, edit Sleek projects, and implement their designs in React Native or HTML.

Mobile1.1M installs

ios-design

uizze.sh

Design and review iOS UI/UX for iPhone apps in SwiftUI, UIKit, or React Native. Use for mobile app design, screen redesigns, navigation flows, typography, forms, keyboard and safe-area layout, and accessibility checks. Apply Apple Human Interface Guidelines and consult real product references through the optional Uizze connection.

Mobile416.5K installs

vercel-react-native-skills

vercel-labs/agent-skills

React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.

OfficialMobile256.7K installs

animate-expo

emilkowalski/skills

Build animations in React Native and Expo, making the decisions in the order that determines whether they feel right — should it animate, which thread it runs on, which properties, spring or timing, how the gesture hands off, how it degrades. Writes the implementation with Reanimated, Gesture Handler, Expo Router and expo-haptics. Use when animating anything in an Expo app, adding gestures, sheets, screen transitions, press feedback or haptics, or fixing motion that stutters on device. For web animation use animate.

Mobile140.1K installs

xcode-project-setup

firebase/agent-skills

Safely modifies Xcode projects (.pbxproj) to add Swift Packages and link files. Use this skill whenever an iOS project needs dependencies installed (e.g. Firebase, Alamofire).

OfficialMobile131.2K installs

firebase-remote-config-basics

firebase/agent-skills

Manages Firebase Remote Config templates, feature flags, loading strategies, and SDKs (Android, iOS). Use when downloading/deploying remoteconfig JSON templates, managing version history/feature flags, setting in-app defaults, fetchAndActivate(), real-time listeners, or SDK setup. Don't use for Firebase Hosting, Auth, Firestore, Data Connect, Crashlytics, or App Hosting.

OfficialMobile121.7K installs