agentleFS
Khuirul-HudaKhuirul-Huda/clean-principles/.cursor/rules/clean-principles.mdc

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.

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
  1. Distinctive:

    If a user request contains ambiguous scope terms (e.g., "simple", "quick", "basic", "clean", "production-ready"):

    line 13
  2. Distinctive:

    Ask 1–2 targeted clarifying questions before writing code, OR

    line 14
  3. Distinctive:

    ≤ 3 parameters: Use parameter object / dataclass if more are required.

    line 18
  4. Distinctive:

    Small & focused: Must fit comfortably on one screen.

    line 21
  5. Very specific:

    Avoid junk drawer files (utils.ts, helpers.py, Common.java).

    line 26
  6. Distinctive:

    Write for humans first, compiler second.

    line 29
  7. Distinctive:

    No clever one-liners; self-documenting conditionals.

    line 31
  8. Distinctive:

    No commented-out code: Delete dead code immediately.

    line 37
  9. Very specific:

    Catch specific exceptions only: Never catch bare Exception or except:.

    line 40
  10. Distinctive:

    YAGNI: No unrequested abstractions or premature generalization.

    line 45
  11. Very specific:

    Do NOT rely on internal model memory alone.

    line 53
  12. Distinctive:

    Before outputting code, verify:

    line 63

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
clean-principles.mdc
---
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?

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.