Overview
code-simplifier is an open-source code-simplification Agent that Anthropic's Claude Code team originally used internally, with public release in late 2025. It runs on Claude Opus and targets one specific problem: AI-generated code accumulates structural noise across repeated iterations, including redundant logic, inconsistent naming, excessive nesting, and stale comments. The Agent only changes how code is written, never what it does, acting like a precision surgical tool that trims AI's over-defensive habits back to human-readable aesthetics.
Key points
- The diagnosis: why AI code gets uglier over time
- *Over-defense*: AI leans "safety-first" and produces stacked null/undefined/typeof checks before reaching real logic, where a human would rely on a single type guard and early return.
- *Nested-condition stacking ("hadouken")*: each new turn adds a branch on top of existing nested ternaries, producing unreadable pyramids (active → verified → suspended).
- *Sources of structural noise*: redundant logic, inconsistent naming (camelCase/snake_case/abbreviations mixed in one file), stale comments, over-abstraction (3-line logic wrapped in 3 helpers), and nesting hell.
- What code-simplifier is
- Official Claude Code plugin/Agent from Anthropic, open-sourced late 2025 / early 2026.
- Backed by Claude Opus for strongest reasoning.
- Core rule: only the writing changes, never the behavior.
- Install via
claude plugin install code-simplifier. - What it changes vs. preserves
- Changes: redundant code, inconsistent naming within a file/function, unnecessary complexity, stale comments, and inefficient patterns when cheaper equivalents exist.
- Preserves: I/O contracts, return values, side effects, edge cases, valuable doc comments.
- How the Agent works 1. User invokes
- Core prompt emphasizes: *"Prioritize readable, explicit code over overly compact solutions."*
- The Agent is not a fixed rule set; it adapts to each project's conventions in
CLAUDE.md. - Practical refactoring examples (TypeScript)
- *Nested ternaries → flat switch/if*: a 4-level ternary computing user status becomes a named
getUserStatusfunction with early returns, preserving every status path. - *Over-defensive guards → type guard + early return*: a 30-line validator shell collapses into a single
isValidOrdercall, letting real business logic start on line 3 instead of line 30. - *Mixed naming styles → consistent camelCase verbs*:
fetch_user_data,getUserProfile,loadUserOrdersbecomefetchUserData,fetchUserProfile,fetchUserOrders. - Automation: pre-commit hook and CI/CD
- Pre-commit hook lists staged files matching
.(ts|tsx|js|jsx|py|go|rs)$, runsclaude agent code-simplifier:code-simplifier --files "$STAGED_FILES", then re-stages any modifications. - GitHub Actions workflow runs the plugin on pull requests and fails the check if
git diffis non-empty, forcing contributors to simplify locally first. - Known issues and ecosystem
- GitHub issue #36002: plugin name and Agent name both
code-simplifier, so the fully qualified name iscode-simplifier:code-simplifier;/simplifyfails to resolve via short name. - Workaround: invoke with the full qualified name.
- GitHub issue #19889: the Agent is incorrectly listed under the Skill tool and returns "Unknown skill" when invoked there; it must be called via the Task tool.
- Community ports: a Laravel/PHP version (by Taylor Otwell) aware of Laravel conventions, and a Rust version from the MCP marketplace that handles ownership patterns and idiomatic code.
- Install Laravel port:
/plugin marketplace add laravel/claude-codethen/plugin install laravel-simplifier@laravel. - Positioning vs. other tools
- ESLint/Prettier: static rule-based formatting; no AI.
- Claude Code itself: conversational, may change functionality.
- GitHub Copilot: inline completion, generates new functionality.
- code-simplifier: the only tool dedicated to cleaning structural noise from AI-generated code, using a stronger reasoning model (Opus) to audit weaker-AI output aesthetics.
- Usage guidance
- Recommended: cleanup after long sessions (e.g., 2 hours), before opening a PR, when inheriting AI-generated code, and before code review.
- Not recommended: emergency hotfixes, performance-tuned algorithms, code without test coverage, throwaway scripts.
- Best practice: install the plugin, write a
CLAUDE.mddefining function patterns (top-levelfunctionkeyword, avoid nested ternaries, prefer early returns) and naming (camelCase verbs + nouns), commit a WIP backup before running, then reviewgit diffafter simplification. - Reference links
- GitHub issues: #36002 (name collision), #19889 (Skill/Agent confusion)
- Claude Code plugin docs: https://code.claude.com/docs/en/plugins
- Official plugin repo: anthropics/claude-plugins-official
- aiproductivity.ai pre-commit guide
- claudecn.com Chinese community docs
/simplify or asks to run code-simplifier.
2. Claude Code launches the Agent on Opus.
3. Agent reads CLAUDE.md for project coding standards.
4. Agent analyzes recent edits (default scope) and identifies improvements for elegance and consistency.
5. Iterates file-by-file, focusing on one issue at a time.
6. Verifies functional equivalence.
7. Outputs simplified code plus a change summary.