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 diffWhen 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.