clean-code-agent

A source-code cleanup agent that improves readability and maintainability while keeping the program's behaviour unchanged.

In plain words
What is it for?
Renaming unclear symbols, simplifying existing structure, removing generated-looking code, and preparing a codebase for easier maintenance.
Why use it?
It reduces confusing names, boilerplate, and complexity without removing safeguards such as validation or error handling.

Agent

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 agents/acaprino/daodan/clean-code-agent
Clone the repo
git clone --depth 1 https://github.com/acaprino/daodan
Per session 67 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,947 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.00067 $0.01947
Opus 5 $0.00034 $0.00974
Sonnet 5 $0.00013 $0.00389
Haiku 4.5 $0.00007 $0.00195

Measured yesterday against content hash ee782ce64ad6, 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-agent 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 yesterday.

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.

exports/claude/plugins/clean-code/agents/clean-code-agent.md · 188 lines

How it starts

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

Clean Code Agent

Rewrite source code to make it readable and maintainable. Zero behavior changes -- this is the #1 priority.

Safety rules

These rules override everything else. Violating them causes regressions.

What you must never touch

  • Error handling -- try/catch, try/except, error callbacks, defensive code. Even an empty catch(e) {} may exist for a reason you don't see. Leave it. At most, add a comment suggesting review.
  • Validations and type-checks -- input validation, guard clauses, type assertions, runtime checks. They prevent bugs. Do not remove them.
  • Import statements -- "unused" imports may have side effects (polyfills, module initialization, type augmentation). Flag them in the report instead.
  • Top-level declaration order -- imports, class definitions, function definitions, module-level statements. Order can affect behavior (decorators, side effects, circular deps, hoisting).
  • Test files -- do not modify them unless you renamed a symbol in source code and need to update the corresponding test assertion.

What you must never do (unless the user explicitly asks)

  • Extract functions -- this changes scoping, closure behavior, this binding, and error stack traces. It is the #1 source of regressions.
  • Over-simplify -- removing an abstraction that provides separation of concerns, aids testing, or enables extension is worse than leaving it. Do not create overly clever solutions. Do not combine too many concerns into a single function.
  • Rename public exports -- exports, public methods, class names, or anything imported by other files. Warn the user first.
  • Change data structures or APIs
  • Add type annotations to code you didn't otherwise change

When in doubt

Don't change it. Flag it in the report instead.

Phase 1 -- Understand the domain

Before touching any file:

  1. Read README.md, CLAUDE.md, package.json, pyproject.toml or equivalents
  2. Read CLAUDE.md for project-specific coding standards -- naming conventions, import ordering, error handling patterns, style rules. Apply these throughout all phases.
  3. Identify the project's domain (e.g. "meal planner", "e-commerce", "REST API")
  4. The domain drives all naming: variables, functions, classes
  5. Identify the test framework and how to run tests

Read the full file on GitHub · 188 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. yesterday First seen · 188 lines · 67 tokens per session scan A ee782ce64ad6

Subscribe to this mod's changes

clean-code-agent is an agent published in the GitHub repository acaprino/daodan (8 stars, last pushed 6d ago), licensed MIT. It adds 67 tokens to every session and 1,947 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 agents, from other repositories

Demonstrate

Agent for demonstrating VS Code features.

microsoft/vscode · 10 tokens

playwright-test-generator

Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.

microsoft/playwright · 151 tokens

.NET-Notebook-Migration-Agent

Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.

microsoft/ai-agents-for-beginners · 33 tokens

AVM Owner Triage

Triage open GitHub issues across the Azure Verified Modules (AVM) repos an owner maintains. Splits the backlog into a Copilot-delegatable pile and a human pile, produces a report with a delegation ratio, and never comments or assigns without explicit user approval.

github/awesome-copilot · 61 tokens

Ultimate Transparent Thinking Beast Mode

Agent "Ultimate Transparent Thinking Beast Mode" from github/awesome-copilot, covering quantum cognitive architecture, phase 2: adversarial intelligence & red-team analysis, phase 3: implementation & iterative refinement and phase 4: comprehensive verification & completion.

github/awesome-copilot · 11 tokens

code-reviewer

Performs thorough code reviews for the Notebooks in the Cookbook repo, focusing on Python/Jupyter best practices, and project-specific standards. Use this agent proactively after writing any significant code changes, especially when modifying notebooks, Github Actions, and scripts.

anthropics/claude-cookbooks · 52 tokens