AI agent skill for secure credential storage & cryptography on Apple platforms - Keychain Services, biometric auth, CryptoKit, and OWASP compliance (iOS 13–26+)
npx skills add https://github.com/ivan-magda/swift-security-skill --skill swift-security-expert使用 CLI 安装这个技能,并在你的工作区中直接复用对应的 SKILL.md 工作流。
Agent skill for Apple platform security work in Swift. It covers Keychain Services, biometric access control, CryptoKit, Secure Enclave, certificate trust, and secure credential storage on iOS and macOS.
The point is simple: AI tools are often shaky on security code, especially around Keychain, biometrics, and cryptography. This repo gives them better defaults, sharper review guidance, and Apple-specific implementation patterns.
The guidance is based on Apple documentation, DTS engineer guidance, WWDC sessions, and OWASP MASTG.
UserDefaults, plists, or legacy storageAI coding assistants routinely generate dangerous Apple security code. This skill exists to catch those patterns and replace them with safer ones.
npx skills add https://github.com/ivan-magda/swift-security-skill --skill swift-security-expert
For more information, visit the skills.sh platform page.
Then use it in your AI agent:
Use the swift security expert skill and review the current security code for authentication bypasses, credential storage issues, and cryptographic correctness.
/plugin marketplace add ivan-magda/swift-security-skill
/plugin install swift-security-expert@swift-security-skill
To automatically provide this skill to everyone working in a repository, configure .claude/settings.json:
{
"enabledPlugins": {
"swift-security-expert@swift-security-skill": true
},
"extraKnownMarketplaces": {
"swift-security-skill": {
"source": {
"source": "github",
"repo": "ivan-magda/swift-security-skill"
}
}
}
}
Upload the swift-security-expert/ folder contents to a Claude Project's knowledge base. Include SKILL.md and all files from references/.
swift-security-expert/ folder following your tool's skill installation docsHow to verify: Your agent should use SKILL.md as the router and load the relevant reference files for the task.
LAContext.evaluatePolicy() used as a standalone auth gateUserDefaults, property lists, or sourceOSStatus failures and weak kSecAttrAccessible choicesSecAccessControlSecItemAdd / SecItemCopyMatching add-or-update flows.biometryCurrentSet, .biometryAny, and .userPresence| # | Domain | Risk | Key APIs |
|---|---|---|---|
| 1 | Keychain Fundamentals | CRITICAL | SecItemAdd, SecItemCopyMatching, SecItemUpdate, SecItemDelete, OSStatus |
| 2 | Keychain Item Classes | HIGH | kSecClassGenericPassword, kSecClassInternetPassword, kSecClassKey, kSecClassCertificate, kSecClassIdentity |
| 3 | Keychain Access Control | CRITICAL | kSecAttrAccessible* (7 levels), SecAccessControlCreateWithFlags, NSFileProtection |
| 4 | Biometric Authentication | CRITICAL | LAContext, evaluatePolicy, SecAccessControlCreateWithFlags, .biometryCurrentSet, .biometryAny |
| 5 | Secure Enclave | HIGH | SecureEnclave.P256.Signing.PrivateKey, SecureEnclave.isAvailable, kSecAttrTokenIDSecureEnclave |
| 6 | CryptoKit — Symmetric | HIGH | SHA256–SHA3_256, HMAC, AES.GCM, ChaChaPoly, SymmetricKey |
| 7 | CryptoKit — Public Key | HIGH | P256, P384, Curve25519, HKDF, HPKE (iOS 17+), MLKEM768, MLDSA65 (iOS 26+) |
| 8 | Credential Storage Patterns | CRITICAL | ASWebAuthenticationSession, keychain token patterns, kSecAttrSynchronizable |
| 9 | Keychain Sharing | MEDIUM | kSecAttrAccessGroup, keychain-access-groups, App Groups entitlement |
| 10 | Certificate Trust | HIGH | SecCertificate, SecTrust, SecTrustEvaluateAsyncWithError, SecIdentity |
| 11 | Migration — Legacy Stores | MEDIUM | UserDefaults.removeObject, FileManager.removeItem, first-launch flag pattern |
| 12 | Common Anti-Patterns | CRITICAL | All anti-pattern APIs with correct/incorrect corrections |
| 13 | Testing Security Code | MEDIUM | XCTest, protocol-based keychain mocks, Swift Testing, CI/CD strategies |
| 14 | Compliance & OWASP Mapping | MEDIUM | OWASP M1, M3, M9, M10; MASVS controls; MASTG test cases |
SKILL.md is a router. It looks at the task — review, improve, or implement — then pulls in the right reference files.
Use it to audit existing code. The skill runs the review checklist, flags findings as pass/fail/warning, and points to the exact reference file and section behind each call.
Use it to fix or modernize existing code. The skill identifies the gap, loads the relevant migration and domain references, then applies the safer pattern.
Use it to build a security feature from scratch. The skill selects the relevant domains and follows the correct patterns from the start.
Contributions are welcome. When adding or editing reference files:
## Summary Checklist at the bottomiOS 13+, iOS 17+, iOS 26+)keychain-fundamentals.mdSee AGENTS.md for full contribution format, testing constraints, and scope boundaries.
MIT