PluginBench
Skill
Fail
Audit score 45

arkts-syntax-assistant

summerkaze/skill-arkts-syntax-assistant

How to install arkts-syntax-assistant

npx skills add https://github.com/summerkaze/skill-arkts-syntax-assistant --skill arkts-syntax-assistant
Claude Code
Cursor
Windsurf
Cline
Full instructions (SKILL.md)

Source of truth, from summerkaze/skill-arkts-syntax-assistant.


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

ArkTS Syntax Assistant

中文文档


Overview

ArkTS is the default development language for OpenHarmony applications. It builds upon TypeScript with enhanced static typing to improve program stability and performance.

Core Features

  • Static Typing: All types determined at compile time, reducing runtime checks
  • No Dynamic Object Layout: Object structure fixed at compile time, cannot be modified at runtime
  • Restricted Operators: Some operator behaviors are restricted to encourage clearer code semantics
  • No Structural Typing: Structural typing is currently not supported

Reference Documentation

ScenarioDocument
Syntax Learningreferences/en/introduction-to-arkts.md
Quick Overviewreferences/en/arkts-get-started.md
TS Migrationreferences/en/typescript-to-arkts-migration-guide.md
Migration Backgroundreferences/en/arkts-migration-background.md
Performancereferences/en/arkts-high-performance-programming.md
More Casesreferences/en/arkts-more-cases.md

Workflows

1. Syntax Questions

User Question -> Identify Question Type -> Consult Documentation -> Provide Code Example

Common Syntax Questions:

  • Variable declaration -> Use let/const with explicit type or inference
  • Function definition -> Supports optional parameters, defaults, rest parameters, arrow functions
  • Classes and interfaces -> Must initialize fields, supports inheritance and implementation
  • Generics -> Supports constraints and default values
  • Null safety -> Nullable types ((T | null)), non-null assertion ((!)), optional chaining ((?.))

2. TypeScript Migration

Identify TS Code -> Check Incompatible Features -> Consult Migration Rules -> Provide ArkTS Alternative

Key Migration Rules Quick Reference:

TypeScriptArkTS Alternative
var xlet x
any/unknownSpecific types
{n: 42} object literalDefine class/interface first
[index: T]: U index signatureRecord<T, U>
A & B intersection typeinterface C extends A, B
function(){} function expression() => {} arrow function
<Type>value type assertionvalue as Type
Destructuring [a, b] = arrIndividual access arr[0], arr[1]
for..infor loop or for..of
Constructor parameter propertiesExplicit field declaration

3. Performance Optimization

Analyze Code -> Identify Performance Issues -> Consult Optimization Guide -> Provide Solutions

High-Performance Programming Key Points:

  • Declarations: Use const for invariants; avoid mixing integer and float
  • Loops: Extract loop invariants; avoid numeric overflow
  • Functions: Parameter passing preferred over closures; avoid optional parameters
  • Arrays: Use TypedArray for numeric values; avoid sparse arrays and union type arrays
  • Exceptions: Avoid throwing in loops; use return values instead

4. Compile Error Resolution

Get Error Message -> Search Migration Rules -> Find Related Case -> Provide Fix

Common Questions

Q: How to handle JSON.parse return value?

// Error
let data = JSON.parse(str);

// Correct
let data: Record<string, Object> = JSON.parse(str);

Q: How to define object types?

// 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 };

Q: How to replace globalThis?

// 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);
  }
}

Q: How to handle error types in catch?

// Error
try {} catch (e: BusinessError) {}

// Correct
try {} catch (error) {
  let e: BusinessError = error as BusinessError;
}

Q: How to use Record type?

// 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,
};

Q: How to replace constructor signatures with factory functions?

// TypeScript constructor signature
type ControllerCtor = {
  new (value: string): Controller;
}

// ArkTS factory function
type ControllerFactory = () => Controller;

class Menu {
  createController: ControllerFactory = () => {
    return new Controller('default');
  }
}

Prohibited Standard Library APIs

The following are prohibited in ArkTS:

  • Global: eval
  • Object: __proto__, defineProperty, freeze, getPrototypeOf, etc.
  • Reflect: apply, construct, defineProperty, etc.
  • Proxy: All handler methods

