ark-layer

Enforce ArkTS layering, lifecycle, and dependency rules for OpenHarmony apps.

31|6|Updated Jan 29, 2026
One-click install
npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill ark-layer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ark-layer
Source: https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/openharmony-arkts-layer
Command: npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill ark-layer

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you follow a strict ArkTS architecture for OpenHarmony apps by preventing broken layering, incorrect Service lifecycle usage, and invalid ArkTS syntax that can lead to unstable behavior and hard-to-debug integration issues.

Core Features & Use Cases

  • Architecture规范校验: Check that Services inherit the required base class, declare dependencies via the constructor, and respect the infra/domain/pages separation rules.
  • Service生命周期指导与落地: Enforce init/load/unload responsibilities (e.g., no network I/O in init) to ensure predictable startup and login/logout flows.
  • 多阶段加载(Phase)编排: Map services to GLOBAL/BUSINESS/FEATURE/LAZY phases to control ordering and parallelism, including cross-phase dependency handling.
  • ArkTS语法限制修复建议: Detect prohibited syntax patterns (e.g., object/array spread, destructuring, throw) and propose compatible alternatives.
  • 模板与快速开始: Generate Service scaffolds and provide a minimal runnable example for wiring pages via ServiceManager.

Quick Start

Tell me how to create a UserProfileService that follows the ark-layer three-layer rule, declares its StorageService dependency through the constructor, assigns the correct Phase for login-time loading, and ensures ArkTS syntax stays within the allowed subset.

Frequently Asked Questions about ark-layer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce Service lifecycle boundaries in OpenHarmony ArkTS apps?

To enforce Service lifecycle boundaries, ensure your ArkTS Services follow strict init/load/unload rules, such as prohibiting network I/O in the init phase, guaranteeing predictable startup and login/logout flows.

What is the correct infra/domain/pages layering direction for ArkTS Service architecture?

Correct ArkTS Service architecture mandates a strict infra/domain/pages separation direction, requiring dependencies to be declared via the constructor to maintain compliant layering boundaries.

How do I configure multi-phase loading for ArkTS Services across GLOBAL, BUSINESS, and FEATURE phases?

Configuring multi-phase loading involves mapping Services to GLOBAL, BUSINESS, FEATURE, or LAZY phases to control execution ordering and parallelism, while correctly handling cross-phase dependencies.

Which ArkTS syntax patterns are prohibited and how do I find compatible alternatives?

Prohibited ArkTS syntax patterns include object spreading, array spreading, destructuring, and throw statements. You must replace these with compatible alternatives to avoid unstable behavior and hard-to-debug integration issues.

Can I generate a Service scaffold with correct dependency declaration for OpenHarmony apps?

Yes, you can generate Service scaffolds that inherit the required base class and declare dependencies via the constructor, providing a minimal runnable example for wiring UI-driven pages through ServiceManager.

What are the limitations of using constructor-based dependency declaration in ArkTS?

Using constructor-based dependency declaration requires strict adherence to infra/domain/pages dependency directions, preventing broken layering and incorrect Service lifecycle usage that could lead to unstable app behavior.