Home / Commands / addyosmani/agent-skills

code-simplify

Simplify code for clarity and maintainability — reduce complexity without changing behavior

commandLicense: MIT Source: addyosmani/agent-skills

Install

Copy this folder into your Claude Code project (needs Node.js):

curl -fsSL --create-dirs -o .claude/commands/code-simplify.md https://raw.githubusercontent.com/addyosmani/agent-skills/HEAD/.claude/commands/code-simplify.md

Or install it for every project:

curl -fsSL --create-dirs -o ~/.claude/commands/code-simplify.md https://raw.githubusercontent.com/addyosmani/agent-skills/HEAD/.claude/commands/code-simplify.md

File content

Made by its original authors and shared under MIT. We show it unchanged, with credit and a link to the source. Source ↗

---
description: Simplify code for clarity and maintainability — reduce complexity without changing behavior
disable-model-invocation: true
---

Invoke the agent-skills:code-simplification skill.

Simplify recently changed code (or the specified scope) while preserving exact behavior:

1. Read CLAUDE.md and study project conventions
2. Identify the target code — recent changes unless a broader scope is specified
3. Understand the code's purpose, callers, edge cases, and test coverage before touching it
4. Scan for simplification opportunities:
   - Deep nesting → guard clauses or extracted helpers
   - Long functions → split by responsibility
   - Nested ternaries → if/else or switch
   - Generic names → descriptive names
   - Duplicated logic → shared functions
   - Dead code → remove after confirming
5. Apply each simplification incrementally — run tests after each change
6. Verify all tests pass, the build succeeds, and the diff is clean

If tests fail after a simplification, revert that change and reconsider. Use `code-review-and-quality` to review the result.