brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
ArkTS syntax, migration, and optimization guide for HarmonyOS/OpenHarmony development. Triggers on: .ets files, ArkTS keywords, HarmonyOS/OpenHarmony context, @ohos packages. Help with syntax reference, TypeScript migration, performance optimization, compile errors, state
Claude Code
$ npx -y skills add SummerKaze/skill-arkts-syntax-assistant --skill skill-arkts-syntax-assistant --agent claude-code
Codex
$ npx skills add SummerKaze/skill-arkts-syntax-assistant --skill skill-arkts-syntax-assistant -a codex -y
Cursor
$ npx skills add SummerKaze/skill-arkts-syntax-assistant --skill skill-arkts-syntax-assistant -a cursor -y
Gemini CLI
$ npx skills add SummerKaze/skill-arkts-syntax-assistant --skill skill-arkts-syntax-assistant -a gemini-cli -y
GitHub Copilot
$ npx skills add SummerKaze/skill-arkts-syntax-assistant --skill skill-arkts-syntax-assistant -a github-copilot -y
OpenCode
$ npx skills add SummerKaze/skill-arkts-syntax-assistant --skill skill-arkts-syntax-assistant -a opencode -y
Windsurf
$ npx skills add SummerKaze/skill-arkts-syntax-assistant --skill skill-arkts-syntax-assistant -a windsurf -y
name: arkts-syntax-assistant description: |- ArkTS syntax, migration, and optimization guide for HarmonyOS/OpenHarmony development. Triggers on: .ets files, ArkTS keywords, HarmonyOS/OpenHarmony context, @ohos packages. Help with syntax reference, TypeScript migration, performance optimization, compile errors, state management, component development, and language-specific questions. license: MIT tags: - arkts - harmonyos - typescript - migration - development - syntax
[中文文档](SKILL.zh.md)
---
ArkTS is the default development language for OpenHarmony applications. It builds upon TypeScript with enhanced static typing to improve program stability and performance.
modified at runtime
clearer code semantics
| Scenario | Document | |----------|----------| | Syntax Learning | [references/en/introduction-to-arkts.md](references/en/introduction-to-arkts.md) | | Quick Overview | [references/en/arkts-get-started.md](references/en/arkts-get-started.md) | | TS Migration | [references/en/typescript-to-arkts-migration-guide.md](references/en/typescript-to-arkts-migration-guide.md) | | Migration Background | [references/en/arkts-migration-background.md](references/en/arkts-migration-background.md) | | Performance | [references/en/arkts-high-performance-programming.md](references/en/arkts-high-performance-programming.md) | | More Cases | [references/en/arkts-more-cases.md](references/en/arkts-more-cases.md) |
User Question -> Identify Question Type -> Consult Documentation -> Provide Code Example
**Common Syntax Questions**:
arrow functions
implementation
chaining ((?.))
Identify TS Code -> Check Incompatible Features -> Consult Migration Rules -> Provide ArkTS Alternative
**Key Migration Rules Quick Reference**:
| TypeScript | ArkTS Alternative | |------------|-------------------| | `var x` | `let x` | | `any`/`unknown` | Specific types | | `{n: 42}` object literal | Define class/interface first | | `[index: T]: U` index signature | `Record<T, U>` | | `A & B` intersection type | `interface C extends A, B` | | `function(){}` function expression | `() => {}` arrow function | | `<Type>value` type assertion | `value as Type` | | Destructuring `[a, b] = arr` | Individual access `arr[0]`, `arr[1]` | | `for..in` | `for` loop or `for..of` | | Constructor parameter properties | Explicit field declaration |
Analyze Code -> Identify Performance Issues -> Consult Optimization Guide -> Provide Solutions
**High-Performance Programming Key Points**:
parameters
type arrays
Get Error Message -> Search Migration Rules -> Find Related Case -> Provide Fix
// Error let data = JSON.parse(str); // Correct let data: Record<string, Object> = JSON.parse(str);
// TypeScript syntax (not supported in ArkTS)
type Person = { name: string, age: number }
// ArkTS syntax
interface Person {
name: string;
age: number;
}
// Using object literal
let p: Person = { name: 'John', age: 25 };// Error
globalThis.value = 'xxx';
// Use singleton pattern
export class GlobalContext {
private constructor() {}
private static instance: GlobalContext;
private _objects = new Map<string, Object>();
public static getContext(): GlobalContext {
if (!GlobalContext.instance) {
GlobalContext.instance = new GlobalContext();
}
return GlobalContext.instance;
}
getObject(key: string): Object | undefined {
return this._objects.get(key);
}
setObject(key: string, value: Object): void {
this._objects.set(key, value);
}
}// Error
try {} catch (e: BusinessError) {}
// Correct
try {} catch (error) {
let e: BusinessError = error as BusinessError;
}// TypeScript index signature
function foo(data: { [key: string]: string }) {}
// ArkTS Record
function foo(data: Record<string, string>) {}
// Usage example
let map: Record<string, number> = {
'John': 25,
'Mary': 21,
};// TypeScript constructor signature
type ControllerCtor = {
new (value: string): Controller;
}
// ArkTS factory function
type ControllerFactory = () => Controller;
class Menu {
createController: ControllerFactory = () => {
return new Controller('default');
}
}The following are prohibited in ArkTS:
ArkTS 语言学习与开发助手,提供语法参考、TypeScript 迁移指导和高性能编程实践 这是一个支持多平台的 ArkTS 语法助手技能,兼容 claude-code、opencode、cursor、trea 等 AI 编码助手。ArkTS 是 OpenHarmony 应用的默认开发语言,在 TypeScript 基础上做了静态类型强化,提升程序稳定性和性能。
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.