$npx -y skills add rshankras/claude-code-apple-skills --skill account-deletionGenerates an Apple-compliant account deletion flow with multi-step confirmation UI, optional data export, configurable grace period, Keychain cleanup, and server-side deletion request. Use when user needs account deletion, right-to-delete, or Apple App Review compliance for accou
| 1 | # Account Deletion Generator |
| 2 | |
| 3 | Generate a production account deletion flow compliant with Apple's App Store requirement (effective June 30, 2022) that any app offering account creation must also offer account deletion from within the app. Includes multi-step confirmation UI, optional data export, configurable grace period, Keychain cleanup, and Sign in with Apple token revocation. |
| 4 | |
| 5 | ## When This Skill Activates |
| 6 | |
| 7 | Use this skill when the user: |
| 8 | - Asks to "add account deletion" or "delete account" |
| 9 | - Wants to "remove account" or implement "account removal" |
| 10 | - Mentions "right to delete" or "user data deletion" |
| 11 | - Asks about "Apple account deletion requirement" |
| 12 | - Needs App Store compliance for account management |
| 13 | - Wants to implement GDPR/privacy right-to-erasure |
| 14 | |
| 15 | ## Pre-Generation Checks |
| 16 | |
| 17 | ### 1. Project Context Detection |
| 18 | - [ ] Check Swift version (requires Swift 5.9+) |
| 19 | - [ ] Check deployment target (iOS 16+ / macOS 13+) |
| 20 | - [ ] Check for @Observable support (iOS 17+ / macOS 14+) |
| 21 | - [ ] Identify source file locations |
| 22 | |
| 23 | ### 2. Existing Auth/Account Code |
| 24 | Search for existing account management: |
| 25 | ``` |
| 26 | Glob: **/*Auth*.swift, **/*Account*.swift, **/*User*.swift, **/*Profile*.swift |
| 27 | Grep: "ASAuthorizationAppleIDProvider" or "SignInWithApple" or "Keychain" or "deleteAccount" |
| 28 | ``` |
| 29 | |
| 30 | If existing deletion flow found: |
| 31 | - Ask if user wants to replace or enhance it |
| 32 | - If enhancing, integrate with existing auth architecture |
| 33 | |
| 34 | ### 3. Keychain Usage Detection |
| 35 | ``` |
| 36 | Grep: "SecItemAdd" or "SecItemDelete" or "SecItemCopyMatching" or "KeychainWrapper" or "keychain" |
| 37 | ``` |
| 38 | |
| 39 | If Keychain usage found, ensure cleanup covers all stored items. |
| 40 | |
| 41 | ### 4. CloudKit / Server Sync Detection |
| 42 | ``` |
| 43 | Grep: "CKContainer" or "CloudKit" or "CKRecord" or "NSPersistentCloudKitContainer" |
| 44 | Glob: **/*CloudKit*.swift, **/*Sync*.swift |
| 45 | ``` |
| 46 | |
| 47 | If CloudKit or server sync found, include remote data cleanup steps. |
| 48 | |
| 49 | ## Configuration Questions |
| 50 | |
| 51 | Ask user via AskUserQuestion: |
| 52 | |
| 53 | 1. **Deletion type?** |
| 54 | - Immediate — account deleted right away after confirmation |
| 55 | - Grace period — account scheduled for deletion, user can cancel |
| 56 | |
| 57 | 2. **Grace period duration?** (if grace period selected) |
| 58 | - 7 days |
| 59 | - 14 days — recommended |
| 60 | - 30 days |
| 61 | |
| 62 | 3. **Include data export before deletion?** |
| 63 | - Yes — generate DataExportService with JSON/ZIP archive and ShareLink |
| 64 | - No — skip data export |
| 65 | |
| 66 | 4. **Server-side API call needed?** |
| 67 | - Yes — generate server deletion request with configurable endpoint |
| 68 | - No — local-only deletion (Keychain, UserDefaults, SwiftData/CoreData, files) |
| 69 | |
| 70 | ## Generation Process |
| 71 | |
| 72 | ### Step 1: Read Templates |
| 73 | Read `templates.md` for production Swift code. |
| 74 | |
| 75 | ### Step 2: Create Core Files |
| 76 | Generate these files: |
| 77 | 1. `AccountDeletionManager.swift` — @Observable orchestrator for the full deletion lifecycle |
| 78 | 2. `DeletionConfirmationView.swift` — Multi-step confirmation UI with NavigationStack |
| 79 | 3. `KeychainCleanup.swift` — Utility to remove all app Keychain items |
| 80 | |
| 81 | ### Step 3: Create Optional Files |
| 82 | Based on configuration: |
| 83 | - `DataExportService.swift` — If data export selected |
| 84 | - `DeletionGracePeriodView.swift` — If grace period selected |
| 85 | - `SignInWithAppleRevocation.swift` — If SIWA detected in project |
| 86 | |
| 87 | ### Step 4: Determine File Location |
| 88 | Check project structure: |
| 89 | - If `Sources/` exists -> `Sources/AccountDeletion/` |
| 90 | - If `App/` exists -> `App/AccountDeletion/` |
| 91 | - Otherwise -> `AccountDeletion/` |
| 92 | |
| 93 | ## Output Format |
| 94 | |
| 95 | After generation, provide: |
| 96 | |
| 97 | ### Files Created |
| 98 | ``` |
| 99 | AccountDeletion/ |
| 100 | ├── AccountDeletionManager.swift # Orchestrator for deletion lifecycle |
| 101 | ├── DeletionConfirmationView.swift # Multi-step confirmation UI |
| 102 | ├── KeychainCleanup.swift # Keychain item cleanup |
| 103 | ├── DataExportService.swift # Data export before deletion (optional) |
| 104 | ├── DeletionGracePeriodView.swift # Grace period countdown UI (optional) |
| 105 | └── SignInWithAppleRevocation.swift # SIWA token revocation (optional) |
| 106 | ``` |
| 107 | |
| 108 | ### Integration Steps |
| 109 | |
| 110 | **Add to Settings or Account screen:** |
| 111 | ```swift |
| 112 | // In your Settings or Account view |
| 113 | struct AccountSettingsView: View { |
| 114 | @State private var showDeletionFlow = false |
| 115 | |
| 116 | var body: some View { |
| 117 | Form { |
| 118 | // ... other settings ... |
| 119 | |
| 120 | Section { |
| 121 | Button(role: .destructive) { |
| 122 | showDeletionFlow = true |
| 123 | } label: { |
| 124 | Label("Delete Account", systemImage: "person.crop.circle.badge.minus") |
| 125 | } |
| 126 | } footer: { |
| 127 | Text("Permanently removes your account and all associated data.") |
| 128 | } |