clean-principles / rules
Cursor rule0 starsChanged 29 days agoMITView on GitHub
Clean Principles — SOLID, Clean Code, DRY/KISS/YAGNI, Design Patterns, Architecture, Testing, Clarify Before Build.
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 4,183 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository9 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- architecture-principlesSkill
- clarify-before-buildSkill
- clean-codeSkill
- design-patternsSkill
- dry-kiss-yagniSkill
- solid-principlesSkill
- testing-principlesSkill
The file
We split this clean-principles.mdc into the rules it gives an agent
12 rules. About 0 are common, 9 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
If a user request contains ambiguous scope terms (e.g., "simple", "quick", "basic", "clean", "production-ready"):
- Distinctive: line 14
Ask 1–2 targeted clarifying questions before writing code, OR
- Distinctive: line 18
≤ 3 parameters: Use parameter object / dataclass if more are required.
- Distinctive: line 21
Small & focused: Must fit comfortably on one screen.
- Very specific: line 26
Avoid junk drawer files (utils.ts, helpers.py, Common.java).
- Distinctive: line 29
Write for humans first, compiler second.
- Distinctive: line 31
No clever one-liners; self-documenting conditionals.
- Distinctive: line 37
No commented-out code: Delete dead code immediately.
- Very specific: line 40
Catch specific exceptions only: Never catch bare Exception or except:.
- Distinctive: line 45
YAGNI: No unrequested abstractions or premature generalization.
- Very specific: line 53
Do NOT rely on internal model memory alone.
- Distinctive: line 63
Before outputting code, verify:
≈ “Common” is an estimate: at least 1 in 5 of the 6,668 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
--- description: Clean Principles — SOLID, Clean Code, DRY/KISS/YAGNI, Design Patterns, Architecture, Testing, Clarify Before Build. globs: * alwaysApply: true --- # Clean Principles — Active Coding Standards & Quality Gates > **STATUS: ALWAYS ACTIVE ON EVERY PROMPT & CODE TASK** > This ruleset governs all code generation, refactoring, architecture, and review across every session. ## 1. Ambiguity Gate (Clarify Before Build) If a user request contains ambiguous scope terms (e.g., "simple", "quick", "basic", "clean", "production-ready"): - Ask 1–2 targeted clarifying questions before writing code, OR - Explicitly state the minimal assumptions chosen before providing code. Read `skills/clarify-before-build/SKILL.md`. ## 2. Functions & Methods - **≤ 3 parameters**: Use parameter object / dataclass if more are required. - **Single Responsibility (SRP)**: One task per function. If it needs "and" to describe, split it. - **No boolean flag parameters**: Split into separate explicit functions (e.g. `sendSync()` / `sendAsync()`). - **Small & focused**: Must fit comfortably on one screen. - **No hidden side effects**: Functions do what their name promises and nothing else. ## 3. File Sizing & Modularity - **≤ 300 lines per file** (soft limit 200, hard limit 400). - Avoid junk drawer files (`utils.ts`, `helpers.py`, `Common.java`). ## 4. Human-Readable Code (Senior 10+ YoE Standard) - Write for humans first, compiler second. - Guard clauses over nested `if/else` (max indentation level ≤ 2). - No clever one-liners; self-documenting conditionals. - Command-Query Separation (CQS). ## 5. Code Quality & Hygiene - **Intention-revealing names**: Verb phrases for functions (`calculateTax`), noun phrases for classes (`TaxCalculator`). No cryptic abbreviations. - **No magic numbers or strings**: Extract to named constants. - **No commented-out code**: Delete dead code immediately. - **Comments explain WHY, not WHAT**: The code explains what is happening. - **No null/nil/None returns for collections**: Return empty arrays/lists/sets/maps. - **Catch specific exceptions only**: Never catch bare `Exception` or `except:`. ## 6. Design Principles - **DRY**: One source of truth per business rule. - **KISS**: Simple over clever. - **YAGNI**: No unrequested abstractions or premature generalization. - **SOLID**: Enforce Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion. ## 7. Ecosystem Idioms & Conventions - Native-feeling code for the target language and framework. - Respect local toolchain configs (`tsconfig.json`, `phpstan.neon`, `.eslintrc`, `pyproject.toml`). ## 8. Mandatory Full-Skill Reading (Read Full Skill When Needed) Do NOT rely on internal model memory alone. Read the full `SKILL.md` before coding when the task involves: - Scope ambiguity: `skills/clarify-before-build/SKILL.md` - Classes / Interfaces / OOP: `skills/solid-principles/SKILL.md` - Architecture / Layers: `skills/architecture-principles/SKILL.md` - Testing / Mocks / TDD: `skills/testing-principles/SKILL.md` - Design Patterns: `skills/design-patterns/SKILL.md` - Pruning bloat / DRY / YAGNI: `skills/dry-kiss-yagni/SKILL.md` - Readability / Naming: `skills/clean-code/SKILL.md` ## 9. Verification Gate Before outputting code, verify: 1. Does every function have ≤ 3 parameters? 2. Is each function's purpose explainable in a single sentence? 3. Are there magic numbers or unrequested abstractions? 4. Is any file exceeding 300 lines or any function nested more than 2 levels deep?
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

