{"id":"fe2f41b6-9f56-4a71-adf2-dea41047c89a","shortId":"PumqAj","kind":"skill","title":"arkts-syntax-assistant","tagline":"|-","description":"# ArkTS Syntax Assistant\n\n[中文文档](SKILL.zh.md)\n\n---\n\n## Overview\n\nArkTS is the default development language for OpenHarmony applications. It builds\nupon TypeScript with enhanced static typing to improve program stability and\nperformance.\n\n## Core Features\n\n- **Static Typing**: All types determined at compile time, reducing runtime checks\n- **No Dynamic Object Layout**: Object structure fixed at compile time, cannot be\n  modified at runtime\n- **Restricted Operators**: Some operator behaviors are restricted to encourage\n  clearer code semantics\n- **No Structural Typing**: Structural typing is currently not supported\n\n## Reference Documentation\n\n| Scenario | Document |\n|----------|----------|\n| Syntax Learning | [references/en/introduction-to-arkts.md](references/en/introduction-to-arkts.md) |\n| Quick Overview | [references/en/arkts-get-started.md](references/en/arkts-get-started.md) |\n| TS Migration | [references/en/typescript-to-arkts-migration-guide.md](references/en/typescript-to-arkts-migration-guide.md) |\n| Migration Background | [references/en/arkts-migration-background.md](references/en/arkts-migration-background.md) |\n| Performance | [references/en/arkts-high-performance-programming.md](references/en/arkts-high-performance-programming.md) |\n| More Cases | [references/en/arkts-more-cases.md](references/en/arkts-more-cases.md) |\n\n## Workflows\n\n### 1. Syntax Questions\n\n```\nUser Question -> Identify Question Type -> Consult Documentation -> Provide Code Example\n```\n\n**Common Syntax Questions**:\n- Variable declaration -> Use `let`/`const` with explicit type or inference\n- Function definition -> Supports optional parameters, defaults, rest parameters,\n  arrow functions\n- Classes and interfaces -> Must initialize fields, supports inheritance and\n  implementation\n- Generics -> Supports constraints and default values\n- Null safety -> Nullable types ((T | null)), non-null assertion ((!)), optional\n  chaining ((?.))\n\n### 2. TypeScript Migration\n\n```\nIdentify TS Code -> Check Incompatible Features -> Consult Migration Rules -> Provide ArkTS Alternative\n```\n\n**Key Migration Rules Quick Reference**:\n\n| TypeScript | ArkTS Alternative |\n|------------|-------------------|\n| `var x` | `let x` |\n| `any`/`unknown` | Specific types |\n| `{n: 42}` object literal | Define class/interface first |\n| `[index: T]: U` index signature | `Record<T, U>` |\n| `A & B` intersection type | `interface C extends A, B` |\n| `function(){}` function expression | `() => {}` arrow function |\n| `<Type>value` type assertion | `value as Type` |\n| Destructuring `[a, b] = arr` | Individual access `arr[0]`, `arr[1]` |\n| `for..in` | `for` loop or `for..of` |\n| Constructor parameter properties | Explicit field declaration |\n\n### 3. Performance Optimization\n\n```\nAnalyze Code -> Identify Performance Issues -> Consult Optimization Guide -> Provide Solutions\n```\n\n**High-Performance Programming Key Points**:\n\n- **Declarations**: Use `const` for invariants; avoid mixing integer and float\n- **Loops**: Extract loop invariants; avoid numeric overflow\n- **Functions**: Parameter passing preferred over closures; avoid optional\n  parameters\n- **Arrays**: Use TypedArray for numeric values; avoid sparse arrays and union\n  type arrays\n- **Exceptions**: Avoid throwing in loops; use return values instead\n\n### 4. Compile Error Resolution\n\n```\nGet Error Message -> Search Migration Rules -> Find Related Case -> Provide Fix\n```\n\n## Common Questions\n\n### Q: How to handle JSON.parse return value?\n\n```typescript\n// Error\nlet data = JSON.parse(str);\n\n// Correct\nlet data: Record<string, Object> = JSON.parse(str);\n```\n\n### Q: How to define object types?\n\n```typescript\n// TypeScript syntax (not supported in ArkTS)\ntype Person = { name: string, age: number }\n\n// ArkTS syntax\ninterface Person {\n  name: string;\n  age: number;\n}\n\n// Using object literal\nlet p: Person = { name: 'John', age: 25 };\n```\n\n### Q: How to replace globalThis?\n\n```typescript\n// Error\nglobalThis.value = 'xxx';\n\n// Use singleton pattern\nexport class GlobalContext {\n  private constructor() {}\n  private static instance: GlobalContext;\n  private _objects = new Map<string, Object>();\n\n  public static getContext(): GlobalContext {\n    if (!GlobalContext.instance) {\n      GlobalContext.instance = new GlobalContext();\n    }\n    return GlobalContext.instance;\n  }\n\n  getObject(key: string): Object | undefined {\n    return this._objects.get(key);\n  }\n\n  setObject(key: string, value: Object): void {\n    this._objects.set(key, value);\n  }\n}\n```\n\n### Q: How to handle error types in catch?\n\n```typescript\n// Error\ntry {} catch (e: BusinessError) {}\n\n// Correct\ntry {} catch (error) {\n  let e: BusinessError = error as BusinessError;\n}\n```\n\n### Q: How to use Record type?\n\n```typescript\n// TypeScript index signature\nfunction foo(data: { [key: string]: string }) {}\n\n// ArkTS Record\nfunction foo(data: Record<string, string>) {}\n\n// Usage example\nlet map: Record<string, number> = {\n  'John': 25,\n  'Mary': 21,\n};\n```\n\n### Q: How to replace constructor signatures with factory functions?\n\n```typescript\n// TypeScript constructor signature\ntype ControllerCtor = {\n  new (value: string): Controller;\n}\n\n// ArkTS factory function\ntype ControllerFactory = () => Controller;\n\nclass Menu {\n  createController: ControllerFactory = () => {\n    return new Controller('default');\n  }\n}\n```\n\n## Prohibited Standard Library APIs\n\nThe following are prohibited in ArkTS:\n\n- **Global**: `eval`\n- **Object**: `__proto__`, `defineProperty`, `freeze`, `getPrototypeOf`, etc.\n- **Reflect**: `apply`, `construct`, `defineProperty`, etc.\n- **Proxy**: All handler methods\n\n## Build Scripts\n\nThe scripts directory provides quick compilation scripts for ArkTS projects\n(including dependency installation):\n\n| Platform | Script | Purpose |\n|----------|--------|---------|\n| macOS/Linux | `scripts/run.sh` | Execute `ohpm install` + `hvigorw assembleApp` |\n| Windows | `scripts/run.ps1` | Execute `ohpm install` + `hvigorw assembleApp` |\n\nUsage:\n```bash\n# macOS/Linux\nbash scripts/run.sh\n\n# Windows PowerShell\n.\\scripts\\run.ps1\n```\n\nScript execution steps:\n1. Install dependencies (`ohpm install --all`)\n2. Build project (`hvigorw assembleApp`)\n\n## Mandatory Requirements\n\n**CRITICAL**: When this skill generates ArkTS code, the following workflow MUST be followed:\n\n1. **Compilation Verification**: After generating code, you MUST compile the project using the build scripts:\n   - macOS/Linux: `bash scripts/run.sh`\n   - Windows: `.\\scripts\\run.ps1`\n\n2. **Retry Strategy**: If compilation fails:\n   - Analyze the error output\n   - Fix the issue and retry compilation\n   - Maximum of **3 compilation attempts**\n\n3. **User Intervention**: After 3 failed compilation attempts, use `AskUserQuestion`:\n   ```\n   Question: Compilation failed after 3 attempts. How would you like to proceed?\n   Options:\n   - Continue retrying (attempt another fix)\n   - Manual intervention (I'll wait for your guidance)\n   - Skip compilation (proceed without verification)\n   ```\n\n4. **Error Reporting**: Always show the full compilation error output when failures occur.\n\n## Answer Guidelines\n\n1. **Prioritize code examples**: Show correct vs incorrect syntax comparison\n2. **Reference official documentation**: For detailed explanations, guide users to\n   consult corresponding documents in references/\n3. **Explain reasons**: Explain why ArkTS has this restriction (performance,\n   stability)\n4. **Provide alternatives**: For unsupported features, provide feasible\n  alternatives\n\n## License\n\nMIT License - see [LICENSE.txt](LICENSE.txt)","tags":["skill","arkts","syntax","assistant","summerkaze","agent","agent-skills","claude","claude-code","claude-skills","opencode"],"capabilities":["skill","source-summerkaze","skill-skill-arkts-syntax-assistant","topic-agent","topic-agent-skills","topic-claude","topic-claude-code","topic-claude-skills","topic-opencode","topic-skill"],"categories":["skill-arkts-syntax-assistant"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/SummerKaze/skill-arkts-syntax-assistant","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add SummerKaze/skill-arkts-syntax-assistant","source_repo":"https://github.com/SummerKaze/skill-arkts-syntax-assistant","install_from":"skills.sh"}},"qualityScore":"0.476","qualityRationale":"deterministic score 0.48 from registry signals: · indexed on github topic:agent-skills · 53 github stars · SKILL.md body (7,554 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-22T18:57:51.147Z","embedding":null,"createdAt":"2026-04-18T23:56:10.402Z","updatedAt":"2026-04-22T18:57:51.147Z","lastSeenAt":"2026-04-22T18:57:51.147Z","tsv":"'0':248 '1':111,250,624,650,748 '2':175,630,671,758 '21':519 '25':405,517 '3':264,689,692,696,706,773 '4':331,733,784 '42':207 'access':246 'age':386,394,404 'altern':189,197,786,792 'alway':736 'analyz':267,677 'anoth':718 'answer':746 'api':556 'appli':572 'applic':19 'arkt':2,5,11,188,196,381,388,501,539,562,590,642,778 'arkts-syntax-assist':1 'arr':244,247,249 'array':309,317,321 'arrow':145,233 'askuserquest':701 'assembleapp':604,611,634 'assert':172,237 'assist':4,7 'attempt':691,699,707,717 'avoid':288,297,306,315,323 'b':222,229,243 'background':100 'bash':613,615,666 'behavior':66 'build':21,580,631,663 'businesserror':474,481,484 'c':226 'cannot':57 'case':107,343 'catch':468,472,477 'chain':174 'check':46,181 'class':147,419,545 'class/interface':211 'clearer':71 'closur':305 'code':72,122,180,268,643,655,750 'common':124,346 'comparison':757 'compil':42,55,332,587,651,658,675,686,690,698,703,729,740 'const':131,285 'constraint':159 'construct':573 'constructor':258,422,524,531 'consult':119,184,272,768 'continu':715 'control':538,544,551 'controllerctor':534 'controllerfactori':543,548 'core':34 'correct':361,475,753 'correspond':769 'createcontrol':547 'critic':637 'current':80 'data':358,363,497,505 'declar':128,263,283 'default':14,142,161,552 'defin':210,372 'defineproperti':567,574 'definit':138 'depend':593,626 'destructur':241 'detail':763 'determin':40 'develop':15 'directori':584 'document':84,86,120,761,770 'dynam':48 'e':473,480 'encourag':70 'enhanc':25 'error':333,336,356,412,465,470,478,482,679,734,741 'etc':570,575 'eval':564 'exampl':123,510,751 'except':322 'execut':600,607,622 'explain':774,776 'explan':764 'explicit':133,261 'export':418 'express':232 'extend':227 'extract':294 'factori':527,540 'fail':676,697,704 'failur':744 'feasibl':791 'featur':35,183,789 'field':152,262 'find':341 'first':212 'fix':53,345,681,719 'float':292 'follow':558,645,649 'foo':496,504 'freez':568 'full':739 'function':137,146,230,231,234,300,495,503,528,541 'generat':641,654 'generic':157 'get':335 'getcontext':435 'getobject':444 'getprototypeof':569 'global':563 'globalcontext':420,426,436,441 'globalcontext.instance':438,439,443 'globalthi':410 'globalthis.value':413 'guid':274,765 'guidanc':727 'guidelin':747 'handl':351,464 'handler':578 'high':278 'high-perform':277 'hvigorw':603,610,633 'identifi':116,178,269 'implement':156 'improv':29 'includ':592 'incompat':182 'incorrect':755 'index':213,216,493 'individu':245 'infer':136 'inherit':154 'initi':151 'instal':594,602,609,625,628 'instanc':425 'instead':330 'integ':290 'interfac':149,225,390 'intersect':223 'intervent':694,721 'invari':287,296 'issu':271,683 'john':403,516 'json.parse':352,359,367 'key':190,281,445,451,453,459,498 'languag':16 'layout':50 'learn':88 'let':130,200,357,362,399,479,511 'librari':555 'licens':793,795 'license.txt':797,798 'like':711 'liter':209,398 'll':723 'loop':254,293,295,326 'macos/linux':598,614,665 'mandatori':635 'manual':720 'map':430,512 'mari':518 'maximum':687 'menu':546 'messag':337 'method':579 'migrat':96,99,177,185,191,339 'mit':794 'mix':289 'modifi':59 'must':150,647,657 'n':206 'name':384,392,402 'new':429,440,535,550 'non':170 'non-nul':169 'null':163,168,171 'nullabl':165 'number':387,395,515 'numer':298,313 'object':49,51,208,366,373,397,428,432,447,456,565 'occur':745 'offici':760 'ohpm':601,608,627 'openharmoni':18 'oper':63,65 'optim':266,273 'option':140,173,307,714 'output':680,742 'overflow':299 'overview':10,92 'p':400 'paramet':141,144,259,301,308 'pass':302 'pattern':417 'perform':33,103,265,270,279,782 'person':383,391,401 'platform':595 'point':282 'powershel':618 'prefer':303 'priorit':749 'privat':421,423,427 'proceed':713,730 'program':30,280 'prohibit':553,560 'project':591,632,660 'properti':260 'proto':566 'provid':121,187,275,344,585,785,790 'proxi':576 'public':433 'purpos':597 'q':348,369,406,461,485,520 'question':113,115,117,126,347,702 'quick':91,193,586 'reason':775 'record':218,364,489,502,506,513 'reduc':44 'refer':83,194,759,772 'references/en/arkts-get-started.md':93,94 'references/en/arkts-high-performance-programming.md':104,105 'references/en/arkts-migration-background.md':101,102 'references/en/arkts-more-cases.md':108,109 'references/en/introduction-to-arkts.md':89,90 'references/en/typescript-to-arkts-migration-guide.md':97,98 'reflect':571 'relat':342 'replac':409,523 'report':735 'requir':636 'resolut':334 'rest':143 'restrict':62,68,781 'retri':672,685,716 'return':328,353,442,449,549 'rule':186,192,340 'run.ps1':620,670 'runtim':45,61 'safeti':164 'scenario':85 'script':581,583,588,596,619,621,664,669 'scripts/run.ps1':606 'scripts/run.sh':599,616,667 'search':338 'see':796 'semant':73 'setobject':452 'show':737,752 'signatur':217,494,525,532 'singleton':416 'skill':640 'skill-skill-arkts-syntax-assistant' 'skill.zh.md':9 'skip':728 'solut':276 'source-summerkaze' 'spars':316 'specif':204 'stabil':31,783 'standard':554 'static':26,36,424,434 'step':623 'str':360,368 'strategi':673 'string':365,385,393,431,446,454,499,500,507,508,514,537 'structur':52,75,77 'support':82,139,153,158,379 'syntax':3,6,87,112,125,377,389,756 'this._objects.get':450 'this._objects.set':458 'throw':324 'time':43,56 'topic-agent' 'topic-agent-skills' 'topic-claude' 'topic-claude-code' 'topic-claude-skills' 'topic-opencode' 'topic-skill' 'tri':471,476 'ts':95,179 'type':27,37,39,76,78,118,134,166,205,224,236,240,320,374,382,466,490,533,542 'typedarray':311 'typescript':23,176,195,355,375,376,411,469,491,492,529,530 'u':215,220 'undefin':448 'union':319 'unknown':203 'unsupport':788 'upon':22 'usag':509,612 'use':129,284,310,327,396,415,488,661,700 'user':114,693,766 'valu':162,235,238,314,329,354,455,460,536 'var':198 'variabl':127 'verif':652,732 'void':457 'vs':754 'wait':724 'window':605,617,668 'without':731 'workflow':110,646 'would':709 'x':199,201 'xxx':414 '中文文档':8","prices":[{"id":"37d6023f-3b2f-4a9d-b2f3-27f64506bd9e","listingId":"fe2f41b6-9f56-4a71-adf2-dea41047c89a","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"SummerKaze","category":"skill-arkts-syntax-assistant","install_from":"skills.sh"},"createdAt":"2026-04-18T23:56:10.402Z"}],"sources":[{"listingId":"fe2f41b6-9f56-4a71-adf2-dea41047c89a","source":"github","sourceId":"SummerKaze/skill-arkts-syntax-assistant","sourceUrl":"https://github.com/SummerKaze/skill-arkts-syntax-assistant","isPrimary":false,"firstSeenAt":"2026-04-18T23:56:10.402Z","lastSeenAt":"2026-04-22T18:57:51.147Z"}],"details":{"listingId":"fe2f41b6-9f56-4a71-adf2-dea41047c89a","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"SummerKaze","slug":"skill-arkts-syntax-assistant","github":{"repo":"SummerKaze/skill-arkts-syntax-assistant","stars":53,"topics":["agent","agent-skills","claude","claude-code","claude-skills","opencode","skill"],"license":"mit","html_url":"https://github.com/SummerKaze/skill-arkts-syntax-assistant","pushed_at":"2026-01-31T16:25:40Z","description":"ArkTS language learning and development assistant","skill_md_sha":"35309c675f42dec14cff55af008b7590300ac4b0","skill_md_path":"SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/SummerKaze/skill-arkts-syntax-assistant"},"layout":"root","source":"github","category":"skill-arkts-syntax-assistant","frontmatter":{"name":"arkts-syntax-assistant","license":"MIT","description":"|-"},"skills_sh_url":"https://skills.sh/SummerKaze/skill-arkts-syntax-assistant"},"updatedAt":"2026-04-22T18:57:51.147Z"}}