clean-code

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

A guided command for removing unnecessary code from a project. It targets items such as unused variables, dead code, duplicate logic, and debug statements while checking the project's rules and documentation.

In plain words
What is it for?
Use /clean-code with an optional file or folder target to review the whole codebase or focus cleanup on a specific area.
Why use it?
It helps reduce clutter and technical debt, meaning code that makes future changes harder. Cleaning these items can make the codebase easier to read and maintain.

Command for Claude Code

Written for Claude Code: a Claude Code command (commands/*.md). Also seen: installed under .agents/ (shared by several agents); mentions Cursor.

Good fit Use /clean-code with an optional file or folder target to review the whole codebase or focus cleanup on a specific area.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/kaelsensei/magicaibuilder/clean-code
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: Claude Code.

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

Your own site · 80×15
<a href="https://agentmods.dev/commands/kaelsensei/magicaibuilder/clean-code"><img src="https://agentmods.dev/badge/commands/kaelsensei/magicaibuilder/clean-code.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 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,783 The whole file, excluding the scripts and references it only reads on demand.
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.00000 $0.01783
Opus 5.5 $0.00000 $0.00713
Sonnet 5.5 $0.00000 $0.00357
Haiku 4.5 $0.00000 $0.00178

Measured 1mo ago against content hash e870559cd6fe, 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 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 1mo 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/commands/clean-code.md · 228 lines

How it starts

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

Clean Code Command – Code Cleanup and Technical Debt Removal

When /clean-code [target] is invoked, immediately execute the following steps to remove redundant code, unused variables, dead code, debug statements, and other technical debt.


Step 1: Load Project Context

  1. Assume the project root as the working directory
  2. Load and strictly follow ALL Cursor rules from .cursor/rules/*.mdc:
    • security.mdc - Security requirements
    • technical-stack.mdc - React Native/SQLite patterns
    • documentation.mdc - Documentation update requirements
    • version-management.mdc - Git commit/push workflow
  3. Read relevant documentation:
    • README.md
    • PROGRESS.md
    • Architecture documents
  4. Identify the current Git branch and assume it is a refactor branch, not main
  5. Determine the cleanup scope:
    • If no target specified: analyze entire codebase for cleanup opportunities
    • If target specified: focus on specific files/directories (e.g., src/screens/DeckDetailScreen.tsx, src/db/)

Step 2: Understand the Cleanup Scope

  1. Parse the target provided after /clean-code (if any)
  2. Identify cleanup opportunities:
    • Unused imports - Remove imports that are not used
    • Unused variables/state - Remove variables, refs, or state that are never read
    • Dead code - Remove code paths that are unreachable
    • Duplicate code - Identify and consolidate duplicate logic
    • Redundant code - Remove code that does the same thing multiple times
    • Debug statements - Remove console.log, console.debug, console.warn (unless intentional)
    • Commented-out code - Remove old commented code blocks
    • Unused functions - Remove functions that are never called
    • Unnecessary dependencies - Remove dependencies from hooks/useMemo that don't affect the result
    • Overly complex logic - Simplify unnecessarily complex expressions
  3. Do NOT remove:
    • Code that appears unused but is actually used (e.g., via dynamic imports, reflection)
    • Intentional debug logging for production debugging
    • Code that is temporarily disabled for a specific reason
    • Type definitions that improve type safety

Read the full file on GitHub · 228 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. 1mo ago First seen · 228 lines · 0 tokens per session scan A e870559cd6fe

Subscribe to this mod's changes

clean-code is a command published in the GitHub repository KaelSensei/MagicAIBuilder (2 stars, last pushed today), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,783 tokens. 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.