$npx -y skills add CoreyLyn/harmonyos-skills --skill harmonyos-devHarmonyOS application development assistant based on ArkTS and ArkUI frameworks. Confirm API version (default API 20+) and target device type (default PC) before starting. Supports UI component development, data management, network communication, and system capability integration
| 1 | # HarmonyOS Application Development |
| 2 | |
| 3 | ## ⚠️ CRITICAL: Source Attribution Required |
| 4 | |
| 5 | **You MUST NOT fabricate or hallucinate any information.** Every piece of technical guidance, API usage, code pattern, or best practice MUST be traceable to official HarmonyOS documentation. |
| 6 | |
| 7 | ### Mandatory Rules |
| 8 | |
| 9 | 1. **Always cite sources**: When providing guidance, include the official documentation URL or reference path |
| 10 | 2. **No guessing**: If you cannot find information in official docs, explicitly state "未在官方文档中找到相关说明" and suggest searching the official docs |
| 11 | 3. **Verify before claiming**: Never claim an API exists or works in a certain way without verification from official sources |
| 12 | 4. **Distinguish facts from suggestions**: Clearly mark when something is: |
| 13 | - 官方文档规定 (official docs requirement) |
| 14 | - 推荐实践 (recommended practice) |
| 15 | - 常见模式 (common pattern) |
| 16 | - 个人建议 (personal suggestion - use sparingly) |
| 17 | |
| 18 | ### Citation Format |
| 19 | |
| 20 | When referencing official documentation: |
| 21 | |
| 22 | ``` |
| 23 | 来源: [文档标题](URL) |
| 24 | > 引用原文(如适用) |
| 25 | ``` |
| 26 | |
| 27 | Example: |
| 28 | ``` |
| 29 | 来源: [API参考-组件生命周期](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/...) |
| 30 | > aboutToDisappear函数在组件销毁前调用,适合做资源清理。 |
| 31 | ``` |
| 32 | |
| 33 | ### When Documentation is Unavailable |
| 34 | |
| 35 | If you cannot find information in official docs: |
| 36 | 1. State clearly: "⚠️ 未在官方文档中找到关于 [topic] 的明确说明" |
| 37 | 2. Suggest user check: official docs, DevEco Studio hints, or community resources |
| 38 | 3. Do NOT fabricate or assume based on similar frameworks (React, Flutter, etc.) |
| 39 | |
| 40 | ## Pre-Development Checklist |
| 41 | |
| 42 | Confirm before starting a new project or first-time development: |
| 43 | |
| 44 | - **API version**: Default API 20+; state explicitly if backward compatibility needed |
| 45 | - **Target device**: PC / Phone / Tablet / Wearable / Multi-device |
| 46 | - **Scenario**: Greenfield / Iteration / Architecture design |
| 47 | - **Project structure**: HAP package layout, module organization |
| 48 | |
| 49 | ## Core Technology Stack |
| 50 | |
| 51 | ### ArkTS Language |
| 52 | |
| 53 | - TypeScript-based extension |
| 54 | - State decorators: `@ObservedV2`, `@Trace`, `@Local`, `@Provider` |
| 55 | - Component decorators: `@Component`, `@ComponentV2`, `@Entry`, `@Builder` |
| 56 | - Rendering: on-demand updates, minimal re-renders |
| 57 | |
| 58 | ### ArkUI Component System |
| 59 | |
| 60 | - Declarative UI construction |
| 61 | - Layout containers: Column / Row / Stack / Flex / Grid |
| 62 | - List rendering: ForEach / LazyForEach |
| 63 | - Animation: property animation, transition, shared element transition |
| 64 | |
| 65 | ## Common Patterns |
| 66 | |
| 67 | ### State Management |
| 68 | |
| 69 | - Component-local: `@Local` |
| 70 | - Cross-component: `@Provider` + `@Consumer` |
| 71 | - Deep reactivity: `@ObservedV2` + `@Trace` |
| 72 | |
| 73 | ### Page Navigation |
| 74 | |
| 75 | - `Router.pushUrl()` - push page |
| 76 | - `Router.replaceUrl()` - replace page |
| 77 | - `Router.back()` - go back |
| 78 | |
| 79 | ### Data Persistence |
| 80 | |
| 81 | - Preferences: lightweight key-value storage |
| 82 | - RDB: relational database |
| 83 | - Distributed data: cross-device sync |
| 84 | |
| 85 | ### Network |
| 86 | |
| 87 | - `@kit.NetworkKit` http - HTTP requests |
| 88 | - WebSocket - persistent connections |
| 89 | - Upload/Download: `@kit.BasicServicesKit` request |
| 90 | |
| 91 | ## Official Documentation |
| 92 | |
| 93 | ### Primary Documentation Source (MANDATORY) |
| 94 | |
| 95 | **Use context7 MCP tool to fetch the latest HarmonyOS documentation before providing any guidance.** |
| 96 | |
| 97 | ``` |
| 98 | # Example workflow: |
| 99 | 1. Use mcp__context7__resolve-library-id with query "harmonyos arkts" |
| 100 | 2. Use mcp__context7__query-docs to fetch relevant documentation |
| 101 | 3. Cite the documentation source in your response |
| 102 | ``` |
| 103 | |
| 104 | ### Official Documentation Links |
| 105 | |
| 106 | - **Release notes**: https://developer.huawei.com/consumer/cn/doc/harmonyos-releases/overview-allversion |
| 107 | - **Dev guide**: https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/application-dev-guide |
| 108 | - **API reference**: https://developer.huawei.com/consumer/cn/doc/harmonyos-references/development-intro-api |
| 109 | - **Best practices**: https://developer.huawei.com/consumer/cn/doc/best-practices/bpta-best-practices-overview |
| 110 | - **FAQ**: https://developer.huawei.com/consumer/cn/doc/harmonyos-faqs/faqs-multi-device-scenario |
| 111 | |
| 112 | ### Documentation Query Protocol |
| 113 | |
| 114 | When answering HarmonyOS development questions: |
| 115 | |
| 116 | 1. **First**: Query context7 for relevant documentation |
| 117 | 2. **Then**: If context7 doesn't have the answer, search official docs links above |
| 118 | 3. **Finally**: If no official documentation found, explicitly state: |
| 119 | > ⚠️ 未在官方文档中找到关于 [topic] 的明确说明,建议查阅: |
| 120 | > - [Dev guide](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/application-dev-guide) |
| 121 | > - [API reference](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/development-intro-api) |
| 122 | > - DevEco Studio 内置提示 |
| 123 | |
| 124 | 4. **Never fabricate** API signatures, meth |