返回顶部
h

healthkit-code-reviewHealthKit代码审查

Reviews HealthKit code for authorization patterns, query usage, background delivery, and data type handling. Use when reviewing code with import HealthKit, HKHealthStore, HKSampleQuery, HKObserverQuery, or HKQuantityType.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.2.0
安全检测
已通过
130
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

healthkit-code-review

HealthKit 代码审查

快速参考

问题类型参考文档
HKHealthStore、权限、状态检查、隐私references/authorization.md
HKQuery 类型、谓词、锚定查询、统计
references/queries.md | | 后台投递、观察者查询、完成处理器 | references/background.md | | HKQuantityType、HKCategoryType、锻炼、单位 | references/data-types.md |

审查清单

  • - [ ] 在任何 HealthKit 操作前调用 HKHealthStore.isHealthDataAvailable()
  • [ ] 仅针对所需数据类型请求授权(最小权限原则)
  • [ ] 不将 requestAuthorization 完成处理器误解为已授予权限
  • [ ] 不尝试确定读取权限状态(隐私设计原则)
  • [ ] 查询结果分发到主线程进行 UI 更新
  • [ ] 仅在有限谓词下使用 HKObjectQueryNoLimit
  • [ ] 使用 HKStatisticsQuery 进行聚合,而非手动求和
  • [ ] 观察者查询的 completionHandler() 始终被调用(使用 defer)
  • [ ] 在 application(_:didFinishLaunchingWithOptions:) 中注册后台投递
  • [ ] 添加后台投递授权(iOS 15+)
  • [ ] 为数量类型使用正确的单位(例如心率使用 count/min)
  • [ ] 长时间运行的查询作为属性存储,并在 deinit 中停止

何时加载参考文档

  • - 审查授权/权限流程 -> authorization.md
  • 审查 HKSampleQuery、HKAnchoredObjectQuery 或谓词 -> queries.md
  • 审查 HKObserverQuery 或 enableBackgroundDelivery -> background.md
  • 审查 HKQuantityType、HKCategoryType 或 HKWorkout -> data-types.md

审查问题

  1. 1. 创建 HKHealthStore 前是否检查了 isHealthDataAvailable()?
  2. 代码是否优雅处理了被拒绝的权限(空结果)?
  3. 观察者查询的完成处理器是否在所有代码路径中被调用?
  4. 后台处理器中的工作是否最小化(约15秒限制)?
  5. HKQueryAnchors 是否按样本类型持久化(而非共享)?

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 healthkit-code-review-1776111543 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 healthkit-code-review-1776111543 技能

通过命令行安装

skillhub install healthkit-code-review-1776111543

下载

⬇ 下载 healthkit-code-review v1.2.0(免费)

文件大小: 10.34 KB | 发布时间: 2026-4-14 10:05

v1.2.0 最新 2026-4-14 10:05
- Added a structured quick reference table for HealthKit authorization, query patterns, background delivery, and data type usage.
- Introduced a detailed review checklist covering key HealthKit best practices and common pitfalls.
- Provided clear guidance on when to consult specific documentation references.
- Included targeted review questions to help ensure correct and privacy-compliant HealthKit code.

Archiver·手机版·闲社网·闲社论坛·智能体自动化市场· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2026 闲社网·AI智能体论坛·AI自动化解决方案·http://xianshe.com

p2p_official_large
返回顶部