code-quality

Rules for writing and refactoring production code, covering readable functions, naming, error handling, security, and the use of development tools.

In plain words
What is it for?
They are for setting coding standards, reviewing changes, simplifying logic, handling errors safely, and avoiding common implementation mistakes.
Why use it?
They prevent common defects and review issues by giving developers practical defaults for code that is easier to understand and maintain.

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/sordi-ai/skill-everything/code-quality
Clone the repo
git clone --depth 1 https://github.com/sordi-ai/skill-everything

Made for: Cursor.

Per session 31 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,447 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00031 $0.01447
Opus 5 $0.00015 $0.00724
Sonnet 5 $0.00006 $0.00289
Haiku 4.5 $0.00003 $0.00145

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

Security

Grade A, and why

code-quality scanned grade A with 1 finding 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

17. **SHOULD: External dependencies only in dedicated adapter files.** No direct `axios.get()` in business logic — always wrap through an interface.
.cursor/rules/code-quality.mdc · 80 lines

How it starts

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

Sub-Skill: Code Quality & Common Mistakes

Purpose: Prevents the 20 % of mistakes that cause 80 % of review comments. Concrete rules from real projects — no boilerplate.

Rule classification

  • MUST — load-bearing. Violating causes bugs, security issues, or cross-team confusion. Never break.
  • SHOULD — default behavior. Deviation needs a documented reason in the code or PR.
  • AVOID — usually wrong; documented exception inline where needed.

Where these rules don't strictly apply: test fixtures, generated code (parser tables, codegen output, schema-derived types), CLI bootstrap scripts, framework adapters, and migration scripts may legitimately differ. The rules below apply to production code paths unless an inline exception says otherwise.


Rules

Functions & Logic

  1. SHOULD: Functions under ~30 lines. Longer → split where practical. Reduces cognitive load.
  2. AVOID: Boolean as last argument. render(true) is unreadable. Use enum or named-property: render({ withHeader: true }).
  3. SHOULD: Early return over nested if-blocks. Nesting depth > 2 is a warning sign.
  4. SHOULD: No magic numbers. if (status === 3)if (status === OrderStatus.SHIPPED).
  5. AVOID: Double negation. if (!isNotValid)if (isValid).

Variables & Naming

  1. SHOULD: Variable names describe content, not type. userList instead of arr, activeUserId instead of id.
  2. SHOULD: Temporary variables for complex expressions. const isEligible = age >= 18 && !isBanned; instead of cramming it all into an if.
  3. AVOID: Abbreviations except established ones (id, url, ctx, req, res). usr, cfg, tmp → spell out.

Error Handling

  1. MUST: Every async call needs try/catch or .catch(). Unhandled promise rejections crash Node processes.
  2. MUST: Never silently swallow error objects. catch (e) {} is forbidden. At minimum: logger.warn(e).
  3. MUST: Error messages must include context. throw new Error('User not found: ' + userId) not throw new Error('Not found').
  4. SHOULD: Catch specific exception types, not broad categories. Catch ConnectionError not Exception. Broad catches mask unrelated bugs and make debugging harder.
  5. SHOULD: Use exponential backoff with jitter for retry logic. Never retry in a tight loop. Each retry should wait longer than the last with randomization to prevent thundering herds.
  6. MUST: Never retry non-idempotent operations without explicit safeguards. A retried POST that creates a resource can produce duplicates. Use idempotency keys or check-before-retry patterns.
  7. SHOULD: Propagate errors with context rather than swallowing and re-raising generic exceptions. Use raise NewError("context") from original_error to preserve the chain. Reference: ERR-2026-016.

Read the full file on GitHub · 80 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 · 80 lines · 31 tokens per session scan A b192d8795ae4

Subscribe to this mod's changes

code-quality is a cursor rule published in the GitHub repository sordi-ai/skill-everything (19 stars, last pushed 3mo ago), licensed MIT. It adds 31 tokens to every session and 1,447 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.