ruff

ruff is a cursor rule for Cursor from nedcodes-ok/cursorrules-collection. It costs 555 tokens per session, scanned A, original, MIT.

A set of coding rules for Ruff, a Python tool that checks code style and can format code automatically. It covers configuration, selected checks, formatting, imports, and fixes.

In plain words
What is it for?
Use it to configure Python linting and formatting, sort imports, choose project rules, and run a standard fix-and-format workflow.
Why use it?
It helps teams apply the same style rules and catch common code problems before they spread through a project.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc). Also seen: mentions Cursor.

Good fit Use it to configure Python linting and formatting, sort imports, choose project rules, and run a standard fix-and-format workflow.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/nedcodes-ok/cursorrules-collection/ruff
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/nedcodes-ok/cursorrules-collection

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 ruff

README.md
[![agentmods](https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/ruff/github.svg)](https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/ruff)
Your own site
<a href="https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/ruff"><img src="https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/ruff/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 ruff

Your own site · 80×15
<a href="https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/ruff"><img src="https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/ruff.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 555 This file is loaded in full into every session.
When invoked 555 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.00555 $0.00555
Opus 5.5 $0.00222 $0.00222
Sonnet 5.5 $0.00111 $0.00111
Haiku 4.5 $0.00056 $0.00056

Measured 2mo ago against content hash 734f16963d36, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

ruff 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 2mo 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/tools/ruff.mdc · 45 lines

What it actually says

Ruff Cursor Rules

You are an expert in Ruff Python linting and formatting. Follow these rules:

Configuration

  • Configure in pyproject.toml [tool.ruff] or standalone ruff.toml — not both
  • Set target-version = "py312" (or your minimum Python version) explicitly
  • Set line-length = 88 (Black default) or 120 — be explicit, don't rely on default
  • Use src = ["src"] to help Ruff resolve first-party imports correctly

Rule Selection

  • Start with select = ["E", "F", "W", "I", "UP", "B", "SIM", "N"] for a solid baseline
  • Add "S" (bandit) for security, "PT" for pytest style, "D" for docstrings as needed
  • Use ignore sparingly and document why: ignore = ["E501"] # handled by formatter
  • Use per-file-ignores for test/migration exceptions: {"tests/" = ["S101"], "migrations/" = ["E501"]}

Formatting

  • Use ruff format as a drop-in Black replacement — same output, faster
  • Don't mix Ruff formatter with Black — pick one
  • Set format.quote-style = "double" and format.indent-style = "space" explicitly
  • Use ruff check --fix && ruff format for the standard fix-then-format workflow

Import Sorting

  • Enable isort rules with "I" in select — Ruff replaces isort entirely
  • Configure [tool.ruff.isort] for known-first-party, known-third-party if needed
  • Use force-single-line = true if your team prefers one import per line
  • Set combine-as-imports = true to group aliased imports

Integration

  • Run in CI: ruff check . && ruff format --check .
  • Use --fix only in local development, never in CI (CI should fail, not auto-fix)
  • Pre-commit hook: use ruff-pre-commit (official) — not generic pre-commit hooks
  • VS Code: install charliermarsh.ruff extension, disable pylint/flake8/isort extensions

Noqa & Suppression

  • Use inline # noqa: RULE_CODE with specific codes — never bare # noqa
  • Use per-file-ignores over blanket noqa comments when an entire file needs exceptions
  • Run ruff check --statistics to see which rules fire most — fix patterns, not symptoms
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. 2mo ago First seen · 45 lines · 555 tokens per session scan A 734f16963d36

Subscribe to this mod's changes

ruff is a cursor rule published in the GitHub repository nedcodes-ok/cursorrules-collection (38 stars, last pushed 9mo ago), licensed MIT. It adds 555 tokens to every session, about $0.0022 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-09-03.

Related

ruff compared with cursor rules from other repositories

ruff next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
ruffnedcodes-ok/cursorrules-collectionCursor rule389mo agoMITA555Cursor
pythonnedcodes-ok/cursor-lint-rulesCursor rule19mo agononeA123Cursor
cursorrulessurvivorforge/cursor-rulesCursor rule197mo agoMITA2,136Cursor
10-backend-fastapiaiagentwithdhruv/ai-dev-stackCursor rule115mo agoMITA0Cursor
12-naming-conventionsorbitalsonic/AndroidPilotCursor rule11mo agononeA0Cursor
06-coroutines-floworbitalsonic/AndroidPilotCursor rule11mo agononeA0Cursor
05-kotlinorbitalsonic/AndroidPilotCursor rule11mo agononeA0Cursor