[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-c9820abd-2706-47da-8e88-ea7e23a757ff":3,"$f-WYpna57hTPG2y-aZdhRy-ST2l6PXbBFX1zzPg1WEpY":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"c9820abd-2706-47da-8e88-ea7e23a757ff","swiftui-performance-audit","从代码审查和性能分析证据中审计SwiftUI的性能问题。","cat_coding_frontend","mod_coding","sickn33,coding","---\nname: swiftui-performance-audit\ndescription: Audit SwiftUI performance issues from code review and profiling evidence.\nrisk: safe\nsource: \"Dimillian\u002FSkills (MIT)\"\ndate_added: \"2026-03-25\"\n---\n\n# SwiftUI Performance Audit\n\n## Quick start\n\nUse this skill to diagnose SwiftUI performance issues from code first, then request profiling evidence when code review alone cannot explain the symptoms.\n\n## When to Use\n- When the user reports slow rendering, janky scrolling, layout thrash, or high CPU in SwiftUI.\n- When you need a code-first audit plus Instruments guidance if profiling evidence is required.\n\n## Workflow\n\n1. Classify the symptom: slow rendering, janky scrolling, high CPU, memory growth, hangs, or excessive view updates.\n2. If code is available, start with a code-first review using `references\u002Fcode-smells.md`.\n3. If code is not available, ask for the smallest useful slice: target view, data flow, reproduction steps, and deployment target.\n4. If code review is inconclusive or runtime evidence is required, guide the user through profiling with `references\u002Fprofiling-intake.md`.\n5. Summarize likely causes, evidence, remediation, and validation steps using `references\u002Freport-template.md`.\n\n## 1. Intake\n\nCollect:\n- Target view or feature code.\n- Symptoms and exact reproduction steps.\n- Data flow: `@State`, `@Binding`, environment dependencies, and observable models.\n- Whether the issue shows up on device or simulator, and whether it was observed in Debug or Release.\n\nAsk the user to classify the issue if possible:\n- CPU spike or battery drain\n- Janky scrolling or dropped frames\n- High memory or image pressure\n- Hangs or unresponsive interactions\n- Excessive or unexpectedly broad view updates\n\nFor the full profiling intake checklist, read `references\u002Fprofiling-intake.md`.\n\n## 2. Code-First Review\n\nFocus on:\n- Invalidation storms from broad observation or environment reads.\n- Unstable identity in lists and `ForEach`.\n- Heavy derived work in `body` or view builders.\n- Layout thrash from complex hierarchies, `GeometryReader`, or preference chains.\n- Large image decode or resize work on the main thread.\n- Animation or transition work applied too broadly.\n\nUse `references\u002Fcode-smells.md` for the detailed smell catalog and fix guidance.\n\nProvide:\n- Likely root causes with code references.\n- Suggested fixes and refactors.\n- If needed, a minimal repro or instrumentation suggestion.\n\n## 3. Guide the User to Profile\n\nIf code review does not explain the issue, ask for runtime evidence:\n- A trace export or screenshots of the SwiftUI timeline and Time Profiler call tree.\n- Device\u002FOS\u002Fbuild configuration.\n- The exact interaction being profiled.\n- Before\u002Fafter metrics if the user is comparing a change.\n\nUse `references\u002Fprofiling-intake.md` for the exact checklist and collection steps.\n\n## 4. Analyze and Diagnose\n\n- Map the evidence to the most likely category: invalidation, identity churn, layout thrash, main-thread work, image cost, or animation cost.\n- Prioritize problems by impact, not by how easy they are to explain.\n- Distinguish code-level suspicion from trace-backed evidence.\n- Call out when profiling is still insufficient and what additional evidence would reduce uncertainty.\n\n## 5. Remediate\n\nApply targeted fixes:\n- Narrow state scope and reduce broad observation fan-out.\n- Stabilize identities for `ForEach` and lists.\n- Move heavy work out of `body` into derived state updated from inputs, model-layer precomputation, memoized helpers, or background preprocessing. Use `@State` only for view-owned state, not as an ad hoc cache for arbitrary computation.\n- Use `equatable()` only when equality is cheaper than recomputing the subtree and the inputs are truly value-semantic.\n- Downsample images before rendering.\n- Reduce layout complexity or use fixed sizing where possible.\n\nUse `references\u002Fcode-smells.md` for examples, Observation-specific fan-out guidance, and remediation patterns.\n\n## 6. Verify\n\nAsk the user to re-run the same capture and compare with baseline metrics.\nSummarize the delta (CPU, frame drops, memory peak) if provided.\n\n## Outputs\n\nProvide:\n- A short metrics table (before\u002Fafter if available).\n- Top issues (ordered by impact).\n- Proposed fixes with estimated effort.\n\nUse `references\u002Freport-template.md` when formatting the final audit.\n\n## References\n\n- Profiling intake and collection checklist: `references\u002Fprofiling-intake.md`\n- Common code smells and remediation patterns: `references\u002Fcode-smells.md`\n- Audit output template: `references\u002Freport-template.md`\n- Add Apple documentation and WWDC resources under `references\u002F` as they are supplied by the user.\n- Optimizing SwiftUI performance with Instruments: `references\u002Foptimizing-swiftui-performance-instruments.md`\n- Understanding and improving SwiftUI performance: `references\u002Funderstanding-improving-swiftui-performance.md`\n- Understanding hangs in your app: `references\u002Funderstanding-hangs-in-your-app.md`\n- Demystify SwiftUI performance (WWDC23): `references\u002Fdemystify-swiftui-performance-wwdc23.md`\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,242,1865,"2026-05-16 13:42:45",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"前端开发","frontend","mdi-language-html5","HTML\u002FCSS\u002FJavaScript\u002F框架相关",1,96,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"edc8230b-1d04-45c9-9c8f-f6f47494ea93","1.0.0","swiftui-performance-audit.zip",10473,"uploads\u002Fskills\u002Fc9820abd-2706-47da-8e88-ea7e23a757ff\u002Fswiftui-performance-audit.zip","ced2e9f9a1f20b9ae3ce5198f67ac7b0eadfd6094be48732331a12ff19e16040","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":5359},{\"path\":\"agents\u002Fopenai.yaml\",\"isDirectory\":false,\"size\":242},{\"path\":\"references\u002Fcode-smells.md\",\"isDirectory\":false,\"size\":3753},{\"path\":\"references\u002Fdemystify-swiftui-performance-wwdc23.md\",\"isDirectory\":false,\"size\":1813},{\"path\":\"references\u002Foptimizing-swiftui-performance-instruments.md\",\"isDirectory\":false,\"size\":1837},{\"path\":\"references\u002Fprofiling-intake.md\",\"isDirectory\":false,\"size\":1904},{\"path\":\"references\u002Freport-template.md\",\"isDirectory\":false,\"size\":1201},{\"path\":\"references\u002Funderstanding-hangs-in-your-app.md\",\"isDirectory\":false,\"size\":1267},{\"path\":\"references\u002Funderstanding-improving-swiftui-performance.md\",\"isDirectory\":false,\"size\":2262}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]