Reduce nesting, extract names, eliminate redundancy without changing
behavior. Apply after features work and tests pass — never as a
drive-by during feature work. Triggers on "simplify", "refactor for clarity",
"this is hard to read", "code review flagged complexity".
Installation
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Reduce nesting, extract names, eliminate redundancy without changing
behavior. Apply after features work and tests pass — never as a
drive-by during feature work. Triggers on "simplify", "refactor for clarity",
"this is hard to read", "code review flagged complexity".
allowed-tools
Read, Edit, Bash, Grep, Glob
Code Simplification Skill
When to trigger
Apply when:
Features work and tests pass — simplification is a separate phase
Code review flagged readability (deep nesting, long functions, unclear names)
You're touching the area for an unrelated reason and the existing code obstructs understanding
A new contributor (human or agent) was confused by the same code twice
Skip when:
The code is already clean or follows the canonical pattern
You don't fully understand what the code does (Chesterton's Fence — see below)
Performance is critical and the "simplification" would change hot-path semantics
Tests don't exist yet — write them first (test-driven-development skill)
The five principles
Preserve behavior exactly. Ask: "Does this produce the same output for every input — including the inputs the original author was paranoid about?"
Follow project conventions. Match the existing codebase, not your external preferences. The .rules/ directory and CLAUDE.md describe what's canonical here.
Prefer clarity over cleverness. Explicit beats compact when the reader has to "decompile" the line in their head.
Maintain balance. Don't over-inline (one giant function), don't over-extract (10 micro-helpers each used once).
Scope to what changed. Drive-by refactors in unrelated files inflate diffs and hide regressions. Open a follow-up PR.
Chesterton's Fence
"Don't remove a fence in the middle of a field until you understand why it was put there."
Before deleting code, comment, or guard clause:
Search for the issue or commit that added it (git log -S "term" --all, git blame).
Understand the original intent. A weird-looking check often guards against a real production bug from years ago.
If the original reason no longer applies, document the reasoning in the simplification commit. If you can't determine the reason, leave it alone — the cost of the fence is one read, the cost of a regression is much higher.
The process
Understand before touching — apply Chesterton's Fence above.
Identify opportunities
Deep nesting (>3 levels) — extract guard clauses, early returns, helper functions
Long functions (>50 lines per .rules/typescript.md) — split by concern
Generic names (data, tmp, result) — rename to describe role in this scope
Duplicated logic in 3+ places — extract (2 instances is coincidence, per CLAUDE.md DRY rule)