# code-simplifier — Anthropic Official Cleanup Subagent > Anthropic's open-source post-task cleanup agent that Boris Cherny runs after every Claude Code session. Refactors for clarity without changing behavior. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: # code-simplifier — Anthropic Official Cleanup Subagent ## Quick Use Option A — CLI install (recommended): ```bash claude plugin install code-simplifier ``` Option B — From inside a Claude Code session: ``` /plugin marketplace update claude-plugins-official /plugin install code-simplifier ``` After a long coding session, tell Claude: > "Run the code-simplifier on what you just changed." Claude invokes the subagent and refactors the recently modified files in place. --- ## Intro code-simplifier is the official Anthropic-published subagent that Boris Cherny (Claude Code's creator) runs after almost every Claude Code session — its job is to clean up Claude's freshly-written code without changing behavior. Anthropic open-sourced it from the internal Claude Code team's own setup in late 2025. It runs on Opus, focuses on recently modified files by default, and reviews for clarity, consistency, and maintainability. Functionality is preserved exactly — original outputs, public APIs, and edge-case handling all stay intact. Best for: cleanup pass after a long feature-build session. Works with Claude Code 1.x and above. --- ## How code-simplifier Works Boris Cherny, Threads (@boris_cherny, post DTBVroqEg_K): > "I use a few subagents regularly: code-simplifier simplifies the code after Claude is done working, verify-app has detailed instructions for testing Claude Code end to end, and so on. Similar to slash commands, I think of subagents as automating the most common workflows that I do for most PRs." ### What it actually does | Pass | Action | |---|---| | 1. Identify | Looks at files changed in the current session (or files you point it at) | | 2. Refactor | Removes duplication, simplifies conditionals, names things better, deletes dead code | | 3. Preserve | Never changes the public surface area, return values, or observable behavior | | 4. Report | Lists what was simplified and why, so you can review the diff before commit | ### Typical session flow ``` You: "Implement the multi-tenant audit log feature." Claude: ... (writes 4 files, ~600 lines) You: "Now run the code-simplifier on what you just changed." Claude: -> invokes code-simplifier subagent -> reviews 4 files -> commits cleanup as a separate diff ``` ### When to use - End of any session where Claude wrote >100 lines - Before opening a PR — separates "feature commit" from "cleanup commit" - After /loop or /ralph-loop runs (long sessions accumulate cruft) - Avoid mid-feature — let Claude finish the implementation first - Avoid on code you didn't write in this session (it's optimized for recently modified files) ### Why Boris ships with it on every PR From his Threads post: he treats subagents the same way he treats slash commands — "automating the most common workflows that I do for most PRs." code-simplifier is one of the two he names by name (the other is verify-app). --- ## Example session ``` User: Build a function that takes a list of users, filters out inactive ones, sorts by created_at desc, and returns the top 10. Claude: [writes a 25-line implementation with nested filters and a temp variable] User: Run code-simplifier on it. code-simplifier: Refactored to a single chained pipeline. - Removed temp variable filtered_users - Replaced lambda x: x.active == True with attrgetter('active') - Inlined the sort key Behavior preserved: same input -> same output, verified against the existing tests. ``` --- ## FAQ **Q: What is code-simplifier?** A: An Anthropic-published Claude Code subagent that cleans up code Claude just wrote — refactoring for clarity and consistency while preserving exact behavior. Open-sourced from the internal Claude Code team's own setup. **Q: Is code-simplifier free?** A: Yes, free and open source via Anthropic's `claude-plugins-official` marketplace. You only pay for Claude API tokens used during the cleanup pass (it runs on Opus, so factor that in). **Q: How do I install code-simplifier?** A: Run `claude plugin install code-simplifier` in your terminal, or `/plugin install code-simplifier` from inside a Claude Code session after `/plugin marketplace update claude-plugins-official`. **Q: Will it change my code's behavior?** A: No. The agent's contract is to never change observable behavior — only how the code is structured. Public APIs, return values, and side effects all stay the same. **Q: When should I run it?** A: At the end of a long coding session, before opening a PR. Don't run it mid-feature — wait until the implementation is functionally complete, then have it cleanup pass over what was changed. --- ## Source & Thanks > Built and open-sourced by [Anthropic](https://github.com/anthropics) — extracted from the internal Claude Code team's daily workflow. > > [Boris Cherny's open-source announcement on X](https://x.com/bcherny/status/2009450715081789767) Used daily by Boris Cherny (Claude Code creator) and the Anthropic Claude Code team on every PR. --- Source: https://tokrepo.com/en/workflows/code-simplifier-anthropic-official-cleanup-subagent-1304ff4c Author: Skill Factory