Install any skill in seconds. Free to start, no credit card required.
Get Started Free →HarmonyOS application development expert. Use when building HarmonyOS apps with ArkTS, ArkUI, Stage model, and distributed capabilities. Covers HarmonyOS NEXT (API 12+) best practices.
.claude/skills/majiayu000-harmonyos-app/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 25% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 50% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 114% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 101% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 132% | 0% |
any or dynamic types> These rules are mandatory. Violating them means the skill is not working correctly.
ArkTS prohibits dynamic typing. Never use any, type assertions, or dynamic property access.
typescript// ❌ FORBIDDEN: Dynamic types let data: any = fetchData(); let obj: object = {}; obj['dynamicKey'] = value; // Dynamic property access (someVar as SomeType).method(); // Type assertion // ✅ REQUIRED: Strict typing interface UserData { id: string; name: string; } let data: UserData = fetchData(); // Use Record for dynamic keys let obj: Record<string, string> = {}; obj['key'] = value; // OK with Record type
Never mutate @State/@Prop variables directly in nested objects. Use immutable updates.
typescript// ❌ FORBIDDEN: Direct mutation @State user: User = { name: 'John', age: 25 }; updateAge() { this.user.age = 26; // UI won't update! } // ✅ REQUIRED: Immutable update updateAge() { this.user = { ...this.user, age: 26 }; // Creates new object, triggers UI update } // For arrays @State items: string[] = ['a', 'b']; // ❌ FORBIDDEN this.items.push('c'); // UI won't update // ✅ REQUIRED this.items = [...this.items, 'c'];
Always use Stage model (UIAbility). Never use deprecated FA model (PageAbility).
typescript// ❌ FORBIDDEN: FA Model (deprecated) // config.json with "pages" array export default { onCreate() { ... } // PageAbility lifecycle } // ✅ REQUIRED: Stage Model // module.json5 with abilities configuration import { UIAbility } from '@kit.AbilityKit'; export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { // Modern Stage model lifecycle } onWindowStageCreate(windowStage: window.WindowStage): void { windowStage.loadContent('pages/Index'); } }
Extract reusable UI into @Component. No inline complex UI in build() methods.
typescript// ❌ FORBIDDEN: Monolithic build method @Entry @Component struct MainPage { build() { Column() { // 200+ lines of inline UI... Row() { Image($r('app.media.avatar')) Column() { Text(this.user.name) Text(this.user.email) } } // More inline UI... } } } // ✅ REQUIRED: Extract components @Component struct UserCard { @Prop user: User; build() { Row() { Image($r('app.media.avatar')) Column() { Text(this.user.name) Text(this.user.email) } } } } @Entry @Component struct MainPage { @State user: User = { name: 'John', email: 'john@example.com' }; build() { Column() { UserCard({ user: this.user }) } } }
| Scenario | Pattern | Example | |----------|---------|---------| | Component-local state | @State | Counter, form inputs | | Parent-to-child data | @Prop | Read-only child data | | Two-way binding | @Link | Shared mutable state | | Cross-component state | @Provide/@Consume | Theme, user context | | Persistent state | PersistentStorage | User preferences | | App-wide state | AppStorage | Global state | | Complex state logic | @Observed/@ObjectLink | Nested object updates |
@State → Component owns the state, triggers re-render on change
@Prop → Parent passes value, child gets copy (one-way)
@Link → Parent passes reference, child can modify (two-way)
@Provide → Ancestor provides value to all descendants
@Consume → Descendant consumes value from ancestor
@StorageLink → Syncs with AppStorage, two-way binding
@StorageProp → Syncs with AppStorage, one-way binding
@Observed → Class decorator for observable objects
@ObjectLink → Links to @Observed object in parentMyApp/
├── entry/ # Main entry module
│ ├── src/main/
│ │ ├── ets/
│ │ │ ├── entryability/ # UIAbility definitions
│ │ │ │ └── EntryAbility.ets
│ │ │ ├── pages/ # Page components
│ │ │ │ ├── Index.ets
│ │ │ │ └── Detail.ets
│ │ │ ├── components/ # Reusable UI components
│ │ │ │ ├── common/ # Common components
│ │ │ │ └── business/ # Business-specific components
│ │ │ ├── viewmodel/ # ViewModels (MVVM)
│ │ │ ├── model/ # Data models
│ │ │ ├── service/ # Business logic services
│ │ │ ├── repository/ # Data access layer
│ │ │ ├── utils/ # Utility functions
│ │ │ └── constants/ # Constants and configs
│ │ ├── resources/ # Resources (strings, images)
│ │ └── module.json5 # Module configuration
│ └── build-profile.json5
├── common/ # Shared library module
│ └── src/main/ets/
├── features/ # Feature modules
│ ├── feature_home/
│ └── feature_profile/
└── build-profile.json5 # Project configuration┌─────────────────────────────────────┐
│ UI Layer (Pages) │ ArkUI Components
├─────────────────────────────────────┤
│ ViewModel Layer │ State management, UI logic
├─────────────────────────────────────┤
│ Service Layer │ Business logic
├─────────────────────────────────────┤
│ Repository Layer │ Data access abstraction
├─────────────────────────────────────┤
│ Data Sources (Local/Remote) │ Preferences, RDB, Network
└─────────────────────────────────────┘typescriptimport { router } from '@kit.ArkUI'; @Component export struct ProductCard { // Props from parent @Prop product: Product; @Prop onAddToCart: (product: Product) => void; // Local state @State isExpanded: boolean = false; // Computed values (use getters) get formattedPrice(): string { return `¥${this.product.price.toFixed(2)}`; } // Lifecycle aboutToAppear(): void { console.info('ProductCard appearing'); } aboutToDisappear(): void { console.info('ProductCard disappearing'); } // Event handlers private handleTap(): void { router.pushUrl({ url: 'pages/ProductDetail', params: { id: this.product.id } }); } private handleAddToCart(): void { this.onAddToCart(this.product); } // UI builder build() { Column() { Image(this.product.imageUrl) .width('100%') .aspectRatio(1) .objectFit(ImageFit.Cover) Text(this.product.name) .fontSize(16) .fontWeight(FontWeight.Medium) Text(this.formattedPrice) .fontSize(14) .fontColor('#FF6B00') Button('Add to Cart') .onClick(() => this.handleAddToCart()) } .padding(12) .backgroundColor(Color.White) .borderRadius(8) .onClick(() => this.handleTap()) } }
typescriptimport { BasicDataSource } from '../utils/BasicDataSource'; class ProductDataSource extends BasicDataSource<Product> { private products: Product[] = []; totalCount(): number { return this.products.length; } getData(index: number): Product { return this.products[index]; } addData(product: Product): void { this.products.push(product); this.notifyDataAdd(this.products.length - 1); } updateData(index: number, product: Product): void { this.products[index] = product; this.notifyDataChange(index); } } @Component struct ProductList { private dataSource: ProductDataSource = new ProductDataSource(); build() { List() { LazyForEach(this.dataSource, (product: Product, index: number) => { ListItem() { ProductCard({ product: product }) } }, (product: Product) => product.id) // Key generator } .lanes(2) // Grid with 2 columns .cachedCount(4) // Cache 4 items for smooth scrolling } }
typescript@CustomDialog struct ConfirmDialog { controller: CustomDialogController; title: string = 'Confirm'; message: string = ''; onConfirm: () => void = () => {}; build() { Column() { Text(this.title) .fontSize(20) .fontWeight(FontWeight.Bold) .margin({ bottom: 16 }) Text(this.message) .fontSize(16) .margin({ bottom: 24 }) Row() { Button('Cancel') .onClick(() => this.controller.close()) .backgroundColor(Color.Gray) .margin({ right: 16 }) Button('Confirm') .onClick(() => { this.onConfirm(); this.controller.close(); }) } } .padding(24) } } // Usage @Entry @Component struct MainPage { dialogController: CustomDialogController = new CustomDialogController({ builder: ConfirmDialog({ title: 'Delete Item', message: 'Are you sure you want to delete this item?', onConfirm: () => this.deleteItem() }), autoCancel: true }); private deleteItem(): void { // Delete logic } build() { Button('Delete') .onClick(() => this.dialogController.open()) } }
Detailed material starting at ## State Management Patterns has been moved to reference/extended.md to keep this skill concise. Load that reference when the task requires the moved examples, command catalogs, checklists, platform details, or implementation templates.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 22,303 | 26,605 | +19% | 1 | 1 | 0% | 4,794 | 6,012 | +25% | 0 | 0 | — |
case-02 | fail→pass | 21,148 | 19,965 | -6% | 1 | 1 | 0% | 4,717 | 7,056 | +50% | 0 | 0 | — |
case-03 | fail→pass | 9,065 | 6,017 | -34% | 1 | 1 | 0% | 1,742 | 3,734 | +114% | 0 | 0 | — |
case-04 | fail→pass | 13,576 | 11,050 | -19% | 1 | 1 | 0% | 2,398 | 4,808 | +101% | 0 | 0 | — |
case-05 | pass→pass | 7,481 | 8,077 | +8% | 1 | 1 | 0% | 1,602 | 4,450 | +178% | 0 | 0 | — |
case-06 | pass→pass | 13,287 | 8,461 | -36% | 1 | 1 | 0% | 2,569 | 4,426 | +72% | 0 | 0 | — |
case-07 | pass→pass | 9,602 | 8,630 | -10% | 1 | 1 | 0% | 1,848 | 4,383 | +137% | 0 | 0 | — |
case-08 | pass→pass | 17,315 | 14,003 | -19% | 1 | 1 | 0% | 3,549 | 5,806 | +64% | 0 | 0 | — |
case-09 | pass→pass | 15,924 | 12,744 | -20% | 1 | 1 | 0% | 2,978 | 5,267 | +77% | 0 | 0 | — |
case-10 | fail→pass | 12,239 | 12,141 | -1% | 1 | 1 | 0% | 2,164 | 5,014 | +132% | 0 | 0 | — |
case-11 | fail→pass | 7,889 | 6,627 | -16% | 1 | 1 | 0% | 1,454 | 4,051 | +179% | 0 | 0 | — |
case-12 | pass→pass | 5,953 | 6,237 | +5% | 1 | 1 | 0% | 927 | 3,849 | +315% | 0 | 0 | — |
case-13 | fail→fail | 18,453 | 21,630 | +17% | 1 | 1 | 0% | 3,361 | 6,864 | +104% | 0 | 0 | — |
case-14 | pass→pass | 14,143 | 12,319 | -13% | 1 | 1 | 0% | 2,844 | 5,445 | +91% | 0 | 0 | — |
case-15 | pass→pass | 8,102 | 5,409 | -33% | 1 | 1 | 0% | 1,415 | 3,776 | +167% | 0 | 0 | — |
case-16 | pass→pass | 13,257 | 12,475 | -6% | 1 | 1 | 0% | 2,742 | 5,457 | +99% | 0 | 0 | — |
case-17 | pass→pass | 15,869 | 14,462 | -9% | 1 | 1 | 0% | 2,711 | 5,445 | +101% | 0 | 0 | — |
case-18 | pass→pass | 9,058 | 5,902 | -35% | 1 | 1 | 0% | 1,487 | 3,933 | +164% | 0 | 0 | — |
case-19 | pass→pass | 10,473 | 4,595 | -56% | 1 | 1 | 0% | 1,674 | 3,599 | +115% | 0 | 0 | — |
case-20 | pass→pass | 9,244 | 7,031 | -24% | 1 | 1 | 0% | 1,520 | 3,976 | +162% | 0 | 0 | — |
case-21 | pass→pass | 11,755 | 7,534 | -36% | 1 | 1 | 0% | 2,110 | 4,098 | +94% | 0 | 0 | — |
case-22 | pass→pass | 14,340 | 14,470 | +1% | 1 | 1 | 0% | 2,814 | 5,591 | +99% | 0 | 0 | — |
case-23 | pass→pass | 11,123 | 10,417 | -6% | 1 | 1 | 0% | 2,324 | 5,010 | +116% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +26 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.