harmonyos arkts skill

    1

    Develop, migrate, and optimize HarmonyOS NEXT apps using ArkTS, ArkUI, and Native NDK.

    Free

    1 useSecurity scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    harmonyos arkts skill

    Example session with this skill installed

    Create a NAPI bridge to expose a C++ method 'calculateSum' to ArkTS, including the .d.ts declaration and the NAPI registration code.

    • Read your context and instructions
    • Compiled the harmonyos arkts

    I have generated the NAPI bridge components for the calculateSum method. This includes the ArkTS type definition, the C++ implementation with Node-API status checks, and the registration logic for your module.

    HarmonyOS NAPI Bridge Implementation

    1. ArkTS Facade (index.d.ts)

    export const calculateSum: (a: number, b: number) => number;
    

    2. Native Implementation (calculate_sum.cpp)

    #include "napi/native_api.h"
    
    static napi_value CalculateSum(napi_env env, napi_callback_info info) {
        size_t argc = 2;
        napi_value args[2] = {nullptr};
        
        // Validate arguments and count
        napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
        if (status != napi_ok || argc < 2) {
            napi_throw_type_error(env, nullptr, "Wrong number of arguments");
            return nullptr;
        }
    
        double val1, val2;
        if (napi_get_value_double(env, args[0], &val1) != napi_ok ||
            napi_get_value_double(env, args[1], &val2) != napi_ok) {
            napi_throw_type_error(env, nullptr, "Arguments must be numbers");
            return nullptr;
        }
    
        napi_value sum;
        napi_create_double(env, val1 + val2, &sum);
        return sum;
    }
    
    // Registration logic
    EXTERN_C_START
    static napi_value Init(napi_env env, napi_value exports) {
        napi_property_descriptor desc[] = {
            { "calculateSum", nullptr, CalculateSum, nullptr, nullptr, nullptr, napi_default, nullptr }
        };
        napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
        return exports;
    }
    EXTERN_C_END
    
    static napi_module nativeModule = {
        .nm_version = 1,
        .nm_flags = 0,
        .nm_filename = nullptr,
        .nm_register_func = Init,
        .nm_modname = "entry",
        .nm_priv = ((void*)0),
        .reserved = { 0 },
    };
    
    extern "C" __attribute__((constructor)) void RegisterModule() {
        napi_module_register(&nativeModule);
    }
    

    Next steps

    • Add calculate_sum.cpp to your CMakeLists.txt under add_library.
    • Import the method in ArkTS using import native from 'libentry.so'.
    • Run a build to verify the .so library is correctly packaged in the HAP.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Building for HarmonyOS NEXT requires strict adherence to ArkTS paradigms and complex NDK bridges. This skill eliminates the guesswork in cross-layer development by enforcing Huawei-specific architectural patterns and migration logic. It handles the friction of mapping Android lifecycles to HarmonyOS, managing NAPI thread safety, and optimizing ArkUI performance.

    What it does

    • ArkTS/ArkUI development implements declarative UI using V1/V2 state management, Navigation, and persistent storage.
    • Native NDK integration manages C/C++ bridges, Node-API (NAPI) registrations, and CMake configurations for .so libraries.
    • Android migration maps Activities, Fragments, and XML layouts to ArkUI components while migrating resources and assets.
    • Static auditing executes bundled scripts to scan Native project structures for ABI mismatches and registration errors.
    • Cross-layer orchestration synchronizes ArkTS facades with C++ headers, ensuring memory safety and proper thread ownership.

    How it works

    1. Context discovery reads your project SDK versions, Hvigor configurations, and existing architectural patterns.
    2. Task routing triggers specialized workflows for UI, Native, or Migration tasks based on file extensions and imports.
    3. Bridge generation defines binary layouts, ownership models, and Promise/callback settle paths for NAPI interop.
    4. Validation runs local linting, Hvigor build tasks, and static chain analysis to verify consistency across ArkTS and Native layers.

    Frameworks & tools

    Targeted at HarmonyOS NEXT using ArkTS, ArkUI, and NDK C/C++. Supports Hvigor build systems, Node-API, CMake, XComponent, and Native Drawing APIs.

    Why this beats prompting it yourself

    Generic AI often produces standard TypeScript or generic JNI code that fails under the strict HarmonyOS runtime. This skill enforces specific constraints like systemDateTime over Date.now(), handles NAPI status checks correctly, and prevents UI thread blocking in the ArkUI lifecycle.

    Use cases

    • Porting a complex Android app with custom C++ rendering to a native HarmonyOS HAP.
    • Debugging memory leaks or crashes in high-frequency ArkTS-to-Native calls.
    • Implementing high-performance UI components using XComponent and GLES.
    • Setting up a multi-module project structure with shared HAR/HSP libraries.

    Known limitations

    Does not modify local DevEco Studio environments, SDK paths, or signing configurations. Native performance tuning requires baseline data from physical target devices.

    Requires manual environment setup for Hvigor and SDKs. Does not automate signature or local.properties configuration. Limited to HarmonyOS NEXT API standards.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    1 use

    Times used to date

    Free forever

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 25 days ago

    • Free with an Agensi account

    Requires

    Git

    Permissions

    Terminal / Shell
    Read Files
    Write Files
    Listed25 days ago

    What's inside

    Frequently Asked Questions

    This skill handles the complex transition from Android's JNI to HarmonyOS's Node-API (NAPI), ensuring correct thread ownership and mapping Android lifecycles directly to ArkUI components.

    Yes, the skill is fully optimized for HarmonyOS NEXT, enforcing the strict ArkTS paradigms and V2 state management required for the latest system version.

    It automates the creation of C/C++ bridges, Node-API registrations, and CMake configurations, preventing common binary interface (ABI) mismatches and memory safety errors.

    The skill provides the logic for ArkTS/ArkUI development, Native NDK orchestration, and automated migration scripts to be used within your AI agent's environment.

    While it automates bridge generation and UI mapping, it does not manage your local DevEco Studio installation, SDK paths, or app signing certificates.

    Generic AI often suggests standard JNI or TypeScript; this skill enforces HarmonyOS-specific constraints, such as using systemDateTime and preventing UI thread blocking in ArkUI.

    New in Agents & Orchestration