clean-code-skill

clean-code-skill is a cursor rule for Cursor from KaelSensei/MagicAIBuilder. It costs 502 tokens per session, scanned A, original, MIT.

A set of code-quality rules based on Robert C. Martin’s Clean Code principles and checked with SonarCloud, a service that detects code problems. It covers duplication, function size, naming, nesting, and constants.

In plain words
What is it for?
Use it when writing or reviewing TypeScript code, extracting shared logic, naming functions, reducing nesting, and checking SonarCloud duplication results.
Why use it?
It gives the coding agent consistent standards for readable, maintainable code and helps catch repeated or overly complex logic before merging.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc). Also seen: mentions CLAUDE.md; installed under .agents/ (shared by several agents).

Good fit Use it when writing or reviewing TypeScript code, extracting shared logic, naming functions, reducing nesting, and checking SonarCloud duplication results.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/kaelsensei/magicaibuilder/clean-code-skill
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/KaelSensei/MagicAIBuilder

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 clean-code-skill

README.md
[![agentmods](https://agentmods.dev/badge/rules/kaelsensei/magicaibuilder/clean-code-skill/github.svg)](https://agentmods.dev/rules/kaelsensei/magicaibuilder/clean-code-skill)
Your own site
<a href="https://agentmods.dev/rules/kaelsensei/magicaibuilder/clean-code-skill"><img src="https://agentmods.dev/badge/rules/kaelsensei/magicaibuilder/clean-code-skill/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 clean-code-skill

Your own site · 80×15
<a href="https://agentmods.dev/rules/kaelsensei/magicaibuilder/clean-code-skill"><img src="https://agentmods.dev/badge/rules/kaelsensei/magicaibuilder/clean-code-skill.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 502 This file is loaded in full into every session.
When invoked 502 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.00502 $0.00502
Opus 5.5 $0.00201 $0.00201
Sonnet 5.5 $0.00100 $0.00100
Haiku 4.5 $0.00050 $0.00050

Measured 20d ago against content hash 800af2aabdd0, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

clean-code-skill 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 20d 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.

.agents/rules/clean-code-skill.mdc · 45 lines

How it starts

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

Clean Code rule

Based on Robert C. Martin (Clean Code) and Kent Beck (Tidy First?). The full reference is the clean-code skill; TypeScript specifics are in the typescript-craftsmanship skill.

Principles

  • Duplicated knowledge is a bug; similar-looking code is a hint. When the same business rule appears twice, move it now into the context that owns it. When code only looks alike, wait for the third occurrence and check it is the same concept.
  • One responsibility per function, component and module. A name that needs "and" asks for a split.
  • Names reveal intent and come from the glossary in CONTEXT.md.
  • Guard clauses over nested if/else. Nesting depth ≤ 3.
  • Small units. Cognitive complexity ≤ 15 per function. Components ≤ 200 lines, other files ≤ 300 lines, comments and blank lines excluded. A file already over its limit must not grow; leave it smaller when you touch it.
  • No magic values. A named constant, with a comment that gives its source.
  • No commented-out code and no console.log (use src/lib/logger.ts).
  • Comments carry information: a module header, a TSDoc contract on every export, a "why" with its source. Never a restatement of the code (docs/engineering/code-documentation.md).

Errors

  • Parse at the boundary with Zod; inside, trust the types.
  • Never swallow an error: log it, wrap it or rethrow it.
  • Expected failures are values (a discriminated union), mapped exhaustively at the edge.

Enforcement

The size and complexity limits are prose today. ESLint max-lines, max-lines-per-function and complexity, with bulk suppressions as a ratchet, are planned (docs/adr/0007-architecture-enforcement-in-stages.md). SonarCloud reports duplication and complexity; it is advisory (CLAUDE.md).

Agent behaviour

  • Do not explain unclear code with a comment: rename or extract it first.
  • Tidy in a separate structural commit, never mixed with a behaviour change.
  • Do not reformat code you are not otherwise changing.

Read the full file on GitHub · 45 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. 20d ago Changed · -16 lines · -130 tokens per session 800af2aabdd0
  2. 3mo ago First seen · 61 lines · 632 tokens per session scan A da0ba34ae3c8

Subscribe to this mod's changes

clean-code-skill is a cursor rule published in the GitHub repository KaelSensei/MagicAIBuilder (2 stars, last pushed today), licensed MIT. It adds 502 tokens to every session, about $0.0020 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-08-31.

Related

clean-code-skill compared with cursor rules from other repositories

clean-code-skill next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
clean-code-skillKaelSensei/MagicAIBuilderCursor rule2todayMITA502Cursor
ultraciteelie222/inbox-zeroCursor rule13ktodaynoneA0Cursor
server-actionskrivoox/agent-stack-templateCursor rule302mo agoMITA0Cursor
projectkrivoox/agent-stack-templateCursor rule302mo agoMITA656Cursor
ui-design-systemkrivoox/agent-stack-templateCursor rule302mo agoMITA0Cursor
performancekrivoox/agent-stack-templateCursor rule302mo agoMITA0Cursor
prisma-schemakrivoox/agent-stack-templateCursor rule302mo agoMITA0Cursor