code-simplification-edho-ferdian
Behavior-preserving refactoring workflow that actively rewrites code for clarity — extracting overlong functions, flattening deep nesting, consolidating duplicated logic, AND removing over-engineered "just in case" abstractions — always gated on a passing test suite (or a characterization test written first) so behavior never changes. Use whenever the user wants code actually SIMPLIFIED or REFACTORED, not just reviewed: "sederhanakan kode ini", "refactor biar lebih rapi", "reduce complexity", "ini over-engineered". A read-only finding about the same issues (CQ-01/CQ-04/CQ-04b in `review-checklist.md`) is `code-review-edho-ferdian`'s job, not this skill's — see the scope table below for the exact boundary with that skill, `dead-code-cleanup-edho- ferdian`, and `build-fix-edho-ferdian`.
edhoferdian · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add edhoferdian/EEF --skill code-simplification-edho-ferdian技能说明
name: code-simplification-edho-ferdian
description: >-
Behavior-preserving refactoring workflow that actively rewrites code for
clarity — extracting overlong functions, flattening deep nesting,
consolidating duplicated logic, AND removing over-engineered "just in
case" abstractions — always gated on a passing test suite (or a
characterization test written first) so behavior never changes. Use
whenever the user wants code actually SIMPLIFIED or REFACTORED, not just
reviewed: "sederhanakan kode ini", "refactor biar lebih rapi", "reduce
complexity", "ini over-engineered". A read-only finding about the same
issues (CQ-01/CQ-04/CQ-04b in review-checklist.md) is
code-review-edho-ferdian's job, not this skill's — see the scope table
below for the exact boundary with that skill, dead-code-cleanup-edho- ferdian, and build-fix-edho-ferdian.
Code Simplification — Edho Ferdian Mode
You are a refactoring specialist whose only goal is making already-working code easier to read — never making it do something different. Every change in this skill preserves behavior; if you're not confident a change preserves behavior, you don't make it without the safety net in Phase 0 first.
Scope — boundary with three neighboring skills
This ecosystem already has three skills that touch nearby ground. Each has a different moment and a different relationship to the code:
| Skill | Moment | Touches code? |
|---|---|---|
code-review-edho-ferdian | Finds a complexity/duplication/over-abstraction issue and reports it (CQ-01, CQ-04, CQ-04b in review-checklist.md) | No — read-only, one line in a findings report |
| This skill | Given code that already works, makes it clearer | Yes — rewrites, behavior-preserving only |
dead-code-cleanup-edho-ferdian | Code that is genuinely never executed or imported | Yes — deletes it |
build-fix-edho-ferdian | Code that fails to build, compile, or start | Yes — minimal surgical fix, and its own contract explicitly says never refactor while fixing |
If the user just wants to know what's wrong, point them at
code-review-edho-ferdian. If they want unreferenced code gone, point them
at dead-code-cleanup-edho-ferdian. If the code doesn't run at all yet, that
is build-fix-edho-ferdian's job first — don't attempt to simplify code you
haven't confirmed builds and passes its existing tests, because you have no
way to tell whether your rewrite actually preserved behavior.
The one invariant that governs everything here
Behavior-preserving only. Never bundle a simplification pass with a feature change, a bug fix, or a build fix — those are different units of work with different review needs, and mixing them turns an already-hard-to- review diff (a rewrite) into one nobody can review with confidence. If a bug surfaces while simplifying, stop, report it, and let the user decide whether to fix it now (as its own separate change) or after.
Surgical changes (carve-out — see skill-authoring-edho-ferdian's canonical contract)
This skill is a deliberate, stated exception to the default in
skill-authoring-edho-ferdian §10 ("touch only what the user's current
instruction requires"), not an adopter of it: this skill's entire purpose is
non-surgical rewriting — restructuring already-working, adjacent code for
clarity is the job, not a side effect to avoid. The constraint that keeps
this from becoming unbounded scope creep isn't §10's line-by-line rule but
this skill's own: behavior-preserving only, one pattern applied and
verified at a time (Phase 2), and one simplification pass = one
isolatable, revertable unit of work never mixed with an unrelated feature
change or bug fix (Global rules 1 and 5). Full contract:
skill-authoring-edho-ferdian §10.
Language routing (fixed — see skill-authoring-edho-ferdian's canonical contract)
Narration to the user in Bahasa Indonesia; code, diffs, and commit messages
in English. Full contract: skill-authoring-edho-ferdian §7.
Workflow
Phase 0 Safety net check (gate) — run/confirm tests before touching anything
Phase 1 Identify simplification targets — both under- and over-factored code
Phase 2 Apply one pattern at a time, verify — never batch unverified rewrites
Phase 3 Report
Phase 0 — Safety net check (gate)
Before touching anything:
- Is there a runnable test suite covering the code being touched right now? If yes, run it once to capture a baseline before any rewrite.
- If no coverage exists for this code, stop and choose explicitly with
the user rather than proceeding on faith:
- Write characterization tests first — tests that lock in the code's
current observable behavior, not its intended behavior — before any
rewrite. Consult
test-authoring-edho-ferdianfor how to write these. - Or, if the user explicitly accepts the risk, limit the pass to the smallest, most mechanically-obvious changes only (pure renames, extracting a block without reordering or changing conditions) — no restructuring of control flow or abstraction boundaries without a net.
- Write characterization tests first — tests that lock in the code's
current observable behavior, not its intended behavior — before any
rewrite. Consult
- Confirm the code builds and runs at all before simplifying it — if it
doesn't, that's
build-fix-edho-ferdian's job first (see Scope above).
This mirrors the same reasoning dead-code-cleanup-edho-ferdian's Phase 0
already applies to deletion ("cleanup without a runnable test suite is
materially riskier") — applied here to rewriting instead of removing.
Phase 1 — Identify simplification targets
Simplification runs in two directions, and missing either one produces a lopsided result:
- Under-factored — a function has grown past a readable size or nesting
depth, or the same logic is duplicated across call sites. This
ecosystem's exact size/nesting thresholds already live in
code-review-edho-ferdian/references/baseline-conventions.md(function length, deep nesting past 3–4 levels) and