figma-ui-thread

figma-ui-thread is a cursor rule for Cursor from hoshikitsunoda/figma-plugins-vibe-coding-template. It costs 0 tokens per session (658 once invoked), scanned A, original, MIT.

Coding rules for the React interface of a Figma plugin. The interface runs in a browser iframe and communicates with the plugin through messages because it cannot directly use Figma's programming interface.

In plain words
What is it for?
Use it when building or editing the plugin's React UI, handling selections, sending commands, receiving updates, or managing browser storage and network requests.
Why use it?
It prevents UI code from relying on APIs that are unavailable in the iframe and defines how the interface and plugin exchange data.

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/hoshikitsunoda/figma-plugins-vibe-coding-template/figma-ui-thread
Clone the repo
git clone --depth 1 https://github.com/hoshikitsunoda/figma-plugins-vibe-coding-template

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 figma-ui-thread

README.md
[![agentmods](https://agentmods.dev/badge/rules/hoshikitsunoda/figma-plugins-vibe-coding-template/figma-ui-thread.svg)](https://agentmods.dev/rules/hoshikitsunoda/figma-plugins-vibe-coding-template/figma-ui-thread)
Your own site
<a href="https://agentmods.dev/rules/hoshikitsunoda/figma-plugins-vibe-coding-template/figma-ui-thread"><img src="https://agentmods.dev/badge/rules/hoshikitsunoda/figma-plugins-vibe-coding-template/figma-ui-thread.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 658 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.1 $0.00000 $0.00658
Opus 5 $0.00000 $0.00329
Sonnet 5 $0.00000 $0.00132
Haiku 4.5 $0.00000 $0.00066

Measured 5d ago against content hash 2957b306115c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

figma-ui-thread 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 5d 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/figma-ui-thread.mdc · 112 lines

How it starts

The opening of the file, as written. The whole thing — 112 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Figma UI Thread (React) Rules

This code runs in an iframe with full browser APIs but NO access to figma.*.

Available APIs

  • Full DOM and React
  • fetch() for network requests
  • window, localStorage, sessionStorage
  • parent.postMessage() to send messages to plugin

Communication with Plugin

Sending Messages to Plugin

import type { PluginMessage } from "../shared/messages";

const postToPlugin = (message: PluginMessage) => {
  parent.postMessage({ pluginMessage: message }, "*");
};

// Usage
postToPlugin({ type: "get-selection" });
postToPlugin({ type: "create-rectangle", width: 100, height: 100 });

Receiving Messages from Plugin

import type { UIMessage } from "../shared/messages";

useEffect(() => {
  const handleMessage = (event: MessageEvent<{ pluginMessage: UIMessage }>) => {
    const msg = event.data.pluginMessage;
    if (!msg) return;

    switch (msg.type) {
      case "selection-changed":
        setSelection(msg.nodes);
        break;
    }
  };

  window.addEventListener("message", handleMessage);
  return () => window.removeEventListener("message", handleMessage);
}, []);

React Patterns

Functional Components with Hooks

// ✓ Use functional components
function SelectionPanel() {
  const [selection, setSelection] = useState<SelectionNode[]>([]);
  // ...
}

Custom Hooks for Plugin Communication

Consider extracting message handling into a custom hook:

// src/ui/hooks/usePluginMessage.ts
function usePluginMessage<T>(type: string, handler: (data: T) => void) {
  useEffect(() => {
    const onMessage = (e: MessageEvent) => {
      if (e.data.pluginMessage?.type === type) {
        handler(e.data.pluginMessage);
      }
    };
    window.addEventListener("message", onMessage);
    return () => window.removeEventListener("message", onMessage);
  }, [type, handler]);
}

Styling with Tailwind CSS

Use Tailwind utility classes with CSS variables defined in index.css. Never hardcode colors — always use variables with Tailwind v4 syntax:

Read the full file on GitHub · 112 lines

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. 5d ago First seen · 112 lines · 0 tokens per session scan A 2957b306115c

Subscribe to this mod's changes

figma-ui-thread is a cursor rule published in the GitHub repository hoshikitsunoda/figma-plugins-vibe-coding-template (21 stars, last pushed 8mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 658 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.