一键导入
memory-leak-diagnosis
Use when investigating memory growth, retain cycles, leaks in Instruments, Task cancellation issues, or ARC problems in Swift 6 apps.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when investigating memory growth, retain cycles, leaks in Instruments, Task cancellation issues, or ARC problems in Swift 6 apps.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when building or reviewing Nuxt 4 apps, app/ directory layout, pages, layouts, server routes, composables, layers, or Nuxt data fetching.
Use when styling Nuxt or Vue UI, migrating from Tailwind 3, configuring @tailwindcss/vite, writing utility classes, or tempted to add custom CSS or inline styles.
Use when writing or reviewing TypeScript in Vue, Nuxt, Node, or shared TS utilities, fixing type errors, or deciding how to type API responses and composables.
Use when writing Vue 3 components or composables, choosing Options vs Composition API, handling reactivity, provide/inject, or script setup patterns.
Use when setting up or running ESLint, Prettier, Vitest, or Playwright for Nuxt/Vue projects, deciding what to test, or enforcing pre-deploy quality gates.
Use when implementing or auditing VoiceOver, Dynamic Type, accessibility labels, focus, contrast, or Hit-testing for SwiftUI iOS/macOS apps.
| name | memory-leak-diagnosis |
| description | Use when investigating memory growth, retain cycles, leaks in Instruments, Task cancellation issues, or ARC problems in Swift 6 apps. |
Find and fix leaks and retain cycles using modern concurrency patterns.
| ALWAYS | NEVER |
|---|---|
Cancel long-lived Tasks | Infinite Task loops without cancellation |
| Prefer structured async over stored escaping closures | Strong self in stored closures without reason |
| Profile with Instruments / Memory Graph | “Optimize” without evidence of a leak |
Prefer @Observable + async over Combine sinks | Ignore purple leak markers in Memory Graph |
weak / remove stored closures / use asyncTask, cancel in deinit / .onDisappear / .task lifecycleactor@Observable
final class SafeViewModel {
private var workTask: Task<Void, Never>?
func start() {
workTask?.cancel()
workTask = Task {
while !Task.isCancelled {
await doWork()
try? await Task.sleep(for: .seconds(1))
}
}
}
func stop() {
workTask?.cancel()
workTask = nil
}
deinit { workTask?.cancel() }
}
// Prefer .task for automatic cancellation with view lifetime
.task {
await viewModel.load()
}
| Pattern | Fix |
|---|---|
Uncancelled Task | Cancel + check Task.isCancelled |
| Stored closure capturing self | weak self or async API |
| NotificationCenter observer | AsyncSequence notifications + cancel |
| Timer | invalidate / use async loop with cancel |