cursorrules

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

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/usamaijazmughal/code-diagram/cursorrules
Clone the repo
git clone --depth 1 https://github.com/usamaijazmughal/code-diagram

Made for: Cursor.

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. 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.03268 $0.03268
Opus 5 $0.01634 $0.01634
Sonnet 5 $0.00654 $0.00654
Haiku 4.5 $0.00327 $0.00327

Measured 2d ago against content hash acf8e190bbe5, 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.

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_TYPEclass, sequence, component, arch, or all (default: all)
  • FLOW_MODEfull or split (default: full)
  • DETAIL_LEVEL — if user says "rich" or "with details" or "show endpoints" → rich. Otherwise → method-names (default, secure)
  • EFFORT_LEVELlow, 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. 2d 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 4mo ago), licensed MIT. It adds 3,268 tokens to every session, about $0.0163 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.