cursorrules

cursorrules is a cursor rule for Cursor from usamaijazmughal/code-diagram. It costs 3,268 tokens per session, scanned A, original, MIT.

A set of project rules for analyzing code and generating Mermaid diagrams, which are text-based diagrams, from files, folders, line ranges, or pasted code.

In plain words
What is it for?
Use it when documenting classes, sequences, components, or architecture from one or more code locations.
Why use it?
It provides a consistent way to inspect code structure and choose the right diagram scope and level of detail.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when documenting classes, sequences, components, or architecture from one or more code locations.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/usamaijazmughal/code-diagram/cursorrules
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/usamaijazmughal/code-diagram

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 cursorrules

README.md
[![agentmods](https://agentmods.dev/badge/rules/usamaijazmughal/code-diagram/cursorrules/github.svg)](https://agentmods.dev/rules/usamaijazmughal/code-diagram/cursorrules)
Your own site
<a href="https://agentmods.dev/rules/usamaijazmughal/code-diagram/cursorrules"><img src="https://agentmods.dev/badge/rules/usamaijazmughal/code-diagram/cursorrules/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for cursorrules

Your own site · 80×15
<a href="https://agentmods.dev/rules/usamaijazmughal/code-diagram/cursorrules"><img src="https://agentmods.dev/badge/rules/usamaijazmughal/code-diagram/cursorrules.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 3,268 This file is loaded in full into every session.
When invoked 3,268 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.03268 $0.03268
Opus 5.5 $0.01307 $0.01307
Sonnet 5.5 $0.00654 $0.00654
Haiku 4.5 $0.00327 $0.00327

Measured 1mo ago against content hash acf8e190bbe5, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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/.cursorrules · 241 lines

How it starts

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

Code Diagram Generator v1.2.0

When the user asks you to generate diagrams, analyze code structure, or visualize architecture, follow this analysis pipeline. Use terminal commands (rg, find, cat) for all file operations.

Input modes

Extract from the user's message and detect which mode applies (check in order):

Mode When Example
Multi-path User mentions multiple files/directories "Analyze lib/auth and lib/payments together"
Line range User specifies line numbers "Diagram lines 10-50 of bloc.dart"
Single file User points at one file "Analyze auth_bloc.dart"
Directory User points at a directory "Analyze lib/features/payments"
Pasted code User pastes raw code "Diagram this: class Foo { ... }"

Also extract flags (can appear in any order in the user's request):

  • DIAGRAM_TYPE — class, sequence, component, arch, or all (default: all)
  • FLOW_MODE — full or split (default: full)
  • DETAIL_LEVEL — if user says "rich" or "with details" or "show endpoints" → rich. Otherwise → method-names (default, secure)
  • EFFORT_LEVEL — low, medium (default), max, or effort=VALUE (explicit form)
    • low: 10 reads, 5-hop trace
    • medium: 20 reads, 12-hop trace (default)
    • max: no read cap, unlimited trace, no auto-decompose split
    • Abstract resolution + mixin tracking are ALWAYS active at all levels

File type validation

If the target is a single file, check its extension: .dart, .ts, .tsx, .js, .jsx, .py, .kt, .java, .go, .swift, .rs, .svelte. If unsupported, tell the user: "Unsupported file type. Please point at a source code file or directory."

Multi-path mode

When multiple targets are provided, budget per target is from EFFORT_LEVEL: low=10, medium=20, max=unlimited. Process each target independently, then check for cross-path imports to draw connections between subgraphs.

Line range mode

When user specifies lines (e.g., "lines 10-50 of file.dart"), read only that range. Note in output that entities outside the range are not shown.

Read the full file on GitHub · 241 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. 1mo ago First seen · 241 lines · 3,268 tokens per session scan A acf8e190bbe5

Subscribe to this mod's changes

cursorrules is a cursor rule published in the GitHub repository usamaijazmughal/code-diagram (2 stars, last pushed 6mo ago), licensed MIT. It adds 3,268 tokens to every session, about $0.0131 per session on Opus 5.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.