cursorrules

A set of coding rules for building Figma plugins with TypeScript, Vite, React, shadcn/ui, and Biome. It describes how the plugin’s main code and browser-based interface communicate and how files should be organized.

In plain words
What is it for?
Use it when creating or maintaining Figma plugins, especially when organizing the project, separating Figma API code from the React interface, or defining shared types and messages.
Why use it?
It gives an agent a consistent structure for handling Figma’s two separate plugin processes and their message-based communication. This helps avoid mixing code that runs in different environments.

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/yasuhiro-y/figma-plugin-by-vibe-coding/cursorrules
Clone the repo
git clone --depth 1 https://github.com/yasuhiro-y/figma-plugin-by-vibe-coding

Made for: Cursor.

Per session 4,469 This file is loaded in full into every session.
When invoked 4,469 The same file — it is already loaded in full.
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.04469 $0.04469
Opus 5 $0.02235 $0.02235
Sonnet 5 $0.00894 $0.00894
Haiku 4.5 $0.00447 $0.00447

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

Security

Grade A, and why

cursorrules 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.

.cursorrules · 681 lines

How it starts

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

Figma Plugin Vibe Coding Rules

You are an expert Figma Plugin Developer with deep knowledge of TypeScript, Vite, React, shadcn/ui, and Biome. You specialize in creating high-quality, maintainable plugins that integrate seamlessly with Figma's design ecosystem.

Architecture Guidelines

Figma Plugin Dual-Process Model

Figma plugins run in two separate processes:

  1. Main Thread (Plugin Code) - Sandboxed JavaScript environment with access to Figma API
  2. UI Thread (iframe) - Standard browser environment for React components

CRITICAL: These processes are completely isolated and can only communicate via postMessage.

Directory Structure

Follow this strict feature-based organization:

src/
├── plugin/           # Main thread code - Figma API interactions only
│   └── main.ts
├── ui/               # UI thread code - React components and styles
│   ├── components/   # Reusable UI components
│   ├── hooks/        # Custom React hooks
│   └── main.tsx      # UI entry point
└── common/           # Shared code - types, constants, messaging contracts
    ├── types.ts      # Type definitions
    ├── messages.ts   # Communication contracts
    └── constants.ts  # Shared constants

Rules:

  • NEVER import Figma API types (@figma/plugin-typings) in src/ui/
  • NEVER import React or DOM APIs in src/plugin/
  • ALL communication contracts MUST be defined in src/common/
  • Use feature-based organization within components

TypeScript Best Practices

Explicit Typing

  • ALL function parameters MUST have explicit type annotations
  • ALL function return types MUST be explicitly declared
  • ALL variables receiving values from external sources MUST be typed
  • Use unknown instead of any, then narrow the type
// ✅ Good
function processNode(node: SceneNode): NodeData {
  return { id: node.id, name: node.name };
}

// ❌ Bad
function processNode(node) {
  return { id: node.id, name: node.name };
}

Error Handling

Use Result pattern for operations that can fail:

Read the full file on GitHub · 681 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. 2d ago First seen · 681 lines · 4,469 tokens per session scan A acc4ec73bd5f

Subscribe to this mod's changes

cursorrules is a cursor rule published in the GitHub repository yasuhiro-y/figma-plugin-by-vibe-coding (4 stars, last pushed 5mo ago), licensed MIT. It adds 4,469 tokens to every session, about $0.0223 per session on Opus 5. 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-31.