arkts-crash-diagnosis
Skill1 starsChanged 2 months agoMITView on GitHub
Use when diagnosing and fixing HarmonyOS ArkTS/JS runtime crashes — jscrash, uncaught exception, stack trace, faultlog/faultlogger, hilog collection. Triggers include 闪退/崩溃/白屏, app exits after 点击/启动/launch, build succeeds but runtime fails (no compile error), runtime logs showing TypeError/ReferenceError/RangeError/SyntaxError/BusinessError/OutOfMemoryError/URIError, jscrash 日志解析, error message keywords such as "Cannot read property", "is not callable", "is not initialized", "UI execution context not found", "WebviewController must be associated", "ForEach id", "circular structure", "Stack overflow", hdc faultlog 拉取, hilog 采集. Provides Node parsing scripts and a fault-mode knowledge base for minimal root-cause fixes. Not for compile-time errors (use arkts-debug), build/sign failures (use arkts-build), or native NDK crash tooling (use arkts-ndk-dev).
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- arkts-buildSkill
- arkts-debugSkill
- arkts-helperSkill
- arkts-ndk-devSkill
- arkui-x-devSkill
- atomic-service-devSkill
- create-app-iconSkill
- create-hmos-projectSkill
- harmony-designSkill
- harmony-fetchSkill
- hmos-flowSkill
- lite-simulator-debugSkill
- skill-authorSkill
- understand-hmosSkill
- validate-skillSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Follow this skill's workflow whenever any of the following conditions is met:
- Distinctive: line 23
Do not force this skill onto "编译期报错"(hvigor/ArkCompiler 编译失败)、"构建/签名/部署失败" 或 "C++ native 层崩溃工具链" 场景 — 使用对应 skill(见下表)。
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
arkts-crash-diagnosis
诊断并修复 HarmonyOS ArkTS/JS 运行期崩溃:编译能过、一跑就闪退/白屏/异常退出。核心方法是先拿到具体崩溃锚点(error_type / error_message / suspected_file / top_stack),再做聚焦的代码阅读与最小修复,禁止在拿到锚点前大范围通读工程。本技能内置 Node 解析脚本(faultlogger 探测、faultlog 拉取、jscrash 解析、hilog 采集)与崩溃模式知识库(9 份 patterns 文档)。
本技能的脚本与知识库经用户许可,吸收自本机安装技能 arkts-runtime-fix(知识库上游:hmos-jscrash-analysis);技能目录名有意与该已安装技能不同,避免同名冲突。
When to Use This Skill
Follow this skill's workflow whenever any of the following conditions is met:
- 运行日志出现
TypeError/ReferenceError/RangeError/SyntaxError/BusinessError/OutOfMemoryError/URIError等运行期异常 - 应用闪退、崩溃、白屏,或点击/启动后立即退出
- 用户提供
jscrash日志、堆栈,或以@file方式给出临时日志文件 - 构建成功,但运行行为立刻失败(无编译错误)
- 需要从设备侧拉取 faultlog 或采集 hilog 作为崩溃证据
Do not force this skill onto "编译期报错"(hvigor/ArkCompiler 编译失败)、"构建/签名/部署失败" 或 "C++ native 层崩溃工具链" 场景 — 使用对应 skill(见下表)。
Boundary with Other Skills
This skill covers 「编译通过后的运行期崩溃诊断与修复」, not 「编译错误」, 「构建链路」, or 「NDK native 工具链」:
| Issue Type | Cross-reference Skill | Boundary |
ArkTS 编译期错误(arkts-no-* 规则、类型不匹配) | arkts-debug | 编译期报错转 arkts-debug;本技能处理编译通过后的运行期崩溃 |
| 构建失败 / 签名 / 部署 / CI | arkts-build | hvigorw/ohpm/hdc 构建链路问题转 arkts-build;修复后也用它重建复测 |
| NDK / C++ 侧崩溃(cppcrash、native so、ASan/LLDB) | arkts-ndk-dev | Native 层内存/调试工具与 Node-API 约束转 arkts-ndk-dev;本技能覆盖 JS 层 jscrash |
| 工程结构 / 配置字段 / 启动链路答疑 | understand-hmos | 只想理解文件职责与启动流程(如白屏的路由核对)时转 understand-hmos |
| 知识库未覆盖的新错误模式 / 最新 faultlog 文档 | harmony-fetch | 在线拉取华为官方 faultlog/hilog/错误码文档 |
| 新建工程 / 脚手架 | create-hmos-project | 从零创建工程转 create-hmos-project |
| 仿真器(Simulator)内运行异常 / 虚拟传感器无数据 | lite-simulator-debug | Lite Wearable 应用在 DevEco 仿真器内的运行与调试问题转 lite-simulator-debug;本技能处理真机运行期崩溃(jscrash/faultlog) |
Workflow (Follow Strictly)
1. 先定锚点,禁止盲目探索
拿到以下任意一个具体锚点之前,不要大范围 Read / Glob / 全工程搜索:
- 用户提供的崩溃日志或堆栈
- 用户指明的页面/模块
- 设备侧最近的 faultlog 或 hilog
锚点形态:error_type、error_message、suspected_file、top_stack。用户已给出足够证据时,直接解析该证据,不要过度采集日志。
2. 解析崩溃证据
脚本通过 Shell 运行({SKILL_DIR} 为本技能目录绝对路径;需要 Node.js,不可用时停止并说明,不要假装执行):
node "{SKILL_DIR}/scripts/jscrash-report.mjs" --log-text "{crashLog}" --bundle-name "{bundleName}" --include-text
node "{SKILL_DIR}/scripts/parse-jscrash-log.mjs" --log-file "{logFilePath}" --bundle-name "{bundleName}" --include-textCase A 用户直接给了崩溃文本 → 用 jscrash-report.mjs --log-text。
Case B 用户给了 @file 或本地日志路径 → 用 parse-jscrash-log.mjs --log-file。
Case C 用户只描述了症状 → 按需采集设备侧证据:
- 读
AppScope/app.json5取准确的app.bundleName,作为所有脚本的{bundleName}——禁止从 vendor、模块目录名或com.example前缀猜 - 用
hdc list targets确认设备:恰好一台直接用;多台必须让用户选;无设备则报告无法采集,请用户连接设备或提供本地日志 - 用户复现崩溃后探测 faultlogger:
node "{SKILL_DIR}/scripts/probe-faultlogger.mjs" --bundle-name "{bundleName}" --device-id "{deviceId}" --max-age-minutes "30" --limit "10"status: found→ 拉取并解析最新 faultlog:
node "{SKILL_DIR}/scripts/fetch-faultlog.mjs" --faultlog-name "{latestFaultlog}" --device-id "{deviceId}" --output-dir "{tempDir}"
node "{SKILL_DIR}/scripts/parse-jscrash-log.mjs" --log-file "{localFaultlogPath}" --bundle-name "{bundleName}" --source file --include-textstatus: not_found→ 不要转而大范围读工程或凭症状猜;请用户再次复现后立即重探- faultlogger 不可用或证据仍不足 → 回退 hilog:
node "{SKILL_DIR}/scripts/collect-hilog.mjs" --device-id "{deviceId}" --lines "4000" --output-dir "{tempDir}"
node "{SKILL_DIR}/scripts/parse-jscrash-log.mjs" --log-file "{hilogPath}" --bundle-name "{bundleName}" --source hilog --include-text脚本输出以 key: value 文本块为准:status(detected / no_crash_signature / parse_failed)、source、error_type、error_message、suspected_file、top_stack(| 分隔帧)、keywords、next_action。--include-text 追加人类可读摘要。非零退出码表示该步骤无法继续——报告原因,不要猜测。status: no_crash_signature 时说明证据薄弱,先要更好的日志/复现路径,再进入代码阅读。
3. 匹配崩溃模式
- 先读
references/fault-mode-library.md,用Reason/Error name/Error message匹配JSError→ 次级原因 → 三级原因 - 按
error_type只读对应 patterns 文档:
| error_type | 文档 |
| ReferenceError | references/referenceerror_patterns.md |
| TypeError | references/typeerror_patterns.md |
| Error | references/error_patterns.md |
| BusinessError | references/businesserror_patterns.md |
| SyntaxError | references/syntaxerror_patterns.md |
| RangeError | references/rangeerror_patterns.md |
| OutOfMemoryError | references/outofmemoryerror_patterns.md |
| URIError | references/urierror_patterns.md |
- 多个模式同时命中时,选
Error message+Error code+ 顶部应用栈帧同时支持的那个(各文档内有可信度规则) - 高频模式速查:
| Error type / message 关键词 | 根因 |
ReferenceError + @Provide/@Consume | @Provide/@Consume 缺失或重复 |
ReferenceError + is not initialized | 变量赋值前被使用 |
TypeError + Cannot read property / null or undefined | 在 undefined/null 上取属性 |
TypeError + is not callable | 调用了非函数值 |
TypeError + circular structure | JSON.stringify 循环引用 |
SyntaxError + Unexpected Text in JSON | JSON.parse 输入损坏 |
RangeError + Stack overflow | 无界递归 |
Error + UI execution context not found / 100001 | UI 上下文未绑定到路由 |
Error + WebviewController must be associated / 17100001 | WebviewController 未关联 Web 组件 |
Error + ForEach id | ForEach keyGenerator 缺失或非法 |
BusinessError + Parameter error | API 参数类型/取值非法 |
| OutOfMemoryError + allocate / leak | 堆分配失败或内存泄漏 |
4. 最小修复并复测
- 对
top_stack指向的应用文件做最小修复,不要扩大重构;优先应用帧而非框架噪声;第一个具体.ets/.ts路径是起点不是终点 - 用户给了复现步骤时,复现步骤优先于纯堆栈推断;堆栈指向非入口页时默认交互触发路径,除非证据表明冷启崩溃
- 红线:不许用重试、任意延时或大范围防御式重写代替根因修复;不许凭推理宣称"已修复"——修复后用
arkts-build的 hvigorw 流程重建、hdc 安装运行并复测 - 涉及不熟悉的
@ohos.*/@kit.*API 时,先查其约束再改
5. 引用来源
回复中标注依据的 patterns 文档,例如:
修复依据
references/typeerror_patterns.md「Cannot read property」模式。
Directory Structure
arkts-crash-diagnosis/
├── SKILL.md # This file
├── references/
│ ├── INDEX.md # Must read first
│ ├── fault-mode-library.md # 崩溃模式总库(JSError→次级→三级原因)
│ ├── referenceerror_patterns.md # ReferenceError 模式
│ ├── typeerror_patterns.md # TypeError 模式
│ ├── error_patterns.md # Error/BusinessError 业务错误模式
│ ├── businesserror_patterns.md # BusinessError 参数校验模式
│ ├── syntaxerror_patterns.md # SyntaxError 模式
│ ├── rangeerror_patterns.md # RangeError 模式
│ ├── outofmemoryerror_patterns.md # OutOfMemoryError 模式
│ └── urierror_patterns.md # URIError 模式
└── scripts/
├── jscrash-report.mjs # 崩溃文本 → 结构化报告
├── parse-jscrash-log.mjs # 日志文件/hilog → 结构化报告
├── probe-faultlogger.mjs # 设备侧 faultlogger 探测
├── fetch-faultlog.mjs # 拉取 faultlog 到本地
├── collect-hilog.mjs # 采集 hilog
└── shared/ # hdc 调用与解析公共模块Documentation Source & Maintenance
- 知识库上游:
https://gitcode.com/HarmonyOS_Skills/harmonyos-agent-skills/tree/main/03-solutions/quality/stability/hmos-jscrash-analysis(references/*.md头部均标注;吸收自本机安装技能 arkts-runtime-fix,2026-08-29) - 脚本:Apache-2.0(Huawei Device Co., Ltd.),经 hdc/
DEVECO_HOME解析调用,自包含无外部依赖 - 更新策略:知识库未覆盖的新错误模式,先用
harmony-fetch查官方 faultlog/hilog 文档补充;重大更新可重新同步上游知识库
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

