fabric-js

fabric-js is a cursor rule for Cursor from sanjeed5/awesome-cursor-rules-mdc. It costs 1,930 tokens per session, scanned A, original, CC0-1.0.

A set of coding guidelines for fabric.js, a JavaScript and TypeScript library for creating and editing objects on HTML canvas elements. It covers typed imports, canvas choices, and organizing interactive canvas applications.

In plain words
What is it for?
Use it when building browser-based drawing tools, editors, diagrams, or other canvas applications with fabric.js.
Why use it?
It helps avoid unnecessary library code, poor canvas choices, and hard-to-maintain project structures. The guidance also targets better performance and clearer modern API usage.

Cursor rule for Cursor

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

Good fit Use it when building browser-based drawing tools, editors, diagrams, or other canvas applications with fabric.js.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/sanjeed5/awesome-cursor-rules-mdc/fabric-js
About the project

awesome-cursor-rules-mdc is a generator that creates Cursor MDC rule files from structured library information, using semantic search and language models to gather and organize guidance. Developers use it to produce reusable rules for libraries in Cursor, and the catalogue includes 200 of those rules.

sanjeed5/awesome-cursor-rules-mdc · 3,570 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/sanjeed5/awesome-cursor-rules-mdc

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 fabric-js

README.md
[![agentmods](https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/fabric-js.svg)](https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/fabric-js)
Your own site
<a href="https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/fabric-js"><img src="https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/fabric-js.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,930 This file is loaded in full into every session.
When invoked 1,930 The same file — it is already loaded in full.
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.01930 $0.01930
Opus 5 $0.00965 $0.00965
Sonnet 5 $0.00386 $0.00386
Haiku 4.5 $0.00193 $0.00193

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

Security

Grade A, and why

fabric-js 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 4d 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-mdc/fabric-js.mdc · 226 lines

How it starts

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

fabric-js Best Practices

This document provides definitive guidelines for developing with fabric-js (v6.9.0+), emphasizing performance, maintainability, and modern API adoption. Adhere to these rules to ensure robust and efficient canvas applications.

1. Code Organization and Structure

1.1. Embrace TypeScript and ES Modules

Always use TypeScript for type safety and leverage ES6 modules for efficient bundling. Import only the specific fabric components you need.

❌ BAD: Global fabric access, full library import

// main.js
import 'fabric'; // Imports everything
const canvas = new fabric.Canvas('myCanvas');
canvas.add(new fabric.Rect({ left: 10, top: 10, width: 50, height: 50 }));

✅ GOOD: Modular, typed imports

// main.ts
import { Canvas, Rect, IText } from 'fabric';

const canvas = new Canvas('myCanvas');
const rect = new Rect({ left: 10, top: 10, width: 50, height: 50, fill: 'red' });
canvas.add(rect);

1.2. Choose the Right Canvas Type

Use StaticCanvas for read-only displays or high-frame-rate scenes where interactivity is not required. It offers a significant performance boost by skipping event handling.

❌ BAD: Using Canvas when no interaction is needed

// For displaying a static image or animation without user interaction
const canvas = new Canvas('myStaticCanvas');
canvas.add(someFabricObject);
canvas.renderAll();

✅ GOOD: Using StaticCanvas for static or high-performance rendering

// For displaying a static image or animation without user interaction
import { StaticCanvas, Rect } from 'fabric';

const staticCanvas = new StaticCanvas('myStaticCanvas');
const rect = new Rect({ left: 10, top: 10, width: 50, height: 50, fill: 'blue' });
staticCanvas.add(rect);
staticCanvas.renderAll();

2. Performance Considerations

2.1. Disable Unnecessary Interactivity

Minimize overhead by disabling selection, controls, and borders on objects or the canvas itself when not needed.

Read the full file on GitHub · 226 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. 4d ago First seen · 226 lines · 1,930 tokens per session scan A eb8cda879be1

Subscribe to this mod's changes

fabric-js is a cursor rule published in the GitHub repository sanjeed5/awesome-cursor-rules-mdc (3,570 stars, last pushed 3mo ago), licensed CC0-1.0. It adds 1,930 tokens to every session, about $0.0097 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-09-03.