clean-code

clean-code is a skill for Claude Code, Codex from KaelSensei/MagicAIBuilder. It costs 60 tokens per session (1,529 once invoked), scanned A, original, MIT.

A set of clean-code guidelines tailored to TypeScript, React, and Next.js projects. It focuses on avoiding duplicated logic, keeping functions focused, and making names reveal their purpose.

In plain words
What is it for?
Use it before adding code, while refactoring, after SonarCloud reports duplication, or when reviewing a pull request.
Why use it?
It helps prevent copy-pasted code and complicated modules that are harder to test or change.

Skill for Claude CodeCodex

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 skills/kaelsensei/magicaibuilder/clean-code
Any agent
npx skills add KaelSensei/MagicAIBuilder --skill clean-code
Clone the repo
git clone --depth 1 https://github.com/KaelSensei/MagicAIBuilder

Made for: Claude Code, Codex.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/kaelsensei/magicaibuilder/clean-code.svg)](https://agentmods.dev/skills/kaelsensei/magicaibuilder/clean-code)
Your own site
<a href="https://agentmods.dev/skills/kaelsensei/magicaibuilder/clean-code"><img src="https://agentmods.dev/badge/skills/kaelsensei/magicaibuilder/clean-code.svg" alt="Measured on agentmods" height="20"></a>
Per session 60 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,529 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. 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.00060 $0.01529
Opus 5 $0.00030 $0.00764
Sonnet 5 $0.00012 $0.00306
Haiku 4.5 $0.00006 $0.00153

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

Security

Grade A, and why

clean-code 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 3d 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/skills/clean-code/SKILL.md · 121 lines

How it starts

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

Clean Code Skill

Practical reference for writing and refactoring code in this repo. The baseline is Robert C. Martin's Clean Code, adapted to TypeScript + React + Next.js App Router and to this project's actual code quality gates (SonarCloud).

When to use this skill

  • Before writing a new module, component, hook, or API route.
  • When SonarCloud flags duplicated_lines_density, duplicated_blocks, or the "Critical Issues" bucket on a file touched by your PR.
  • During a /refactor or /clean-code command invocation.
  • When reviewing a PR that looks "copy-pasted from elsewhere" — pair this with /audit-code.

Non-negotiable rules

  1. DRY — Don't Repeat Yourself. Two or more copies of the same logic is one bug with several homes. Extract the moment duplication is conscious.
  2. SRP — one responsibility per function / component / module. If you say "and" describing what it does, split it.
  3. Names reveal intent. getFilteredDeckCards beats process. Renaming a variable should never be the reason the code becomes clear.
  4. Early returns. Prefer guard clauses over nested if/else. Max nesting depth: 3.
  5. Small functions. Cognitive complexity ≤ 15 (Sonar default). A function you cannot hold in your head at once is too big.
  6. No commented-out code. Git keeps history. Delete it.
  7. No magic values. Named constants in constants/ with a JSDoc @example when useful.

DRY — concrete techniques for this repo

1. Detecting duplication

  • Sonar: the duplication dashboard lists exact duplicated blocks with file paths. Start there. https://sonarcloud.io/component_measures?id=KaelSensei_MagicAIBuilder&metric=duplicated_lines_density&view=list
  • Manually: after writing code, search for two or three distinctive identifiers (a literal string, a specific .reduce shape) via Grep across the repo.
  • Ask yourself: "If this business rule changes, how many files would I edit?" — answer ≥ 2 is a smell.

Read the full file on GitHub · 121 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. 3d ago First seen · 121 lines · 60 tokens per session scan A 630551dc6448

Subscribe to this mod's changes

clean-code is a skill published in the GitHub repository KaelSensei/MagicAIBuilder (2 stars, last pushed 4d ago), licensed MIT. It adds 60 tokens to every session and 1,529 once invoked, about $0.0003 per session on Opus 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

Other skills, from other repositories

organization-best-practices

Configure multi-tenant organizations, manage members and invitations, define custom roles and permissions, set up teams, and implement RBAC using Better Auth's organization plugin. Use when users need org setup, team management, member roles, access control, or the Better Auth organization plugin.

krivoox/agent-stack-template · 61 tokens

changelog-automation

Automate changelog generation from commits, PRs, and releases following Keep a Changelog format. Use when setting up release workflows, generating release notes, or standardizing commit conventions.

krivoox/agent-stack-template · 42 tokens

react-hook-form

React Hook Form performance optimization for client-side form validation using useForm, useWatch, useController, useFieldArray, and the v7.55+ subscribe() API. This skill should be used when building client-side controlled forms with React Hook Form library. This skill does NOT cover React 19 Server Actions…

krivoox/agent-stack-template · 85 tokens

vibe-spec

Spec-driven development workflow plus a production-tested full-stack reference (Next.js 16, Prisma, PostgreSQL, Auth.js/OTP, RBAC, dbt, Zod, Vitest, shadcn/ui, S3, Web Push, GitHub Actions, Vercel). Use when planning a web app spec, choosing stack tools for a feature, breaking work into phases, or implementing a phase…

Connorrmcd6/vibe-spec · 109 tokens

shadcn

Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn/ui, component registries, presets, --preset codes, or any project with a components.json…

krivoox/agent-stack-template · 94 tokens

vercel-react-best-practices

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance…

krivoox/agent-stack-template · 67 tokens