code-simplification

Refactors code to reduce complexity while preserving exact behavior and passing existing tests.

Updated Jun 13, 2026
One-click install
npx skills add https://github.com/22Teikk/22Teikk-Agent-Skills-Hub --skill code-simplification-22teikk
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: code-simplification
Source: https://github.com/22Teikk/22Teikk-Agent-Skills-Hub/tree/main/core/skills/code-simplification
Command: npx skills add https://github.com/22Teikk/22Teikk-Agent-Skills-Hub --skill code-simplification-22teikk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Working code often accumulates unnecessary complexity — deep nesting, long functions, unclear names, and duplicated logic — making it harder to read, maintain, and extend. This Skill provides a disciplined, behavior-preserving process for simplifying code without introducing regressions. ## Core Features & Use Cases - Five Simplification Principles: Preserve behavior exactly, follow project conventions, prefer clarity over cleverness, avoid over-simplification, and scope changes to what changed. - Pattern Detection Tables: Concrete signals for structural complexity, naming issues, and redundancy, each paired with a specific simplification technique. - Incremental Process: Understand before touching (Chesterton's Fence), apply one change at a time, run tests after each step, and keep refactoring separate from feature work. - Language-Specific Guidance: Before/after examples for Kotlin, Java, and Jetpack Compose. - Use Case: After a feature passes its tests but the implementation has 4-level nesting and a 90-line function, use this Skill to split it into focused functions with guard clauses while keeping every test green. ## Quick Start Ask the agent to simplify the recently modified code in the current module without changing its behavior, then verify all existing tests still pass.

Frequently Asked Questions about code-simplification

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor code without changing its behavior?▼

Make one simplification at a time and run the full test suite after each change. If tests fail, revert that change and reconsider. Keep refactoring commits separate from feature or bug fix changes so regressions are easy to isolate.

How to simplify deeply nested code and long functions?▼

Extract nested conditions into guard clauses or helper functions, and split functions over 50 lines into focused functions with descriptive names. Replace nested ternaries with if/else chains, when expressions, or lookup tables.

When should I not simplify or refactor code?▼

Avoid simplifying code you do not yet understand, performance-critical code where the simpler version is measurably slower, and code about to be rewritten entirely. Also skip code that is already clean — simplification for its own sake adds churn.

Does code simplification work for Kotlin and Jetpack Compose?▼

Yes, the guidance includes Kotlin-specific examples like replacing manual loops with filter, using the Elvis operator for null defaults, and groupingBy for counting. Compose examples cover conditional modifiers and destructuring state objects.

Why do refactoring changes break existing tests?▼

Test failures during refactoring usually mean behavior was accidentally changed — an altered edge case, removed error handling, or reordered side effects. Revert the failing change immediately and re-apply it in smaller steps to find the cause.

Should refactoring and feature work be in the same pull request?▼

No, refactoring and feature changes should be separate pull requests. Mixed changes are harder to review, revert, and understand in history, and they obscure which change caused any regression.