hmos-arkui-scenario-development
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseArkUI Scenario Development
ArkUI 场景开发
Skill Definition
Skill 定义
| Field | Content |
|---|---|
| |
| |
| Covers ArkUI basic syntax, UI framework logic, state management, compilation and runtime. Uses route documents for interaction, focus, navigation, page construction, V1/V2 state management, component synchronization, dialogs, menus, animation, custom components, layouts, images, lists, and text. |
| Native development unrelated to ArkUI, non-HarmonyOS development, and CI/CD configuration. |
| |
| 字段 | 内容 |
|---|---|
| |
| |
| 涵盖 ArkUI 基础语法、UI 框架逻辑、状态管理、编译与运行时。通过路由文档处理交互、焦点、导航、页面构建、V1/V2 状态管理、组件同步、对话框、菜单、动画、自定义组件、布局、图片、列表和文本。 |
| 与 ArkUI 无关的原生开发、非 HarmonyOS 开发,以及 CI/CD 配置。 |
| |
Core Constraints
核心约束
- Handle only ArkUI / ArkTS pages, components, interactions, state, navigation, dialogs, animation, layout, images, lists, text, compilation, and runtime tasks.
.ets - Do not handle unrelated native system capabilities, back-end APIs, databases, CI/CD, release workflows, or non-HarmonyOS development. Classify requests limited to those areas as .
not_in_scope - When or
ARKUI-02is matched, read its route document and complete the secondary routing. If several secondary scenes match, record and read all of them.ARKUI-03 - Before presenting a solution or code, provide the routing result, phase, matched scenes, and resource paths to be read. Do not skip routing and go directly to implementation.
- Base the solution or code on the matched resource documents, including their APIs, component structure, callbacks, lifecycle rules, and verification points. Explicitly state any uncovered boundary.
- 仅处理 ArkUI / ArkTS 页面、组件、交互、状态、导航、对话框、动画、布局、图片、列表、文本、编译和运行时任务。
.ets - 不处理无关的原生系统能力、后端 API、数据库、CI/CD、发布工作流或非 HarmonyOS 开发。将仅限于这些领域的请求归类为 。
not_in_scope - 匹配到 或
ARKUI-02时,读取其路由文档并完成次级路由。如果匹配到多个次级场景,则记录并读取所有场景。ARKUI-03 - 在给出方案或代码之前,先提供路由结果、阶段、匹配场景和待读取的资源路径。不得跳过路由而直接实现。
- 基于匹配的资源文档给出方案或代码,包括其中规定的 API、组件结构、回调、生命周期规则和验证点。明确说明任何未覆盖的边界。
Execution Steps
执行步骤
Every ArkUI request must follow these steps in order. Do not write code before completing them.
每个 ArkUI 请求都必须按顺序执行以下步骤。编写代码前不得跳过这些步骤。
Step 1: Determine the Route
第 1 步:确定路由
Use the decision tree and output:
yaml
active_phases: [REQ / DEV / FIX / VAL]
primary_phase: <primary phase>
primary_scene: <primary scene ID, such as ARKUI-02>
secondary_scenes: [<related scene IDs>]
route_reason: <brief routing reason>
next_scene_refs: [<primary and related resource paths>]Rules:
- Include every entry for
resource_refsinsecondary_scenes.next_scene_refs - Find primary scene resources from the scene index.
- Resolve ,
resource_ref, andresource_refsin secondary ROUTE documents.resource_files
使用决策树并输出:
yaml
active_phases: [REQ / DEV / FIX / VAL]
primary_phase: <primary phase>
primary_scene: <primary scene ID, such as ARKUI-02>
secondary_scenes: [<related scene IDs>]
route_reason: <brief routing reason>
next_scene_refs: [<primary and related resource paths>]规则:
- 将 中的每个
secondary_scenes条目加入resource_refs。next_scene_refs - 从场景索引中查找主要场景资源。
- 解析次级 ROUTE 文档中的 、
resource_ref和resource_refs。resource_files
Step 2: Read All Scene References
第 2 步:读取所有场景参考文档
Use the Read tool to read every file in . Do not replace document-specific guidance with assumptions.
next_scene_refsRead in this order:
- Primary scene reference documents.
- Related scene reference documents.
- Cascaded route documents. If a reference is a ROUTE document, continue through its scene index until all leaf documents have been read.
Do not skip a referenced file, assume a file is empty from its name, or replace a documented API pattern with prior knowledge.
使用 Read 工具读取 中的每个文件。不得用假设替代文档中的专项指导。
next_scene_refs按以下顺序读取:
- 主要场景参考文档。
- 相关场景参考文档。
- 级联路由文档。如果某个引用是 ROUTE 文档,则继续沿其场景索引向下读取,直至读取所有叶子文档。
不得跳过被引用的文件,不得仅根据文件名认定文件为空,也不得用既有知识替代文档规定的 API 模式。
Step 3: Confirm the Route
第 3 步:确认路由
Before implementation, output:
markdown
undefined实现前输出:
markdown
undefinedRoute Confirmation
Route Confirmation
Routing result:
- primary_phase: ...
- primary_scene: ...
- secondary_scenes: [...]
Documents read:
- [file path] - [one-sentence summary]
- [file path] - [one-sentence summary]
Implementation points:
- [API, pattern, or constraint extracted from the documents]
undefinedRouting result:
- primary_phase: ...
- primary_scene: ...
- secondary_scenes: [...]
Documents read:
- [file path] - [one-sentence summary]
- [file path] - [one-sentence summary]
Implementation points:
- [API, pattern, or constraint extracted from the documents]
undefinedStep 4: Implement
第 4 步:实现
Implement according to the constraints, API usage, callbacks, lifecycle rules, and configuration formats in the scene documents.
- Use the documented API patterns; do not replace them with undocumented alternatives.
- When a document provides a complete code example, adapt that example instead of rewriting it from scratch.
- When several examples exist, choose the one that best matches the request.
根据场景文档中的约束、API 用法、回调、生命周期规则和配置格式进行实现。
- 使用文档规定的 API 模式,不得用未记录的替代方案取代。
- 当文档提供完整代码示例时,应基于该示例进行调整,而不是从头重写。
- 当存在多个示例时,选择与请求最匹配的示例。
Phase Labels
阶段标签
| Label | Phase | Focus |
|---|---|---|
| Requirements and design | Scene recognition, interaction design, state-management selection, animation selection, and page-flow design |
| Development | ArkUI implementation, component usage, state management, gesture handling, animation APIs, and route configuration |
| Troubleshooting | Compilation errors, runtime exceptions, failed animations, state desynchronization, navigation failures, and broken interactions |
| Functional validation | UI rendering, interaction events, state management, animation effects, and page-flow validation |
| 标签 | 阶段 | 重点 |
|---|---|---|
| 需求与设计 | 场景识别、交互设计、状态管理方案选择、动画选择和页面流设计 |
| 开发 | ArkUI 实现、组件使用、状态管理、手势处理、动画 API 和路由配置 |
| 故障排查 | 编译错误、运行时异常、动画失败、状态不同步、导航失败和交互异常 |
| 功能验证 | UI 渲染、交互事件、状态管理、动画效果和页面流验证 |
Unified Output Fields
统一输出字段
- :
REQ,device_constraints,capability_boundaryacceptance_focus - :
DEV,code_touchpoints,reuse_resources,implementation_notesintegration_risks - :
FIX,problem_profile,root_cause_hypothesis,fix_planregression_watchlist - :
VAL,verification_matrix,evidence_requirements,pass_criteriaresidual_risks
- :
REQ、device_constraints、capability_boundaryacceptance_focus - :
DEV、code_touchpoints、reuse_resources、implementation_notesintegration_risks - :
FIX、problem_profile、root_cause_hypothesis、fix_planregression_watchlist - :
VAL、verification_matrix、evidence_requirements、pass_criteriaresidual_risks
Field Definitions
字段定义
- : Constraints caused by device type, screen size, system version, or similar environment differences.
device_constraints - : The API versions, device types, and system states where the plan is valid, plus cases requiring fallback or extra handling.
capability_boundary - : UI behavior, interaction behavior, and animation effects that must receive special attention during acceptance.
acceptance_focus - The fields listed for a phase are required after the corresponding scene is matched. Output is determined by the phase, not separately by each scene.
- :由设备类型、屏幕尺寸、系统版本或类似环境差异引起的约束。
device_constraints - :方案适用的 API 版本、设备类型和系统状态,以及需要降级处理或额外处理的情况。
capability_boundary - :验收期间需要重点关注的 UI 行为、交互行为和动画效果。
acceptance_focus - 匹配到相应场景后,必须提供该阶段列出的字段。输出由阶段决定,而不是由每个场景分别决定。
Scenario Decision Tree
场景决策树
Step 1: Determine the Phase
第 1 步:确定阶段
Decide whether the user describes an existing implementation with an incorrect result.
- : An existing implementation produces an error, crash, blank screen, failed animation, desynchronized state, failed navigation, unresponsive gesture, or missing dialog; the user explicitly requests troubleshooting or fixing; or the prompt includes an API/code sample and an abnormal result.
FIX - : The user describes a new feature without an existing abnormal result, using signals such as "implement", "development plan", or "build". A design constraint such as "must not be covered" is not the same as an existing obstruction.
DEV - : The user asks for requirements analysis, evaluation, or solution selection.
REQ
判断用户是否在描述一个结果不正确的现有实现。
- :现有实现出现错误、崩溃、白屏、动画失败、状态不同步、导航失败、手势无响应或对话框缺失;用户明确要求排查或修复;或者提示中包含 API/代码示例和异常结果。
FIX - :用户描述一项没有现有异常结果的新功能,并使用了“实现”“开发计划”或“构建”等信号。诸如“不得涵盖”的设计约束,不等同于现有障碍。
DEV - :用户要求进行需求分析、评估或方案选择。
REQ
Step 2: Match Primary Scenes
第 2 步:匹配主要场景
Match all primary scenes in parallel. Use , each scene's , the user's prompt, code, error, screenshot, and context.
metadata.keywordsintent_signals- Strong signals such as API names, decorators, component names, and error symptoms take priority over generic words.
- Check for every candidate.
applies_when - Check and move excluded candidates to a more suitable scene or to
not_applies_when.secondary_scenes - A scene that matches only but not
intent_signalscannot beapplies_when.primary_scene - is the strongest scene satisfying the signals, applicability, and current phase.
primary_scene - capture dependencies, related behavior, troubleshooting prerequisites, and validation supplements. Multiple applicable scenes may be retained.
secondary_scenes
并行匹配所有主要场景。使用 、每个场景的 、用户提示、代码、错误、截图和上下文。
metadata.keywordsintent_signals- API 名称、装饰器、组件名称和错误症状等强信号优先于通用词语。
- 检查每个候选场景的 。
applies_when - 检查 ,并将不符合条件的候选场景移至更合适的场景或
not_applies_when。secondary_scenes - 仅匹配 而不满足
intent_signals的场景不能成为applies_when。primary_scene - 是同时满足信号、适用性和当前阶段的最强场景。
primary_scene - 用于涵盖依赖关系、关联行为、故障排查前提和验证补充。可以保留多个适用场景。
secondary_scenes
Step 3: Apply Phase Decisions
第 3 步:应用阶段决策
Read the matching scene's , , , or decisions according to :
REQDEVFIXVALprimary_phase- clarifies scope and acceptance priorities.
REQ - determines the implementation path and code skeleton.
DEV - identifies diagnostic checkpoints and regression risks.
FIX - generates the validation matrix and evidence requirements.
VAL - If the decisions do not fully cover the request, keep the matched scene and explicitly state the uncovered boundary.
根据 读取匹配场景的 、、 或 决策:
primary_phaseREQDEVFIXVAL- 明确范围和验收重点。
REQ - 确定实现路径和代码骨架。
DEV - 识别诊断检查点和回归风险。
FIX - 生成验证矩阵和证据要求。
VAL - 如果这些决策无法完全覆盖请求,则保留已匹配场景,并明确说明未覆盖的边界。
Step 4: Resolve Resources
第 4 步:解析资源
Add every primary and secondary entry to . Expand every ROUTE reference through its own decision tree. If no scene matches, classify the request as ; do not skip field-based routing and implement directly.
resource_refsnext_scene_refsnot_in_scope将所有主要和次要 条目加入 。通过每个 ROUTE 引用自身的决策树进行展开。如果没有任何场景匹配,将请求归类为 ;不得跳过基于字段的路由而直接实现。
resource_refsnext_scene_refsnot_in_scopeScene Index
场景索引
ARKUI-01
ArkUI Basic Syntax
ARKUI-01ARKUI-01
ArkUI 基础语法
ARKUI-01yaml
scene_id: ARKUI-01
scene_name: ArkUI Basic Syntax
resource_refs:
- ./references/arkui-basic/ROUTE.md
intent_signals:
- declarative UI / conditional rendering / visibility switching / expand and collapse
- custom components / @Component / @ComponentV2 / @Builder / @LocalBuilder / @BuilderParam
- AttributeModifier / @Reusable / @ReusableV2 / LazyForEach / Repeat / virtualScroll / UI slots / style reuse / component reuse
applies_when:
- The request concerns ArkUI's declarative paradigm, component definitions, build(), decorators, or basic syntax.
- The request concerns if rendering, dynamic visibility, expand/collapse, or login-state switching.
- The request concerns @Builder, @BuilderParam, @LocalBuilder, AttributeModifier, @Reusable, @ReusableV2, LazyForEach, Repeat, reuseId, or reuse.
not_applies_when:
- The core request is page structure, layout, navigation, interaction, dialogs, animation, images, lists, or text (`ARKUI-02`).
- The core request is state transfer, synchronization, observation, or V1/V2 mixing (`ARKUI-03`).
- The core request is a compilation/runtime error, blank screen, crash, or SDK compatibility issue (`ARKUI-04`).yaml
scene_id: ARKUI-01
scene_name: ArkUI Basic Syntax
resource_refs:
- ./references/arkui-basic/ROUTE.md
intent_signals:
- declarative UI / conditional rendering / visibility switching / expand and collapse
- custom components / @Component / @ComponentV2 / @Builder / @LocalBuilder / @BuilderParam
- AttributeModifier / @Reusable / @ReusableV2 / LazyForEach / Repeat / virtualScroll / UI slots / style reuse / component reuse
applies_when:
- The request concerns ArkUI's declarative paradigm, component definitions, build(), decorators, or basic syntax.
- The request concerns if rendering, dynamic visibility, expand/collapse, or login-state switching.
- The request concerns @Builder, @BuilderParam, @LocalBuilder, AttributeModifier, @Reusable, @ReusableV2, LazyForEach, Repeat, reuseId, or reuse.
not_applies_when:
- The core request is page structure, layout, navigation, interaction, dialogs, animation, images, lists, or text (`ARKUI-02`).
- The core request is state transfer, synchronization, observation, or V1/V2 mixing (`ARKUI-03`).
- The core request is a compilation/runtime error, blank screen, crash, or SDK compatibility issue (`ARKUI-04`).ARKUI-02
UI Framework and Page Logic
ARKUI-02ARKUI-02
UI 框架与页面逻辑
ARKUI-02yaml
scene_id: ARKUI-02
scene_name: UI Framework and Page Logic
resource_refs:
- ./references/arkui-02-route.md
intent_signals:
- gestures / keyboard / touch / stylus / focus / focusable / requestFocus / nextFocus / focus box
- navigation / Navigation / Router / page stack / dialogs / menus / Toast / Popup / Sheet / Dialog / animation / transitions / animateTo / TransitionEffect / geometryTransition
- Column / Row / Stack / Flex / RelativeContainer / GridRow / Tabs / List / Grid / WaterFlow / ArcList / Scroll / Swiper / page skeleton / responsive layout / breakpoints / FrameNode / Modifier / RenderNode / BuilderNode / XComponent / Image / ImageAnimator / Text / TextInput / RichEditor / SymbolGlyph
applies_when:
- The request builds pages, flows, interactions, temporary interfaces, or animations using ArkUI components and framework capabilities.
- The request handles navigation, gestures, focus, dialogs, menus, animation transitions, layouts, images, lists, text, custom nodes, or page skeletons.
not_applies_when:
- The request only confirms basic syntax, conditional rendering, Builder, or basic reuse (`ARKUI-01`).
- The main issue is state decorators, state synchronization, or V1/V2 mixing (`ARKUI-03`).
- The main issue is compilation/runtime failure rather than UI logic (`ARKUI-04`).yaml
scene_id: ARKUI-02
scene_name: UI Framework and Page Logic
resource_refs:
- ./references/arkui-02-route.md
intent_signals:
- gestures / keyboard / touch / stylus / focus / focusable / requestFocus / nextFocus / focus box
- navigation / Navigation / Router / page stack / dialogs / menus / Toast / Popup / Sheet / Dialog / animation / transitions / animateTo / TransitionEffect / geometryTransition
- Column / Row / Stack / Flex / RelativeContainer / GridRow / Tabs / List / Grid / WaterFlow / ArcList / Scroll / Swiper / page skeleton / responsive layout / breakpoints / FrameNode / Modifier / RenderNode / BuilderNode / XComponent / Image / ImageAnimator / Text / TextInput / RichEditor / SymbolGlyph
applies_when:
- The request builds pages, flows, interactions, temporary interfaces, or animations using ArkUI components and framework capabilities.
- The request handles navigation, gestures, focus, dialogs, menus, animation transitions, layouts, images, lists, text, custom nodes, or page skeletons.
not_applies_when:
- The request only confirms basic syntax, conditional rendering, Builder, or basic reuse (`ARKUI-01`).
- The main issue is state decorators, state synchronization, or V1/V2 mixing (`ARKUI-03`).
- The main issue is compilation/runtime failure rather than UI logic (`ARKUI-04`).ARKUI-03
State Management
ARKUI-03ARKUI-03
状态管理
ARKUI-03yaml
scene_id: ARKUI-03
scene_name: State Management
resource_refs:
- ./references/arkui-03-route.md
intent_signals:
- @State / @Prop / @Link / @Provide / @Consume / @Watch / @Track / @ObjectLink / @Observe
- @Local / @Param / @Event / @Monitor / @Provider / @Consumer / @Computed / @ObservedV2 / @Trace
- AppStorage / AppStorageV2 / state management / component synchronization / application state / V1/V2 mixing
applies_when:
- The request passes or shares state between components.
- The request uses V1 or V2 state management, state observation, computed state, two-way binding, state-driven animation, component reuse, freezing, or loop rendering.
- The request explicitly concerns V1/V2 mixing or using V2 components with V1 components, or vice versa.
not_applies_when:
- The request is only layout, navigation, interaction, dialogs, animation, focus, images, lists, or text (`ARKUI-02`).
- The request is only basic syntax, Builder, conditional rendering, or basic reuse (`ARKUI-01`).
- The issue is a compilation/runtime failure whose root cause is not yet tied to state management; start with `ARKUI-04`.yaml
scene_id: ARKUI-03
scene_name: State Management
resource_refs:
- ./references/arkui-03-route.md
intent_signals:
- @State / @Prop / @Link / @Provide / @Consume / @Watch / @Track / @ObjectLink / @Observe
- @Local / @Param / @Event / @Monitor / @Provider / @Consumer / @Computed / @ObservedV2 / @Trace
- AppStorage / AppStorageV2 / state management / component synchronization / application state / V1/V2 mixing
applies_when:
- The request passes or shares state between components.
- The request uses V1 or V2 state management, state observation, computed state, two-way binding, state-driven animation, component reuse, freezing, or loop rendering.
- The request explicitly concerns V1/V2 mixing or using V2 components with V1 components, or vice versa.
not_applies_when:
- The request is only layout, navigation, interaction, dialogs, animation, focus, images, lists, or text (`ARKUI-02`).
- The request is only basic syntax, Builder, conditional rendering, or basic reuse (`ARKUI-01`).
- The issue is a compilation/runtime failure whose root cause is not yet tied to state management; start with `ARKUI-04`.ARKUI-04
Compilation and Runtime
ARKUI-04ARKUI-04
编译与运行时
ARKUI-04yaml
scene_id: ARKUI-04
scene_name: Compilation and Runtime
resource_refs:
- ./references/compilation-runtime-scenario-development.md
intent_signals:
- compilation error / build failure / ArkTS type error / import / export / module path
- runtime exception / blank screen / crash / abnormal lifecycle / resource-load failure
- hvigor / oh-package.json5 / module.json5 / SDK compatibility / API compatibility
applies_when:
- The request troubleshoots ArkTS compilation, build, dependency, module, or SDK/API compatibility problems.
- The request troubleshoots runtime exceptions, blank screens, crashes, lifecycle issues, or resource loading failures.
- The request checks whether an ArkUI pattern is constrained by language, compilation, runtime, or version rules.
not_applies_when:
- The issue is explicitly a UI page, interaction, navigation, dialog, animation, focus, layout, image, list, or text implementation issue (`ARKUI-02`).
- The issue is explicitly a state decorator, state synchronization, or V1/V2 mixing issue (`ARKUI-03`).
- The request only asks about basic ArkUI syntax or reuse (`ARKUI-01`).yaml
scene_id: ARKUI-04
scene_name: Compilation and Runtime
resource_refs:
- ./references/compilation-runtime-scenario-development.md
intent_signals:
- compilation error / build failure / ArkTS type error / import / export / module path
- runtime exception / blank screen / crash / abnormal lifecycle / resource-load failure
- hvigor / oh-package.json5 / module.json5 / SDK compatibility / API compatibility
applies_when:
- The request troubleshoots ArkTS compilation, build, dependency, module, or SDK/API compatibility problems.
- The request troubleshoots runtime exceptions, blank screens, crashes, lifecycle issues, or resource loading failures.
- The request checks whether an ArkUI pattern is constrained by language, compilation, runtime, or version rules.
not_applies_when:
- The issue is explicitly a UI page, interaction, navigation, dialog, animation, focus, layout, image, list, or text implementation issue (`ARKUI-02`).
- The issue is explicitly a state decorator, state synchronization, or V1/V2 mixing issue (`ARKUI-03`).
- The request only asks about basic ArkUI syntax or reuse (`ARKUI-01`).Additional Guidance
补充指导
- For detailed implementation decisions, continue into the matched scene's section and reference documents.
decisions - Do not mix V1 and V2 decorators in the same component without an explicit requirement and documented bridge strategy.
- When a root cause crosses scene boundaries, retain the original scene and add the related scene to .
secondary_scenes - Always report unresolved API/version boundaries instead of inventing unsupported code.
- 如需详细的实现决策,继续查看匹配场景的 部分及相关参考文档。
decisions - 除非有明确要求和有文档记录的桥接策略,否则不要在同一个组件中混用 V1 和 V2 装饰器。
- 当根因跨越场景边界时,保留原场景,并将相关场景加入 。
secondary_scenes - 始终报告尚未解决的 API/版本边界,不要杜撰不受支持的代码。