d3

d3 is a cursor rule for coding agents from sanjeed5/awesome-cursor-rules-mdc. It costs 3,349 tokens per session, scanned A, original, CC0-1.0.

A set of guidelines for writing D3.js version 7 or newer code for data visualisations such as charts and graphs.

In plain words
What is it for?
Use it when building D3 charts to structure the code, separate responsibilities, and choose focused module imports.
Why use it?
It helps keep visualisation code organised, efficient, easier to test, and smaller by importing only the D3 parts it needs.

Cursor rule

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,571 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.

agentmods
npx agentmods add rules/sanjeed5/awesome-cursor-rules-mdc/d3
Clone the repo
git clone --depth 1 https://github.com/sanjeed5/awesome-cursor-rules-mdc

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 d3

README.md
[![agentmods](https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/d3.svg)](https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/d3)
Your own site
<a href="https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/d3"><img src="https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/d3.svg" alt="Measured on agentmods" height="20"></a>
Per session 3,349 This file is loaded in full into every session.
When invoked 3,349 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.03349 $0.03349
Opus 5 $0.01674 $0.01674
Sonnet 5 $0.00670 $0.00670
Haiku 4.5 $0.00335 $0.00335

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

Security

Grade A, and why

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

rules-mdc/d3.mdc · 405 lines

How it starts

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

d3 Best Practices

D3.js is a powerful, low-level library for data visualization. To leverage its full potential and maintain a clean, performant codebase, adhere to these definitive guidelines.

1. Code Organization and Structure

Always structure your D3 visualizations with clear separation of concerns. This enhances readability, testability, and reusability.

1.1. Modular Imports

Import only the specific D3 modules you need. This is critical for bundle size optimization and tree-shaking.

BAD: Over-importing

// Imports the entire D3 library, increasing bundle size unnecessarily.
import * as d3 from 'd3'; 

// Or using a CDN for the full library
// <script src="https://d3js.org/d3.v7.min.js"></script>

GOOD: Targeted Imports

// Import only necessary modules for a simple bar chart
import { select } from 'd3-selection';
import { scaleLinear, scaleBand } from 'd3-scale';
import { axisBottom, axisLeft } from 'd3-axis';
import { max } from 'd3-array';

1.2. Functional Encapsulation

Organize your visualization logic into distinct, focused functions. A single function should handle data loading, another for scale creation, another for axis rendering, and so on.

// chart.js
import { select } from 'd3-selection';
import { scaleLinear, scaleBand } from 'd3-scale';
import { axisBottom, axisLeft } from 'd3-axis';
import { max } from 'd3-array';

export function createBarChart(containerSelector, data, options = {}) {
  const { width = 800, height = 500, margin = { top: 20, right: 20, bottom: 30, left: 40 } } = options;

  const innerWidth = width - margin.left - margin.right;
  const innerHeight = height - margin.top - margin.bottom;

  const svg = select(containerSelector)
    .append('svg')
    .attr('viewBox', `0 0 ${width} ${height}`) // Responsive design
    .attr('role', 'img')
    .attr('aria-label', 'Bar chart showing data distribution');

  const g = svg.append('g')
    .attr('transform', `translate(${margin.left},${margin.top})`);

  // 1. Create Scales
  const xScale = scaleBand()
    .domain(data.map(d => d.category))
    .range([0, innerWidth])
    .padding(0.1);

  const yScale = scaleLinear()
    .domain([0, max(data, d => d.value)])
    .range([innerHeight, 0]);

  // 2. Render Axes
  g.append('g')
    .attr('class', 'x-axis') // Style with CSS
    .attr('transform', `translate(0,${innerHeight})`)
    .call(axisBottom(xScale));

  g.append('g')
    .attr('class', 'y-axis') // Style with CSS
    .call(axisLeft(yScale));

  // 3. Draw Elements (Bars)
  g.selectAll('.bar')
    .data(data)
    .join('rect')
      .attr('class', 'bar')
      .attr('x', d => xScale(d.category))
      .attr('y', d => yScale(d.value))
      .attr('width', xScale.bandwidth())
      .attr('height', d => innerHeight - yScale(d.value));

  // Add labels, title, etc. as separate concerns
}

// main.js
import { createBarChart } from './chart.js';

async function init() {
  const chartData = await fetch('/api/data').then(res => res.json());
  createBarChart('#chart-container', chartData);
}

init();

Read the full file on GitHub · 405 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 · 405 lines · 0 tokens per session scan A a1a151128cd6

Subscribe to this mod's changes

d3 is a cursor rule published in the GitHub repository sanjeed5/awesome-cursor-rules-mdc (3,571 stars, last pushed 3mo ago), licensed CC0-1.0. It adds 3,349 tokens to every session, about $0.0167 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-30.

Related

Other cursor rules, from other repositories

executing-red-team-engagement-planning

Red team engagement planning is the foundational phase that defines scope, objectives, rules of engagement (ROE), threat model selection, and operational timelines before any offensive testing begins.

galyarderlabs/galyarder-framework · 34 tokens

solana-integration-constraints

Constraints and requirements for Solana integration with MetaMask Connect — wallet adapter config, CAIP-2 IDs, network support per platform, RPC routing, and platform limitations.

MetaMask/metamask-connect-cursor-plugin · 1,207 tokens

visual-and-observational-rules

Defines the visual aspects of the game and how the player observes the world. This includes map color-coding, screen effects, and the overall simulation style.

paulpham157/paul-s-cursor-rules · 0 tokens

018_DSPy_InputField_OutputField

DSPy 3.0.1 Field Definitions - Master InputField and OutputField for precise signature control.

AIFlowML/cursor_rules · 21 tokens

solana_core_architecture

┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐ │ Entry Point │ │ Instruction │ │ Account │ │ lib.rs │───▶│ Processing │───▶│ Validation │ │ │ │ │ │ │ │ - entrypoint! │ │ - Route dispatch │ │ - Owner checks │ │ - processinst │ │ - Deserialize │ │ - Data validate │.

AIFlowML/cursor_rules · 4 tokens

elizaos_v2_onchain_plugins

┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐ │ Wallet Provider│ │ Connection Mgmt │ │ Transaction Svc │ │ - Private Keys │───▶│ - RPC Endpoints │───▶│ - Tx Construction│ │ - Public Keys │ │ - Network Config │ │ - Fee Estimation│ │ - Signatures │ │ - Health Check │ │ - Broadcasting │ └─────────────────┘…

AIFlowML/cursor_rules · 0 tokens