.fyi
SkillsMCPPluginsSubagents

Browse by category

DevOps & CI/CD SkillsProductivity & Workflow SkillsOther SkillsProduct & Project Management SkillsDocumentation & Knowledge SkillsCode Review & Refactor SkillsBackend & APIs SkillsAgent Meta & Communication SkillsResearch SkillsSecurity SkillsUX UI & Design SkillsTesting & QA SkillsSee all →

Every Claude Code skill, MCP server, plugin and subagent in one directory. Searchable, comparable, and one command from installed. Live stats from GitHub, npm and PyPI.

We're on Product HuntYour agent's app storeCheck it out →
Agent SkillsMCP ServersPluginsSubagentsCoding Agents
CollectionsOfficial publishersGlossaryFAQBlogSearchSavedFeedback
PrivacyTermsllms.txtSitemap

made with ♥ · © 2026 aaaa.fyi

Independent project · real data from public registries

…/agent-skills/code-simplification
home/skills/addyosmani/agent-skills/code-simplification
addyosmani avatar

code-simplification

byaddyosmani· 31 skills

Installs

16k

Stars

80k

Forks

8.7k

Category

Code Review & Refactor

View on GitHub

TL;DR

Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.

How to install code-simplification?

addyosmani/agent-skills/code-simplification
$npx -y skills add addyosmani/agent-skills --skill code-simplification

Installs into the current project.

›Prefer a prompt? Paste this to your agent

Use this skill

Run `npx skills use "https://github.com/addyosmani/agent-skills" --skill "addyosmani/agent-skills/code-simplification"` and follow the generated skill instructions now. Read its complete output, redirecting it to a temporary file first if necessary. Resolve relative paths from the supporting-files directory it provides.

Use the whole pack

Use the skills in "https://github.com/addyosmani/agent-skills" that are relevant to the current task. Run `npx skills add "https://github.com/addyosmani/agent-skills"` and select the relevant skills, then follow their instructions.

Files · 1

