api-ui-binding

A set of coding rules for connecting an API to a Compose user interface using the MVVM pattern, where view models hold app data and actions. It covers data objects, API interfaces, API calls, error handling, and displaying results.

In plain words
What is it for?
Use it when adding an API endpoint, creating matching data classes, connecting calls to a view model, or rendering API results in a Compose app.
Why use it?
It gives developers a consistent way to connect server data to screens without scattering network logic through the interface.

Cursor rule for Cursor

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.

agentmods
npx agentmods add rules/heegyeong/composesample/api-ui-binding
Clone the repo
git clone --depth 1 https://github.com/HeeGyeong/ComposeSample

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 433 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00000 $0.00433
Opus 5 $0.00000 $0.00217
Sonnet 5 $0.00000 $0.00087
Haiku 4.5 $0.00000 $0.00043

Measured 2d ago against content hash 7b519d930886, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

api-ui-binding 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 2d 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.

.cursor/rules/api-ui-binding.mdc · 60 lines

What it actually says


description: "API and UI Binding Creation using MVVM and Material3" globs: "" alwaysApply: true

API and UI Binding Creation Rules

Overview

This rule explains the steps to add APIs using MVVM architecture and connect data to UI following Material3 guidelines. Reference the detailed guide from CreateAPIAndUIBindingGuide.md.

Requirements

1. DTO Creation

  • Generate DTOs that match API documentation
  • Follow data class implementation rules from DataRules.md

2. API Interface

  • Add API call functions within already declared API interfaces
  • Create new interfaces only when no appropriate existing interface exists
  • Use proper naming and organization

3. API Call Function Implementation

  • Implement API call functions that match API documentation
  • Use proper HTTP methods and endpoints
  • Include error handling and response processing

4. ViewModel Integration

  • Add API call functions to appropriate ViewModel
  • Store data through API calls via ViewModel
  • Render UI with stored data
  • Follow ViewModel patterns from DIRules.md

Constraints

  1. Import: Use import statements after checking existing versions
  2. Responsiveness: Ensure code responsiveness

Expected Results

API Interface

  • API functions added to API interface

ViewModel

  • API call functions exist in appropriate ViewModel
  • Data stored after API calls

UI Rendering

  • UI rendered with stored data
  • Follow UI guidelines from UIRules.md

Additional Guidelines

  • Follow MVVM architecture and Material3 guidelines
  • Implement according to existing project patterns and rules
  • Maintain consistency across the codebase
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. 2d ago First seen · 60 lines · 0 tokens per session scan A 7b519d930886

Subscribe to this mod's changes

api-ui-binding is a cursor rule published in the GitHub repository HeeGyeong/ComposeSample (11 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 433 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-08-30.