$npx -y skills add rshankras/claude-code-apple-skills --skill debug-menuGenerates a developer debug menu with feature flag toggles, environment switching, network log viewer, cache clearing, crash trigger, and diagnostic info export. Only included in DEBUG builds. Use when user wants a debug panel, dev tools menu, or shake-to-debug functionality.
| 1 | # Debug Menu Generator |
| 2 | |
| 3 | Generate a comprehensive developer debug menu accessible via shake gesture or hidden tap. Includes feature flag toggles, environment switching, network log viewer, cache clearing, crash trigger, and diagnostic info export. All code is wrapped in `#if DEBUG` so it never ships to production. |
| 4 | |
| 5 | ## When This Skill Activates |
| 6 | |
| 7 | Use this skill when the user: |
| 8 | - Asks for a "debug menu" or "developer menu" |
| 9 | - Wants "dev tools" or a "debug panel" |
| 10 | - Mentions "shake to debug" or "diagnostic menu" |
| 11 | - Wants to "toggle feature flags" from the app |
| 12 | - Asks about "environment switching" (dev/staging/production) |
| 13 | - Wants a "network log viewer" in the app |
| 14 | |
| 15 | ## Pre-Generation Checks |
| 16 | |
| 17 | ### 1. Project Context Detection |
| 18 | - [ ] Check deployment target (iOS 17+ / macOS 14+ required for @Observable) |
| 19 | - [ ] Check Swift version (requires Swift 5.9+) |
| 20 | - [ ] Identify source file locations and project structure |
| 21 | |
| 22 | ### 2. Conflict Detection |
| 23 | Search for existing debug/dev menu code: |
| 24 | ``` |
| 25 | Glob: **/*Debug*Menu*.swift, **/*DevMenu*.swift, **/*DevTools*.swift, **/*DebugPanel*.swift |
| 26 | Grep: "DebugMenu" or "DevMenu" or "motionEnded" or "shake" in *.swift |
| 27 | ``` |
| 28 | |
| 29 | If existing debug menu found: |
| 30 | - Ask if user wants to replace or extend it |
| 31 | - If extending, integrate new sections into existing structure |
| 32 | |
| 33 | ### 3. Feature Flags Detection |
| 34 | Search for existing feature flag setup: |
| 35 | ``` |
| 36 | Glob: **/*FeatureFlag*.swift, **/*Feature*Toggle*.swift |
| 37 | Grep: "FeatureFlag" or "featureFlag" or "isFeatureEnabled" |
| 38 | ``` |
| 39 | |
| 40 | If found, integrate debug menu toggles with existing feature flag system rather than creating a new one. |
| 41 | |
| 42 | ## Configuration Questions |
| 43 | |
| 44 | Ask user via AskUserQuestion: |
| 45 | |
| 46 | 1. **Access method?** |
| 47 | - Shake gesture (shake device to open) |
| 48 | - Hidden tap (5-tap on a hidden area) |
| 49 | - Both (shake + hidden tap) -- recommended |
| 50 | |
| 51 | 2. **Sections to include?** (multi-select) |
| 52 | - Feature flags (toggle flags on/off at runtime) |
| 53 | - Environment switcher (dev / staging / production) |
| 54 | - Network logs (recent requests with status codes and timing) |
| 55 | - Cache tools (clear image cache, HTTP cache, all caches) |
| 56 | - Crash trigger (force crash for Crashlytics testing) |
| 57 | - Diagnostics (device info, memory, disk, app version) |
| 58 | |
| 59 | 3. **Include push notification testing?** |
| 60 | - Yes (simulate local push notifications for testing) |
| 61 | - No |
| 62 | |
| 63 | 4. **Include export diagnostics?** |
| 64 | - Yes (share sheet with full diagnostic report) |
| 65 | - No |
| 66 | |
| 67 | ## Generation Process |
| 68 | |
| 69 | ### Step 1: Read Templates |
| 70 | Read `templates.md` for production Swift code wrapped in `#if DEBUG`. |
| 71 | |
| 72 | ### Step 2: Create Core Files |
| 73 | Generate these files (all wrapped in `#if DEBUG`): |
| 74 | 1. `DebugMenuView.swift` -- Main NavigationStack with all sections |
| 75 | 2. `DebugSection.swift` -- Enum defining available debug sections |
| 76 | |
| 77 | ### Step 3: Create Section Files |
| 78 | Based on configuration: |
| 79 | 3. `DebugEnvironmentSwitcher.swift` -- If environment switcher selected |
| 80 | 4. `DebugNetworkLogger.swift` -- If network logs selected |
| 81 | 5. `DiagnosticInfo.swift` -- If diagnostics or export selected |
| 82 | |
| 83 | ### Step 4: Create Trigger Files |
| 84 | 6. `DebugMenuTrigger.swift` -- ShakeDetector + hidden tap gesture + ViewModifier |
| 85 | |
| 86 | ### Step 5: Create Action Files |
| 87 | 7. `DebugActions.swift` -- Collection of debug utility actions |
| 88 | |
| 89 | ### Step 6: Determine File Location |
| 90 | Check project structure: |
| 91 | - If `Sources/` exists -> `Sources/DebugMenu/` |
| 92 | - If `App/` exists -> `App/DebugMenu/` |
| 93 | - Otherwise -> `DebugMenu/` |
| 94 | |
| 95 | Entire folder is `#if DEBUG` and should be excluded from release builds. |
| 96 | |
| 97 | ## Output Format |
| 98 | |
| 99 | After generation, provide: |
| 100 | |
| 101 | ### Files Created |
| 102 | ``` |
| 103 | DebugMenu/ |
| 104 | ├── DebugMenuView.swift # Main NavigationStack with all sections |
| 105 | ├── DebugSection.swift # Enum of available sections |
| 106 | ├── DebugEnvironmentSwitcher.swift # Environment switching (optional) |
| 107 | ├── DebugNetworkLogger.swift # Network request logger (optional) |
| 108 | ├── DiagnosticInfo.swift # Device and app diagnostics (optional) |
| 109 | ├── DebugMenuTrigger.swift # Shake gesture + hidden tap trigger |
| 110 | └── DebugActions.swift # Utility actions (reset, clear, crash) |
| 111 | ``` |
| 112 | |
| 113 | ### Integration Steps |
| 114 | |
| 115 | **Add the debug trigger to your root view:** |
| 116 | ```swift |
| 117 | #if DEBUG |
| 118 | import SwiftUI |
| 119 | |
| 120 | @main |
| 121 | struct MyApp: App { |
| 122 | var body: some Scene { |
| 123 | WindowGroup { |
| 124 | ContentView() |
| 125 | .debugMenuTrigger() // Adds shake + tap to open debug menu |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | #endif |
| 130 | ``` |
| 131 | |
| 132 | **Or add only to specific views:** |
| 133 | ```swift |
| 134 | struct SettingsView: View { |
| 135 | var body: some View { |
| 136 | Form { |
| 137 | // ... your settings |
| 138 | } |
| 139 | #if DEBUG |
| 140 | .debugMenuTrigger(me |