View on GitHub
SKILL.md
1# Code Simplification
2 
3> Inspired by the [Claude Code Simplifier plugin](https://github.com/anthropics/claude-plugins-official/blob/main/plugins/code-simplifier/agents/code-simplifier.md). Adapted here as a model-agnostic, process-driven skill for any AI coding agent.
4 
5## Overview
6 
7Simplify code by reducing complexity while preserving exact behavior. The goal is not fewer lines — it's code that is easier to read, understand, modify, and debug. Every simplification must pass a simple test: "Would a new team member understand this faster than the original?"
8 
9## When to Use
10 
11- After a feature is working and tests pass, but the implementation feels heavier than it needs to be
12- During code review when readability or complexity issues are flagged
13- When you encounter deeply nested logic, long functions, or unclear names
14- When refactoring code written under time pressure
15- When consolidating related logic scattered across files
16- After merging changes that introduced duplication or inconsistency
17 
18**When NOT to use:**
19 
20- Code is already clean and readable — don't simplify for the sake of it
21- You don't understand what the code does yet — comprehend before you simplify
22- The code is performance-critical and the "simpler" version would be measurably slower
23- You're about to rewrite the module entirely — simplifying throwaway code wastes effort
24 
25## The Five Principles
26 
27### 1. Preserve Behavior Exactly
28 
29Don't change what the code does — only how it expresses it. All inputs, outputs, side effects, error behavior, and edge cases must remain identical. If you're not sure a simplification preserves behavior, don't make it.
30 
31```
32ASK BEFORE EVERY CHANGE:
33→ Does this produce the same output for every input?
34→ Does this maintain the same error behavior?
35→ Does this preserve the same side effects and ordering?
36→ Do all existing tests still pass without modification?
37```
38 
39### 2. Follow Project Conventions
40 
41Simplification means making code more consistent with the codebase, not imposing external preferences. Before simplifying:
42 
43```
441. Read CLAUDE.md / project conventions
452. Study how neighboring code handles similar patterns
463. Match the project's style for:
47 - Import ordering and module system
48 - Function declaration style
49 - Naming conventions
50 - Error handling patterns
51 - Type annotation depth
52```
53 
54Simplification that breaks project consistency is not simplification — it's churn.
55 
56### 3. Prefer Clarity Over Cleverness
57 
58Explicit code is better than compact code when the compact version requires a mental pause to parse.
59 
60```typescript
61// UNCLEAR: Dense ternary chain
62const label = isNew ? 'New' : isUpdated ? 'Updated' : isArchived ? 'Archived' : 'Active';
63 
64// CLEAR: Readable mapping
65function getStatusLabel(item: Item): string {
66 if (item.isNew) return 'New';
67 if (item.isUpdated) return 'Updated';
68 if (item.isArchived) return 'Archived';
69 return 'Active';
70}
71```
72 
73```typescript
74// UNCLEAR: Chained reduces with inline logic
75const result = items.reduce((acc, item) => ({
76 ...acc,
77 [item.id]: { ...acc[item.id], count: (acc[item.id]?.count ?? 0) + 1 }
78}), {});
79 
80// CLEAR: Named intermediate step
81const countById = new Map<string, number>();
82for (const item of items) {
83 countById.set(item.id, (countById.get(item.id) ?? 0) + 1);
84}
85```
86 
87### 4. Maintain Balance
88 
89Simplification has a failure mode: over-simplification. Watch for these traps:
90 
91- **Inlining too aggressively** — removing a helper that gave a concept a name makes the call site harder to read
92- **Combining unrelated logic** — two simple functions merged into one complex function is not simpler
93- **Removing "unnecessary" abstraction** — some abstractions exist for extensibility or testability, not complexity
94- **Optimizing for line count** — fewer lines is not the goal; easier comprehension is
95 
96### 5. Scope to What Changed
97 
98Default to simplifying recently modified code. Avoid drive-by refactors of unrelated code unless explicitly asked to broaden scope. Unscoped simplification creates noise in diffs and risks unintended regressions.
99 
100## The Simplification Process
101 
102### Step 1: Understand Before Touching (Chesterton's Fence)
103 
104Before changing or removing anything, understand why it exists. This is Chesterton's Fence: if you see a fence across a road and don't understand why it's there, don't tear it down. First understand the reason, then decide if the reason still applies.
105 
106```
107BEFORE SIMPLIFYING, ANSWER:
108- What is this code's responsibility?
109- What calls it? What does it call?
110- What are the edge cases and error paths?
111- Are there tests that define the expected behavior?
112- Why might it have been written this way? (Performance? Platform constraint? Historical reason?)
113- Check git blame: what was the original context for this code?
114```
115 
116If you can't answer these, you're not ready to simplify. Read more context first.
117 
118### Step 2: Identify Simplification Opportunities
119 
120Scan for these patterns — each one is a concrete signal, not a vague smell:
121 
122**Structural complexity:**
123 
124| Pattern | Signal | Simplification |
125|---------|--------|----------------|
126| Deep nesting (3+ levels) | Hard to follow control flow | Extract conditions into guard clauses or helper functions |
127| Long functions (50+ lines) | Multiple responsibilities | Split into focused functions with descriptive names |
128| Nested ternaries | Requires mental stack to parse | Replace with if/else chains, switch, or lookup objects |
129| Boolean parameter flags | `doThing(true, false, true)` | Replace with options objects or separate functions |
130| Repeated conditionals | Same `if` check in multiple places | Extract to a well-named predicate function |
131 
132**Naming and readability:**
133 
134| Pattern | Signal | Simplification |
135|---------|--------|----------------|
136| Generic names | `data`, `result`, `temp`, `val`, `item` | Rename to describe the content: `userProfile`, `validationErrors` |
137| Abbreviated names | `usr`, `cfg`, `btn`, `evt` | Use full words unless the abbreviation is universal (`id`, `url`, `api`) |
138| Misleading names | Function named `get` that also mutates state | Rename to reflect actual behavior |
139| Comments explaining "what" | `// increment counter` above `count++` | Delete the comment — the code is clear enough |
140| Comments explaining "why" | `// Retry because the API is flaky under load` | Keep these — they carry intent the code can't express |
141 
142**Redundancy:**
143 
144| Pattern | Signal | Simplification |
145|---------|--------|----------------|
146| Duplicated logic | Same 5+ lines in multiple places | Extract to a shared function |
147| Dead code | Unreachable branches, unused variables, commented-out blocks | Remove (after confirming it's truly dead) |
148| Unnecessary abstractions | Wrapper that adds no value | Inline the wrapper, call the underlying function directly |
149| Over-engineered patterns | Factory-for-a-factory, strategy-with-one-strategy | Replace with the simple direct approach |
150| Redundant type assertions | Casting to a type that's already inferred | Remove the assertion |
151 
152### Step 3: Apply Changes Incrementally
153 
154Make one simplification at a time. Run tests after each change. **Submit refactoring changes separately from feature or bug fix changes.** A PR that refactors and adds a feature is two PRs — split them.
155 
156```
157FOR EACH SIMPLIFICATION:
1581. Make the change
1592. Run the test suite
1603. If tests pass → commit (or continue to next simplification)
1614. If tests fail → revert and reconsider
162```
163 
164Avoid batching multiple simplifications into a single untested change. If something breaks, you need to know which simplification caused it.
165 
166**The Rule of 500:** If a refactoring would touch more than 500 lines, invest in automation (codemods, sed scripts, AST transforms) rather than making the changes by hand. Manual edits at that scale are error-prone and exhausting to review.
167 
168### Step 4: Verify the Result
169 
170After all simplifications, step back and evaluate the whole:
171 
172```
173COMPARE BEFORE AND AFTER:
174- Is the simplified version genuinely easier to understand?
175- Did you introduce any new patterns inconsistent with the codebase?
176- Is the diff clean and reviewable?
177- Would a teammate approve this change?
178```
179 
180If the "simplified" version is harder to understand or review, revert. Not every simplification attempt succeeds.
181 
182## Language-Specific Guidance
183 
184### TypeScript / JavaScript
185 
186```typescript
187// SIMPLIFY: Unnecessary async wrapper
188// Before
189async function getUser(id: string): Promise<User> {
190 return await userService.findById(id);
191}
192// After
193function getUser(id: string): Promise<User> {
194 return userService.findById(id);
195}
196 
197// SIMPLIFY: Verbose conditional assignment
198// Before
199let displayName: string;
200if (user.nickname) {
201 displayName = user.nickname;
202} else {
203 displayName = user.fullName;
204}
205// After
206const displayName = user.nickname || user.fullName;
207 
208// SIMPLIFY: Manual array building
209// Before
210const activeUsers: User[] = [];
211for (const user of users) {
212 if (user.isActive) {
213 activeUsers.push(user);
214 }
215}
216// After
217const activeUsers = users.filter((user) => user.isActive);
218 
219// SIMPLIFY: Redundant boolean return
220// Before
221function isValid(input: string): boolean {
222 if (input.length > 0 && input.length < 100) {
223 return true;
224 }
225 return false;
226}
227// After
228function isValid(input: string): boolean {
229 return input.length > 0 && input.length < 100;
230}
231```
232 
233### Python
234 
235```python
236# SIMPLIFY: Verbose dictionary building
237# Before
238result = {}
239for item in items:
240 result[item.id] = item.name
241# After
242result = {item.id: item.name for item in items}
243 
244# SIMPLIFY: Nested conditionals with early return
245# Before
246def process(data):
247 if data is not None:
248 if data.is_valid():
249 if data.has_permission():
250 return do_work(data)
251 else:
252 raise PermissionError("No permission")
253 else:
254 raise ValueError("Invalid data")
255 else:
256 raise TypeError("Data is None")
257# After
258def process(data):
259 if data is None:
260 raise TypeError("Data is None")
261 if not data.is_valid():
262 raise ValueError("Invalid data")
263 if not data.has_permission():
264 raise PermissionError("No permission")
265 return do_work(data)
266```
267 
268### React / JSX
269 
270```tsx
271// SIMPLIFY: Verbose conditional rendering
272// Before
273function UserBadge({ user }: Props) {
274 if (user.isAdmin) {
275 return <Badge variant="admin">Admin</Badge>;
276 } else {
277 return <Badge variant="default">User</Badge>;
278 }
279}
280// After
281function UserBadge({ user }: Props) {
282 const variant = user.isAdmin ? 'admin' : 'default';
283 const label = user.isAdmin ? 'Admin' : 'User';
284 return <Badge variant={variant}>{label}</Badge>;
285}
286 
287// SIMPLIFY: Prop drilling through intermediate components
288// Before — consider whether context or composition solves this better.
289// This is a judgment call — flag it, don't auto-refactor.
290```
291 
292## Common Rationalizations
293 
294| Rationalization | Reality |
295|---|---|
296| "It's working, no need to touch it" | Working code that's hard to read will be hard to fix when it breaks. Simplifying now saves time on every future change. |
297| "Fewer lines is always simpler" | A 1-line nested ternary is not simpler than a 5-line if/else. Simplicity is about comprehension speed, not line count. |
298| "I'll just quickly simplify this unrelated code too" | Unscoped simplification creates noisy diffs and risks regressions in code you didn't intend to change. Stay focused. |
299| "The types make it self-documenting" | Types document structure, not intent. A well-named function explains *why* better than a type signature explains *what*. |
300| "This abstraction might be useful later" | Don't preserve speculative abstractions. If it's not used now, it's complexity without value. Remove it and re-add when needed. |
301| "The original author must have had a reason" | Maybe. Check git blame — apply Chesterton's Fence. But accumulated complexity often has no reason; it's just the residue of iteration under pressure. |
302| "I'll refactor while adding this feature" | Separate refactoring from feature work. Mixed changes are harder to review, revert, and understand in history. |
303 
304## Red Flags
305 
306- Simplification that requires modifying tests to pass (you likely changed behavior)
307- "Simplified" code that is longer and harder to follow than the original
308- Renaming things to match your preferences rather than project conventions
309- Removing error handling because "it makes the code cleaner"
310- Simplifying code you don't fully understand
311- Batching many simplifications into one large, hard-to-review commit
312- Refactoring code outside the scope of the current task without being asked
313 
314## Verification
315 
316After completing a simplification pass:
317 
318- [ ] All existing tests pass without modification
319- [ ] Build succeeds with no new warnings
320- [ ] Linter/formatter passes (no style regressions)
321- [ ] Each simplification is a reviewable, incremental change
322- [ ] The diff is clean — no unrelated changes mixed in
323- [ ] Simplified code follows project conventions (checked against CLAUDE.md or equivalent)
324- [ ] No error handling was removed or weakened
325- [ ] No dead code was left behind (unused imports, unreachable branches)
326- [ ] A teammate or review agent would approve the change as a net improvement

Security

Passed

  • Gen Agent Trust Hubpass
  • Socketpass
  • Snykpass
  • Runlayerpass
  • ZeroLeakspass

Preview

addyosmani/agent-skillsaddyosmani/agent-skills

$ npx -y skills add addyosmani/agent-skills --skill code-simplification

▸ installing to .claude/skills…

✓ code-simplification ready

Repoaddyosmani/agent-skills
TypeSkills
CategoryCode Review & Refactor
ForDeveloper
UpdatedJul 2026
License—
First seenJul 26, 2026

Tags

Skill

Related

6 picks
Type
  1. mattpocock avatarimprove-codebase-architectureScan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.SkillsJul 2026566k189k
  2. mattpocock avatardomain-modelingBuild and sharpen a project's domain model. Use when the user wants to pin down domain terminology or a ubiquitous language, record an architectural decision,…SkillsJul 2026275k189k
  3. juliusbrussee avatarcaveman-reviewUltra-compressed code review comments. Cuts noise from PR feedback while preserving the actionable signal. Each comment is one line: location, problem, fix.SkillsJul 2026270k93k
  4. mattpocock avatarcodebase-designShared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a…SkillsJul 2026266k189k
  5. mattpocock avatarcode-reviewReview the changes since a fixed point (commit, branch, tag, or merge-base) along two axes — Standards (does the code follow this repo's documented coding…SkillsJul 2026201k189k
  6. mattpocock avatarresolving-merge-conflictsUse when you need to resolve an in-progress git merge/rebase conflict.SkillsJul 2026183k189k