agentleFS
DunoDogeDunoDoge/OHOS-Skills/arkts-helper/SKILL.md

arkts-helper

Skill1 starsChanged 2 months agoMITView on GitHub

Use when writing, reviewing, or migrating ArkTS code for HarmonyOS / OpenHarmony app development. Triggers include ArkTS syntax, ArkTS type system, ArkTS class/interface/generics, ArkTS coding style, ArkTS language features, TypeScript to ArkTS migration, ArkTS performance optimization, ArkTS standard library, ArkTS concurrency, Promise, async/await, TaskPool, Worker, Sendable, ArkTS container classes, ArkUI state management, @State, @Prop, @Link, @Provide, @Consume, @Observed, @ObjectLink, @ObservedV2, @Trace, @Local, @Param, XML/Buffer/JSON, or any topic under the HarmonyOS ArkTS language documentation. Loads the offline ArkTS language reference set so the agent can give accurate ArkTS guidance instead of guessing from TypeScript knowledge.

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 3 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Mandatory static typing: All variables must have declared types.

    line 11
  2. Distinctive:

    Follow this skill's workflow whenever any of the following conditions are met:

    line 21
  3. Distinctive:

    Do not force this skill onto "ArkTS compilation error fixes", "NDK/C++ interop", or "command-line build/deploy" scenarios — use the …

    line 34
  4. Very specific:

    Before any ArkTS syntax/migration/performance task, you must read references/INDEX.md first.

    line 55
  5. Very specific:

    When reading documents, prefer using Grep/Read with offset/limit to locate specific sections — do not read large files in their entirety at …

    line 75
  6. Distinctive:

    Before writing or modifying ArkTS code, self-check the following high-frequency red lines (detailed rules are subject to the original …

    line 79
  7. Very specific:

    No any/unknown: Must use concrete types

    line 82
  8. Very specific:

    No as type assertions: Use explicit type declarations

    line 84
  9. Very specific:

    Unary + only for numbers: Use Number() or parseInt() for string-to-number conversion

    line 85
  10. Very specific:

    When uncertain, search the original text in references/04-ts-to-arkts-migration-rules.md or 06-arkts-high-performance.md for the relevant …

    line 96
  11. Very specific:

    When answering ArkTS syntax/migration/performance questions, include a citation at the end of the response, e.g.:

    line 100

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

arkts-helper

ArkTS is the official high-level language for HarmonyOS application development, extending and constraining the TypeScript (TS) ecosystem:

  • Mandatory static typing: All variables must have declared types; any/unknown are not supported. The compiler performs stricter type checking at development time.
  • No runtime object layout changes: Dynamically adding/removing object properties is not allowed; object structure is determined at compile time.
  • Restricted operator semantics: The unary plus operator + can only operate on numbers, not for string-to-number conversion.
  • No Structural typing: Type compatibility is based on nominal typing, not structural typing.
  • Use let instead of var: ArkTS requires let for variable declarations; var is not supported.

Code written by agents using generic TypeScript experience is highly likely to fail compilation or underperform on HarmonyOS. This skill provides offline reference documents (13 docs + INDEX under references/) which are offline copies of Huawei's official "ArkTS Language" documentation series, serving as the authoritative reference for ArkTS syntax/migration/performance/standard-library/state-management tasks.

When to Use This Skill

Follow this skill's workflow whenever any of the following conditions are met:

  • The user requests writing or reviewing ArkTS code (syntax, type system, classes/interfaces/generics/enums)
  • The user requests migrating TypeScript code to ArkTS (adaptation rules, adaptation cases)
  • The user requests optimizing ArkTS code performance (high-performance programming practices)
  • The user requests using the ArkTS standard library (XML/Buffer/JSON/container libraries)
  • The user requests ArkTS concurrency programming (Promise/async-await/TaskPool/Worker/Sendable)
  • The user requests ArkUI state management guidance (V1: @State/@Prop/@Link/@Provide/@Consume/@Observed/@ObjectLink; V2: @ObservedV2/@Trace/@Local/@Param)
  • The user asks about differences between ArkTS and TypeScript
  • The user requests ArkTS coding standards (naming, code formatting, comments)
  • The user mentions arkts-no-* rules but needs syntax guidance rather than error fixes
  • The user mentions ArkTS language features (@Concurrent, Sendable, container classes, etc.)

Do not force this skill onto "ArkTS compilation error fixes", "NDK/C++ interop", or "command-line build/deploy" scenarios — use the corresponding skills instead (see boundary below).

Boundary with Other Skills

This skill covers "ArkTS language syntax and style guidance", not "how to fix compilation errors", "how to write NDK code", or "how to invoke build commands". When ArkTS development tasks involve the following issues, cross-reference the corresponding skill:

Issue TypeCross-reference SkillBoundary
ArkTS compilation errors (arkts-no-* rules, etc.)arkts-debugThis skill covers "how to write compliant code"; arkts-debug covers "how to fix errors after they occur"
NDK / C++ / Node-API interoparkts-ndk-devThis skill only provides a cross-language interaction overview; detailed Node-API development belongs to arkts-ndk-dev
Command-line build/deploy/signing/pipelinearkts-buildThis skill does not cover build commands
APIs / Kits / features not covered by offline docsharmony-fetchIf the 13 offline docs in this skill are insufficient to answer a question (e.g., new Kits, latest API signatures, version changes), use harmony-fetch to fetch the latest documentation from the Huawei developer portal
Runtime crashes / jscrash (code compiles but crashes)arkts-crash-diagnosisThis skill covers "how to write compliant code"; diagnosing and fixing runtime failures (闪退/白屏/异常) belongs to arkts-crash-diagnosis
Understanding an existing project / line-by-line explanationunderstand-hmos"Why is this file here / what does this config mean" for an existing project belongs to understand-hmos
Creating a new project from scratchcreate-hmos-projectScaffold a runnable project with create-hmos-project, then write code with this skill
Atomic Service (元服务) capability limitsatomic-service-devWhether an API / module type / package size is allowed in an atomic service belongs to atomic-service-dev (元服务API集 subset enforcement); ArkTS syntax itself stays here

Workflow (Follow Strictly)

1. Read the Index First, Then Decide Which Doc to Load

Before any ArkTS syntax/migration/performance task, you must read references/INDEX.md first. It provides the role of each of the 12 documents, reading paths by scenario, and key difference quick references — this prevents loading the entire reference directory into context.

2. Load the Corresponding Document by Task Type

Task TypeRequired Reading (under references/)
ArkTS syntax (declarations/types/operators/statements/functions/classes/interfaces/generics/enums)01-arkts-language-introduction.md
ArkTS coding style02-arkts-coding-style.md
TS→ArkTS migration background03-ts-to-arkts-migration-background.md
TS→ArkTS migration rules04-ts-to-arkts-migration-rules.md
TS→ArkTS migration cases05-ts-to-arkts-migration-cases.md
ArkTS high-performance programming06-arkts-high-performance.md
ArkTS standard library overview07-arkts-stdlib-overview.md
XML/Buffer/JSON extension libraries08-arkts-xml-buffer-json.md
ArkTS container library09-arkts-container-library.md
Async concurrency (Promise/async-await)10-arkts-concurrency-async.md
Multi-thread concurrency (TaskPool/Worker/Sendable)11-arkts-concurrency-multithread.md
Cross-language interaction overview12-arkts-cross-language-overview.md
ArkUI state management (V1/V2 decorators)13-arkts-state-management.md

When reading documents, prefer using Grep/Read with offset/limit to locate specific sections — do not read large files in their entirety at once.

3. Strictly Enforce Red Lines When Writing Code

Before writing or modifying ArkTS code, self-check the following high-frequency red lines (detailed rules are subject to the original documentation):

TS→ArkTS difference red lines:

  • No any/unknown: Must use concrete types
  • No runtime object layout changes: Cannot dynamically add/remove properties
  • No as type assertions: Use explicit type declarations
  • Unary + only for numbers: Use Number() or parseInt() for string-to-number conversion
  • Use let instead of var: ArkTS does not support var
  • Object literals must correspond to declared classes or interfaces: Cannot use anonymous object types

High-performance programming red lines:

  • Use const for unchanging variables: Variables declared with let that are never modified should use const
  • Avoid mixing integer and floating-point types: number type variables should not mix integers and floating-point values
  • Avoid sparse arrays: Arrays should be initialized contiguously
  • Avoid reassigning function parameters: Parameters should be treated as read-only
  • Use ArkTS container classes instead of Array: ArrayList/HashMap/TreeMap, etc. offer better performance

When uncertain, search the original text in references/04-ts-to-arkts-migration-rules.md or 06-arkts-high-performance.md for the relevant red line before writing.

4. Cite the Source When Referencing Documents

When answering ArkTS syntax/migration/performance questions, include a citation at the end of the response, e.g.:

Per the "Mandatory Static Typing" section in references/04-ts-to-arkts-migration-rules.md.

5. Do Not Skip or Replace This Skill's Checks

Even if the user's code "looks like valid TypeScript", in the HarmonyOS context you must verify against this skill's red lines before answering — do not assume TypeScript knowledge can be directly applied to ArkTS.

TS→ArkTS Differences Quick Reference

DifferenceTypeScriptArkTSNotes
Type SystemOptional static typingMandatory static typingNo any/unknown; all variables must declare types
Object LayoutProperties can be added/removed at runtimeNo runtime object layout changesObject structure determined at compile time; no dynamic property add/remove
Operator SemanticsUnary + can convert strings to numbersRestricted operator semanticsUnary + only for numbers; use Number()/parseInt() for string-to-number
Type CompatibilityStructural typingNo Structural typingType compatibility based on nominal typing
Variable Declarationvar/let/constUse let/const, no varMust use let or const
Type Assertionas type assertionRestricted as type assertionSome scenarios prohibit as; prefer explicit type declarations
Object LiteralsCan use anonymous object typesMust correspond to declared class or interfaceObject literals must correspond to explicitly declared class or interface
Index SignaturesSupports [key: string]: typeNo index signaturesUse Record or Map instead
DecoratorsExperimental supportNative support@Entry/@Component/@State and other ArkUI decorators
EnumsNumeric/string/heterogeneous enumsOnly numeric and string enumsHeterogeneous enums not supported
FunctionsSupports function overloadingNo function overloadingUse union types or optional parameters instead
in OperatorSupports property checksRestricted in operatorOnly supported in for...in and keyof scenarios

High-Performance Programming Rules

CategoryRuleViolation Consequence
DeclarationsVariables that don't change must use constCompiler cannot optimize, performance degrades
NumericAvoid mixing integer and floating-point in number variablesRuntime type check overhead
NumericAvoid numeric overflow in computationsRuntime exceptions
LoopsExtract constants in loops, reduce property access countUnnecessary repeated property access
FunctionsPrefer passing external variables as parametersClosure variable capture causes performance loss
FunctionsAvoid optional parametersRuntime type check overhead
FunctionsAvoid reassigning function parametersCompiler cannot optimize
ArraysAvoid sparse arraysRuntime extra checks
ContainersUse ArkTS container classes (ArrayList/HashMap, etc.) instead of ArrayArray operations are less performant than specialized containers
ConcurrencyUse TaskPool/Worker for long-running tasks to avoid blocking main threadUI stuttering

Directory Structure

arkts-helper/
├── SKILL.md                                          # This file
└── references/
    ├── INDEX.md                                      # Must read first
    ├── 01-arkts-language-introduction.md             # ArkTS language introduction
    ├── 02-arkts-coding-style.md                      # ArkTS coding style
    ├── 03-ts-to-arkts-migration-background.md        # TS→ArkTS migration background
    ├── 04-ts-to-arkts-migration-rules.md             # TS→ArkTS migration rules
    ├── 05-ts-to-arkts-migration-cases.md             # TS→ArkTS migration cases
    ├── 06-arkts-high-performance.md                  # ArkTS high-performance programming
    ├── 07-arkts-stdlib-overview.md                   # ArkTS standard library overview
    ├── 08-arkts-xml-buffer-json.md                   # XML/Buffer/JSON extension libraries
    ├── 09-arkts-container-library.md                 # ArkTS container library
    ├── 10-arkts-concurrency-async.md                 # Async concurrency (Promise/async-await)
    ├── 11-arkts-concurrency-multithread.md           # Multi-thread concurrency & inter-thread communication
    ├── 12-arkts-cross-language-overview.md           # Cross-language interaction overview
    └── 13-arkts-state-management.md                  # ArkUI state management overview (V1/V2)

Documentation Source & Maintenance

  • Upstream: Huawei Developer official site "Documentation Center › Application Development" series, under https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/:
    • introduction-to-arkts (ArkTS language introduction)
    • arkts-coding-style-guide (ArkTS coding style)
    • arkts-migration-background (migration background)
    • typescript-to-arkts-migration-guide (migration rules)
    • arkts-more-cases (migration cases)
    • arkts-high-performance-programming (high-performance programming)
    • arkts-utils-overview (standard library overview)
    • xml-generation-parsing-conversion + buffer + arkts-json (XML/Buffer/JSON)
    • containers + linear-container + nonlinear-container (container libraries)
    • async-concurrency-overview (async concurrency)
    • multithread-concurrency + interthread-communication (multi-thread concurrency)
    • arkts-cross-language-interaction (cross-language interaction)
    • arkts-state-management-overview (ArkUI state management V1/V2 overview)
  • Documents are offline snapshots: 01-12 taken on 2026-07-20, 13 taken on 2026-08-29; each document includes the upstream URL and fetch timestamp at the top.
  • To update to the latest version, re-run the fetch (use curl/WebFetch from the upstream URLs to overwrite files in references/); if expanding the file list, also update references/INDEX.md.
  • ArkTS language specifications may change with HarmonyOS version updates; if uncertain about syntax, consult the latest official documentation.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.