# Code Simplification (code-simplification)

> Reduces code complexity while preserving exact behavior, aiming for code that is easier to read, modify and debug rather than fewer lines.

- Category: [Refactoring](https://www.myskills.tools/en/categories/refactoring/)
- Source: Community · Addy Osmani
- Repository: https://github.com/addyosmani/agent-skills/tree/main/skills/code-simplification (commit f1f6fbf)
- SKILL.md: https://github.com/addyosmani/agent-skills/blob/main/skills/code-simplification/SKILL.md
- Install command: `npx skills add addyosmani/agent-skills --skill code-simplification`
- License: MIT
- Compatible with: Claude Code, Codex, Cursor, Copilot, Gemini CLI
- Permissions: read-repo ✓, write-files ✓, shell ✓, network ✗
- Status: Scan passed
- A rule scan cannot catch every risk. Read this skill's SKILL.md and check its permissions before installing.

## Core rule

Preserve behavior exactly; if you are not sure a simplification preserves behavior, do not make it.

## Execution Phases

1. **Understand before touching** — Apply Chesterton's Fence: learn the code's responsibility, callers, edge cases, tests and git blame history before changing anything.
2. **Identify opportunities** — Following project conventions, look for deep nesting, long functions, nested ternaries, unclear names, duplication, dead code and needless abstractions.
3. **Apply incrementally** — Make one simplification at a time and run tests after each, reverting on failure; submit refactors separately from feature or bug-fix changes.
4. **Verify the result** — Compare before and after for readability and consistency; existing tests pass unmodified and build and lint stay clean.

## Permissions (summarised from SKILL.md)

| Capability | Needed | Details |
|---|---|---|
| File writes | Required | Edits code in scope, by default the recently modified code. |
| Command execution | Required | Runs tests, builds, linters and git blame, and may use codemod scripts for large changes. |
| Network outbound | Not required | The skill does not call for network access. |

## SKILL.md frontmatter (YAML)

```yaml
---
name: code-simplification
description: 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. Use when asked to simplify, clean up, or reduce the nesting of a function or module that already works, even when the code is pasted inline and nothing else needs to change.
---
```

Home: https://www.myskills.tools/en/ · URL: https://www.myskills.tools/en/skills/code-simplification/