Build Scripts

The scripts directory provides quick compilation scripts for ArkTS projects (including dependency installation):

PlatformScriptPurpose
macOS/Linuxscripts/run.shExecute ohpm install + hvigorw assembleApp
Windowsscripts/run.ps1Execute ohpm install + hvigorw assembleApp

Usage:

# macOS/Linux
bash scripts/run.sh

# Windows PowerShell
.\scripts\run.ps1

Script execution steps:

  1. Install dependencies (ohpm install --all)
  2. Build project (hvigorw assembleApp)

Mandatory Requirements

CRITICAL: When this skill generates ArkTS code, the following workflow MUST be followed:

  1. Compilation Verification: After generating code, you MUST compile the project using the build scripts:

    • macOS/Linux: bash scripts/run.sh
    • Windows: .\scripts\run.ps1
  2. Retry Strategy: If compilation fails:

    • Analyze the error output
    • Fix the issue and retry compilation
    • Maximum of 3 compilation attempts
  3. User Intervention: After 3 failed compilation attempts, use AskUserQuestion:

    Question: Compilation failed after 3 attempts. How would you like to proceed?
    Options:
    - Continue retrying (attempt another fix)
    - Manual intervention (I'll wait for your guidance)
    - Skip compilation (proceed without verification)
    
  4. Error Reporting: Always show the full compilation error output when failures occur.

Answer Guidelines

  1. Prioritize code examples: Show correct vs incorrect syntax comparison
  2. Reference official documentation: For detailed explanations, guide users to consult corresponding documents in references/
  3. Explain reasons: Explain why ArkTS has this restriction (performance, stability)
  4. Provide alternatives: For unsupported features, provide feasible alternatives

License

MIT License - see LICENSE.txt

Related skills

More from summerkaze/skill-arkts-syntax-assistant and the wider catalog.

PPppt-agent logo

ppt-agent

sunbigfly/ppt-agent-skills

专业 PPT 演示文稿全流程 AI 生成助手。模拟顶级 PPT 设计公司的完整工作流(需求调研到资料搜集到大纲策划到策划稿到设计稿),输出高质量 HTML 格式演示文稿。当用户提到制作 PPT、做演示文稿、做 slides、做幻灯片、做汇报材料、做培训课件、做路演 deck、做产品介绍页面时触发此技能。即使用户只说"帮我做个关于 X 的介绍"或"我要给老板汇报 Y",只要暗示需要结构化的多页演示内容,都应该触发。也适用于用户说"帮我把这篇文档做成 PPT"、"把这个主题做成演示"等需要将内容转化为演示格式的场景。英文场景同样适用:"make a presentation about..."、"create slides for..."、"build a pitch deck"、"I need a keynote for..."。隐式意图也应触发:"帮我把这个数据可视化一下给老板看"、"我需要一份能拿去路演的东西"、"把这个报告做得好看点能展示"、"beautify my existing PPT"、"redesign these slides"。改善或美化现有 PPT 也属于此技能范畴。

663 installs
EXexa-web-search-free logo

exa-web-search-free

sundial-org/awesome-openclaw-skills

Free neural search for web, code, and company research via Exa MCP—no API key required.

2.7k installs
FFffmpeg-video-editor logo

ffmpeg-video-editor

sundial-org/awesome-openclaw-skills

Generate FFmpeg commands from natural language video editing requests - cut, trim, convert, compress, change aspect ratio, extract audio, and more.

1.2k installs
FIfinance-news logo

finance-news

sundial-org/awesome-openclaw-skills

AI-powered market news briefings with portfolio tracking and automated delivery to WhatsApp.

2.6k installs
JIjina-reader logo

jina-reader

sundial-org/awesome-openclaw-skills

Web content extraction via Jina AI Reader API. Three modes: read (URL to markdown), search (web search + full content), ground (fact-checking). Extracts clean content without exposing server IP.

984 installs
MEmemory-setup logo

memory-setup

sundial-org/awesome-openclaw-skills

Enable persistent memory for Moltbot/Clawdbot agents to recall past conversations, preferences, and project context.

1.4k installsAudited