harmony-arkts

harmony-arkts is a cursor rule for Cursor from PatrickJS/awesome-cursorrules. It costs 0 tokens per session (449 once invoked), scanned A, original, CC0-1.0.

A set of Cursor rules for building HarmonyOS applications with ArkTS, including components, state, layouts, resources, and accessibility.

In plain words
What is it for?
Use it when creating or reviewing HarmonyOS user interfaces and components in ArkTS.
Why use it?
It helps keep the application structure, data flow, event handling, and interface code consistent with HarmonyOS practices.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it when creating or reviewing HarmonyOS user interfaces and components in ArkTS.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/patrickjs/awesome-cursorrules/harmony-arkts
About the project

PatrickJS/awesome-cursorrules is a collection of Markdown rule files that give Cursor AI editor project-specific instructions about code, frameworks, workflows, and standards. Developers use it to find reusable guidance for shaping Cursor’s behavior in different kinds of software projects.

PatrickJS/awesome-cursorrules · 40,734 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/PatrickJS/awesome-cursorrules

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for harmony-arkts

README.md
[![agentmods](https://agentmods.dev/badge/rules/patrickjs/awesome-cursorrules/harmony-arkts.svg)](https://agentmods.dev/rules/patrickjs/awesome-cursorrules/harmony-arkts)
Your own site
<a href="https://agentmods.dev/rules/patrickjs/awesome-cursorrules/harmony-arkts"><img src="https://agentmods.dev/badge/rules/patrickjs/awesome-cursorrules/harmony-arkts.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 449 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00449
Opus 5 $0.00000 $0.00225
Sonnet 5 $0.00000 $0.00090
Haiku 4.5 $0.00000 $0.00045

Measured 3d ago against content hash b8bd2ad23cf4, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

harmony-arkts scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules/harmony-arkts.mdc · 55 lines

What it actually says

HarmonyOS ArkTS Rules

Component Structure

  • Use @Component for component definitions and PascalCase for component structs.
  • Keep state declarations near the top of the component.
  • Group lifecycle hooks before build().
  • Place build() last and keep it focused on UI composition.
  • Extract complex UI into smaller components.

State and Data Flow

  • Use @State for component-owned state.
  • Use @Prop for parent-to-child data.
  • Use @Link only for intentional two-way binding.
  • Keep derived values in methods or computed helpers rather than duplicating state.
  • Avoid broad global state unless the project has an established app-state pattern.

Layout and Styling

  • Use Column, Row, Stack, List, and other ArkUI primitives intentionally.
  • Keep layout properties such as width, height, alignment, and layout weight grouped before visual properties.
  • Use object notation for margin and padding when sides differ.
  • Use logical pixels consistently.
  • Use percentage strings for relative sizes.
  • Keep reusable spacing, colors, and typography in resources when the project supports it.

Events and Lifecycle

  • Use arrow functions for event handlers.
  • Keep event handlers short and delegate complex logic to methods.
  • Handle async failures explicitly and surface user-facing errors where appropriate.
  • Use lifecycle hooks for setup and teardown that genuinely depends on component lifecycle.

Resources and Accessibility

  • Use $r() for app resources.
  • Group resource references consistently.
  • Add descriptive labels and focus handling for interactive elements.
  • Maintain color contrast and touch target size.
  • Test on representative device sizes and orientations.

Common Mistakes

  • Do not bury business logic in build().
  • Do not use two-way binding when one-way props are enough.
  • Do not hardcode repeated strings, colors, and dimensions that belong in resources.
  • Do not leave debug console.log calls in production code.
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 55 lines · 0 tokens per session scan A b8bd2ad23cf4

Subscribe to this mod's changes

harmony-arkts is a cursor rule published in the GitHub repository PatrickJS/awesome-cursorrules (40,734 stars, last pushed 3mo ago), licensed CC0-1.0. It costs nothing until one of its globs matches a file; then it loads 449 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.