본문으로 건너뛰기
Skillpedia
일반 코딩8.2k · #12539

simplify-code

하는 일

이 스킬은 AI가 코드에서 불필요한 복잡성을 찾아 없애도록 돕습니다. 코드가 커져서 읽기 어렵거나 관리하기 힘든 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓거의 아무 일도 하지 않는 래퍼 클래스나 추상화가 있을 때.
  • ✓죽은 코드, 쓰지 않는 import, 따라가기 어려운 중첩 로직이 보일 때.
  • ✓동작은 그대로 두면서 코드를 더 읽기 쉽게 만들고 싶은 경우.

스킬 링크

https://github.com/vudovn/ag-kit/blob/main/.agents/skills/simplify-code/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/vudovn/ag-kit/blob/main/.agents/skills/simplify-code/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 모듈을 단순하게 만들어 주세요. 쓰지 않는 것은 지우고 깊게 중첩된 로직은 펴 주되, 동작은 그대로 유지해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 스킬은 흔한 복잡성 문제 목록에 맞춰 코드를 점검합니다. 필요 없는 부분은 지우거나 평평하게 펴며, 동작은 그대로 유지합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Simplify Code — Reduce Unnecessary Complexity

The best code is the code you don't have to write. The second best is the code anyone can read.

Core Principle

Complexity is a cost. Every abstraction, every indirection, every clever pattern
adds cognitive load. Simplify ruthlessly unless complexity serves a clear purpose.

Simplification Checklist

1. Unnecessary Abstractions

Smell Simplification
Wrapper class that just delegates Remove wrapper, use the inner class directly
Factory that creates only one type Replace with direct constructor
Strategy pattern with one strategy Replace with simple function
Interface with one implementation Remove interface, use the class
Abstract class with one child Merge into the child class
Config object for 2 values Use function parameters

2. Dead Code

Smell Action
Unused imports Remove
Unreachable branches Remove (check tests first)
Commented-out code Remove (it's in git history)
Unused variables/functions Remove
TODO comments older than 6 months Remove or create issue
Feature flags for launched features Remove flag, keep the code

3. Deep Nesting

// ❌ Before: 4 levels deep
function process(data) {
  if (data) {
    if (data.items) {
      for (const item of data.items) {
        if (item.active) {
          doSomething(item)
        }
      }
    }
  }
}

// ✅ After: Early returns + filter
function process(data) {
  if (!data?.items) return

  data.items
    .filter(item => item.active)
    .forEach(doSomething)
}

4. Over-Parameterized Functions

// ❌ Before: 8 parameters
function createUser(name, email, age, role, dept, active, verified, avatar) { }

// ✅ After: Object parameter
function createUser(opts: CreateUserOpts) { }

5. Premature Optimization

Smell Simplification
Custom cache for <100 items Remove cache, measure first
Memoization on cheap functions Remove memo
Lazy loading for small modules Use direct import
Complex state machine for 3 states Use simple if/else or switch

Simplification Protocol

Step 1: Identify Complexity

- Count nesting levels (target: ≤3)
- Count function parameters (target: ≤4)
- Count lines per function (target: ≤30)
- Count abstractions per feature (target: ≤2)
- Check for dead code (target: 0)

Step 2: Verify Understanding

Before simplifying, ensure you understand:

  • What the code does (not what it looks like it does)
  • Why it was written this way (maybe there's a reason)
  • What tests cover it (simplification must not break tests)

Step 3: Simplify Incrementally

1. Remove dead code first (safest)
2. Flatten nesting with early returns
3. Inline trivial abstractions
4. Merge related functions
5. Simplify data structures

Step 4: Verify Behavior Preserved

npm run test    # All existing tests still pass
npm run build   # Still compiles

When NOT to Simplify

Situation Why Keep Complexity
Performance-critical hot path Optimization may look complex but is necessary
Required by framework/library External constraints
Explicitly requested pattern User chose this architecture
Will need extension soon Abstraction prepares for known growth

Ask first: "This pattern seems over-engineered. Should I simplify it, or is there a reason for the abstraction?"

자주 묻는 질문

단순화하면 코드 동작이 바뀌나요?

동작을 보존하도록 설계되어 있으며, 분기를 지우기 전에 테스트를 확인합니다.

죽은 코드란 무엇인가요?

쓰지 않는 import, 쓰지 않는 변수와 함수, 도달할 수 없는 분기, 오래된 주석 처리 코드입니다.

기능 플래그도 지우나요?

이미 출시된 기능의 플래그는 제거를 제안하지만, 기능 코드 자체는 남긴다고 설명합니다.

상세 정보

작성자의 원본 설명

Reduce complexity of over-engineered code. Identify unnecessary abstractions, remove dead code, flatten deep nesting, and simplify logic while preserving behavior.

repo: vudovn/ag-kit

인기도

GitHub 스타
8.2k
순위
#12539
라이선스
MIT
업데이트
2026. 10. 18.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