Community코딩 & 개발github.com

alfathafp/코드-단순화

동작은 유지하면서 코드를 더 읽기 쉽고 유지보수하기 쉽게 단순화합니다. 불필요한 복잡성이 쌓인 코드를 리팩토링하거나 리뷰할 때 사용하세요.

코드-단순화란 무엇인가요?

이 스킬은 AI 코딩 에이전트가 코드의 동작을 정확히 유지하면서 복잡성을 줄이도록 안내하는 프로세스 기반의 모델-불변 스킬입니다. 단순히 코드 라인 수를 줄이는 것이 아니라, 새로운 팀원도 원래 코드보다 빠르게 이해할 수 있는 방향으로 개선하는 것이 목표입니다. 특히 기능이 정상 동작하고 테스트를 통과한 후 구현이 더 무겁다고 느껴질 때, 코드 리뷰 중 가독성 문제가 지적될 때, 깊이 중첩된 로직이나 긴 함수, 모호한 이름을 발견했을 때, 시간에 쫓겨 작성된 코드를 리팩토링할 때, 여러 파일에 흩어진 관련 로직을 통합할 때, 또는 중복이나 불일치가 발생한 병합 후에 특히 유용합니다.**사용해서는 안 되는 경우**는 코드가 이미 깔끔하고 읽기 쉬울 때, 코드를 아직 이해하지 못했을 때(이해 전에 단순화하면 안 됨), 성능이 중요한 코드에서 '단순화'된 버전이 명백히 느려질 때, 또는 모듈 전체를 곧 다시 작성할 예정일 때(임시 코드 단순화는 시간 낭비)입니다. 스킬은 동작 정확히 유지, 프로젝트 규칙 준수, 명확성 우선, 균형 유지, 변경 범위 제한이라는 다섯 가지 원칙을 따릅니다. 각 단순화 전에 '이 변경이 모든 입력에 대해 동일한 출력을 내는가?', '에러 동작이 동일한가?', '부수 효과와 순서가 유지되는가?', '기존 테스트가 수정 없이 통과하는가?'를 스스로 확인해야 합니다. 프로젝트 규칙(CLAUDE.md 등)을 먼저 읽고 주변 코드가 유사한 패턴을 어떻게 처리하는지 학습한 후, 프로젝트의 스타일(import 순서, 함수 선언 방식, 명명 규칙, 에러 처리 패턴, 타입 어노테이션 깊이)과 일관되게 단순화해야 합니다. 명확한 코드가 영리하지만 이해하기 어려운 코드보다 우선이며, 인라인을 너무 공격적으로 하거나 관련 없는 로직을 합치거나 '불필요한' 추상화를 제거하거나 라인 수를 최적화하는 함정에 빠지지 않도록 주의해야 합니다. 기본적으로 최근에 수정된 코드만 단순화하고, 명시적으로 요청되지 않은 관련 없는 코드에 대한 드라이브-바이 리팩토링은 피해야 합니다.

지원 대상✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/alfathafp/portofolio-web-design/tree/HEAD/.agents/skills/code-simplification

Installed? Explore more 코딩 & 개발 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

코드 단순화

Claude Code Simplifier 플러그인에서 영감을 받았습니다. 여기서는 모델에 구애받지 않는 프로세스 중심 스킬로서 모든 AI 코딩 에이전트에 맞게 조정되었습니다.

개요

정확한 동작을 유지하면서 복잡성을 줄여 코드를 단순화합니다. 목표는 라인 수를 줄이는 것이 아니라, 코드를 더 읽기 쉽고, 이해하기 쉽고, 수정 및 디버깅하기 쉽게 만드는 것입니다. 모든 단순화는 간단한 테스트를 통과해야 합니다: "새로운 팀원이 원래 코드보다 이것을 더 빨리 이해할 수 있는가?"

사용 시기

  • 기능이 작동하고 테스트가 통과했지만, 구현이 필요한 것보다 더 무겁게 느껴질 때
  • 코드 리뷰 중 가독성이나 복잡성 문제가 지적될 때
  • 깊이 중첩된 로직, 긴 함수, 또는 불명확한 이름을 발견했을 때
  • 시간이 촉박한 상황에서 작성된 코드를 리팩토링할 때
  • 여러 파일에 흩어진 관련 로직을 통합할 때
  • 중복이나 불일치를 초래한 변경 사항을 병합한 후

사용하지 말아야 할 때:

  • 코드가 이미 깔끔하고 읽기 쉽다면 — 단순화를 위해 단순화하지 마세요
  • 코드가 무엇을 하는지 아직 이해하지 못했다면 — 단순화하기 전에 먼저 이해하세요
  • 코드가 성능에 중요한 부분이고 "단순한" 버전이 눈에 띄게 느려질 것 같다면
  • 모듈 전체를 곧 다시 작성할 예정이라면 — 임시 코드를 단순화하는 것은 시간 낭비입니다

다섯 가지 원칙

1. 동작을 정확히 유지하세요

코드가 하는 일을 바꾸지 마세요 — 표현 방식만 바꾸세요. 모든 입력, 출력, 부수 효과, 에러 동작, 엣지 케이스가 동일하게 유지되어야 합니다. 단순화가 동작을 유지하는지 확실하지 않다면, 하지 마세요.

모든 변경 전에 스스로 질문하세요:
→ 이것이 모든 입력에 대해 동일한 출력을 내는가?
→ 동일한 에러 동작을 유지하는가?
→ 동일한 부수 효과와 순서를 유지하는가?
→ 모든 기존 테스트가 수정 없이 통과하는가?

2. 프로젝트 규칙을 따르세요

단순화는 코드를 코드베이스와 더 일관되게 만드는 것을 의미하며, 외부 선호도를 강요하는 것이 아닙니다. 단순화하기 전에:

1. CLAUDE.md / 프로젝트 규칙을 읽으세요
2. 주변 코드가 유사한 패턴을 어떻게 처리하는지 학습하세요
3. 프로젝트 스타일을 맞추세요:
   - Import 순서와 모듈 시스템
   - 함수 선언 스타일
   - 명명 규칙
   - 에러 처리 패턴
   - 타입 어노테이션 깊이

프로젝트 일관성을 깨는 단순화는 단순화가 아니라 혼란입니다.

3. 명확성을 영리함보다 선호하세요

명시적인 코드가 간결한 코드보다 낫습니다. 간결한 버전이 이해하는 데 정신적 멈춤이 필요할 때 특히 그렇습니다.

// 불명확: 밀집된 삼항 연산자 체인
const label = isNew ? 'New' : isUpdated ? 'Updated' : isArchived ? 'Archived' : 'Active';

// 명확: 읽기 쉬운 매핑
function getStatusLabel(item: Item): string {
  if (item.isNew) return 'New';
  if (item.isUpdated) return 'Updated';
  if (item.isArchived) return 'Archived';
  return 'Active';
}
// 불명확: 인라인 로직이 포함된 체인된 reduce
const result = items.reduce((acc, item) => ({
  ...acc,
  [item.id]: { ...acc[item.id], count: (acc[item.id]?.count ?? 0) + 1 }
}), {});

// 명확: 이름이 있는 중간 단계
const countById = new Map<string, number>();
for (const item of items) {
  countById.set(item.id, (countById.get(item.id) ?? 0) + 1);
}

4. 균형을 유지하세요

단순화에는 과도한 단순화라는 실패 모드가 있습니다. 다음 함정을 조심하세요:

  • 너무 공격적인 인라인 — 개념에 이름을 부여한 도우미를 제거하면 호출 지점을 읽기가 더 어려워집니다
  • 관련 없는 로직 결합 — 두 개의 간단한 함수를 하나의 복잡한 함수로 병합하는 것은 더 단순하지 않습니다
  • "불필요한" 추상화 제거 — 일부 추상화는 복잡성이 아니라 확장성이나 테스트 용이성을 위해 존재합니다
  • 라인 수 최적화 — 라인 수가 적은 것이 목표가 아닙니다; 더 쉬운 이해가 목표입니다

5. 변경된 범위로 제한하세요

기본적으로 최근에 수정된 코드를 단순화하세요. 명시적으로 범위를 넓히라고 요청받지 않는 한, 관련 없는 코드에 대한 드라이브-바이 리팩토링을 피하세요. 범위가 지정되지 않은 단순화는 diff에 노이즈를 만들고 의도치 않은 회귀 위험을 초래합니다.

단순화 프로세스

1단계: 건드리기 전에 이해하세요 (체스터턴의 울타리)

무언가를 변경하거나 제거하기 전에, 그것이 왜 존재하는지 이해하세요. 이것이 체스터턴의 울타리입니다: 길 건너편에 울타리가 있는데 왜 거기에 있는지 이해하지 못한다면, 그것을 허물지 마세요. 먼저 이유를 이해한 다음, 그 이유가 여전히 유효한지 결정하세요.

단순화 전에 답하세요:
- 이 코드의 책임은 무엇인가?
- 무엇이 이것을 호출하는가? 이것은 무엇을 호출하는가?
- 엣지 케이스와 에러 경로는 무엇인가?
- 예상되는 동작을 정의하는 테스트가 있는가?
- 왜 이렇게 작성되었을까? (성능? 플랫폼 제약? 역사적 이유?)
- git blame을 확인하세요: 이 코드의 원래 맥락은 무엇이었나?

이것들에 답할 수 없다면, 단순화할 준비가 되지 않은 것입니다. 먼저 더 많은 맥락을 읽으세요.

2단계: 단순화 기회 식별

다음 패턴을 스캔하세요 — 각각은 막연한 냄새가 아니라 구체적인 신호입니다:

구조적 복잡성:

패턴신호단순화
깊은 중첩 (3단계 이상)제어 흐름을 따라가기 어려움조건을 가드 절 또는 도우미 함수로 추출
긴 함수 (50줄 이상)여러 책임설명적인 이름을 가진 집중된 함수로 분할
중첩된 삼항 연산자정신적 스택 필요if/else 체인, switch, 또는 조회 객체로 대체
불리언 파라미터 플래그doThing(true, false, true)옵션 객체 또는 별도 함수로 대체
반복되는 조건문여러 곳에서 동일한 if 검사이름이 잘 지어진 조건자 함수로 추출

명명 및 가독성:

패턴신호단순화
일반적인 이름data, result, temp, val, item내용을 설명하도록 이름 변경: userProfile, validationErrors
축약된 이름usr, cfg, btn, evt약어가 보편적이지 않는 한 전체 단어 사용 (id, url, api)
오해의 소지가 있는 이름get으로 명명되었지만 상태를 변경하는 함수실제 동작을 반영하도록 이름 변경
"무엇"을 설명하는 주석count++ 위에 // increment counter주석 삭제 — 코드가 충분히 명확함
"왜"를 설명하는 주석// 부하가 걸린 API가 불안정하므로 재시도유지 — 코드가 표현할 수 없는 의도를 담고 있음

중복:

패턴신호단순화
중복된 로직여러 곳에서 동일한 5줄 이상공유 함수로 추출
죽은 코드도달할 수 없는 분기, 사용되지 않는 변수, 주석 처리된 블록제거 (진정으로 죽은 것인지 확인 후)
불필요한 추상화가치를 더하지 않는 래퍼래퍼 인라인, 기본 함수 직접 호출
과도하게 설계된 패턴공장을 위한 공장, 단일 전략을 가진 전략 패턴간단한 직접 접근 방식으로 대체
중복 타입 단언이미 추론된 타입으로 캐스팅단언 제거

3단계: 점진적으로 변경 적용

한 번에 하나의 단순화를 수행하세요. 각 변경 후 테스트를 실행하세요. 리팩토링 변경 사항은 기능 또는 버그 수정 변경 사항과 별도로 제출하세요. 기능을 추가하면서 리팩토링하는 PR은 두 개의 PR입니다 — 분리하세요.

각 단순화마다:
1. 변경을 적용하세요
2. 테스트 스위트를 실행하세요
3. 테스트가 통과하면 → 커밋 (또는 다음 단순화로 계속)
4. 테스트가 실패하면 → 되돌리고 재고하세요

여러 단순화를 단일 테스트되지 않은 변경으로 일괄 처리하지 마세요. 무언가가 깨지면, 어떤 단순화가 원인인지 알아야 합니다.

500줄 규칙: 리팩토링이 500줄 이상을 건드려야 한다면, 수동으로 변경하는 대신 자동화(코드 모드, sed 스크립트, AST 변환)에 투자하세요. 그 규모의 수동 편집은 오류가 발생하기 쉽고 검토하기에도 힘듭니다.

4단계: 결과 확인

모든 단순화 후, 한 걸음 물러나 전체를 평가하세요:

전후 비교:
- 단순화된 버전이 진정으로 이해하기 더 쉬운가?
- 코드베이스와 일관성이 없는 새로운 패턴을 도입했는가?
- Diff가 깔끔하고 검토 가능한가?
- 팀원이 이 변경을 승인할 것인가?

"단순화된" 버전이 이해하거나 검토하기 더 어렵다면 되돌리세요. 모든 단순화 시도가 성공하는 것은 아닙니다.

언어별 지침

TypeScript / JavaScript

// 단순화: 불필요한 async 래퍼
// Before
async function getUser(id: string): Promise<User> {
  return await userService.findById(id);
}
// After
function getUser(id: string): Promise<User> {
  return userService.findById(id);
}

// 단순화: 장황한 조건부 할당
// Before
let displayName: string;
if (user.nickname) {
  displayName = user.nickname;
} else {
  displayName = user.fullName;
}
// After
const displayName = user.nickname || user.fullName;

// 단순화: 수동 배열 구축
// Before
const activeUsers: User[] = [];
for (const user of users) {
  if (user.isActive) {
    activeUsers.push(user);
  }
}
// After
const activeUsers = users.filter((user) => user.isActive);

// 단순화: 중복 불리언 반환
// Before
function isValid(input: string): boolean {
  if (input.length > 0 && input.length < 100) {
    return true;
  }
  return false;
}
// After
function isValid(input: string): boolean {
  return input.length > 0 && input.length < 100;
}

Python

# 단순화: 장황한 딕셔너리 구축
# Before
result = {}
for item in items:
    result[item.id] = item.name
# After
result = {item.id: item.name for item in items}

# 단순화: 조기 반환을 사용한 중첩 조건문
# Before
def process(data):
    if data is not None:
        if data.is_valid():
            if data.has_permission():
                return do_work(data)
            else:
                raise PermissionError("No permission")
        else:
            raise ValueError("Invalid data")
    else:
        raise TypeError("Data is None")
# After
def process(data):
    if data is None:
        raise TypeError("Data is None")
    if not data.is_valid():
        raise ValueError("Invalid data")
    if not data.has_permission():
        raise PermissionError("No permission")
    return do_work(data)

React / JSX

// 단순화: 장황한 조건부 렌더링
// Before
function UserBadge({ user }: Props) {
  if (user.isAdmin) {
    return <Badge variant="admin">Admin</Badge>;
  } else {
    return <Badge variant="default">User</Badge>;
  }
}
// After
function UserBadge({ user }: Props) {
  const variant = user.isAdmin ? 'admin' : 'default';
  const label = user.isAdmin ? 'Admin' : 'User';
  return <Badge variant={variant}>{label}</Badge>;
}

// 단순화: 중간 컴포넌트를 통한 Prop 드릴링
// Before — 컨텍스트나 컴포지션이 이것을 더 잘 해결하는지 고려하세요.
// 이것은 판단의 문제입니다 — 플래그를 지정하고, 자동 리팩토링하지 마세요.

일반적인 합리화

합리화현실
"작동하니까 건드릴 필요 없어"읽기 어려운 작동 코드는 고장 났을 때 고치기 어렵습니다. 지금 단순화하면 앞으로의 모든 변경에 시간을 절약할 수 있습니다.
"라인 수가 적은 것이 항상 더 단순하다"1줄 중첩 삼항 연산자는 5줄 if/else보다 더 단순하지 않습니다. 단순함은 이해 속도에 관한 것이지 라인 수에 관한 것이 아닙니다.
"이 관련 없는 코드도 빨리 단순화할게"범위가 지정되지 않은 단순화는 지저분한 diff를 만들고 의도하지 않은 코드에서 회귀 위험을 초래합니다. 집중하세요.
"타입이 스스로 문서화해준다"타입은 구조를 문서화하지 의도를 문서화하지 않습니다. 이름이 잘 지어진 함수가 타입 시그니처가 설명하는 무엇보다 왜를 더 잘 설명합니다.
"이 추상화는 나중에 유용할 수도 있어"추측성 추상화를 유지하지 마세요. 지금 사용되지 않는다면 가치 없는 복잡성입니다. 제거하고 필요할 때 다시 추가하세요.
"원작자에게는 이유가 있었을 거야"아마도. git blame을 확인하고 체스터턴의 울타리를 적용하세요. 그러나 축적된 복잡성은 종종 이유가 없습니다; 압박 속에서 반복된 작업의 잔재일 뿐입니다.
"이 기능을 추가하면서 리팩토링할게"리팩토링과 기능 작업을 분리하세요. 혼합된 변경은 검토, 되돌리기, 기록에서 이해하기 더 어렵습니다.

위험 신호

  • 단순화를 위해 테스트를 수정해야 하는 경우 (동작을 변경했을 가능성이 높음)
  • "단순화된" 코드가 원본보다 길고 따라가기 더 어려운 경우
  • 프로젝트 규칙이 아닌 자신의 선호도에 맞춰 이름을 변경하는 경우
  • "코드를 더 깔끔하게 만든다"는 이유로 에러 처리를 제거하는 경우
  • 완전히 이해하지 못한 코드를 단순화하는 경우
  • 많은 단순화를 하나의 크고 검토하기 어려운 커밋으로 일괄 처리하는 경우
  • 요청받지 않고 현재 작업 범위를 벗어난 코드를 리팩토링하는 경우

검증

단순화 패스를 완료한 후:

  • 모든 기존 테스트가 수정 없이 통과함
  • 빌드가 새로운 경고 없이 성공함
  • 린터/포맷터 통과 (스타일 회귀 없음)
  • 각 단순화가 검토 가능하고 점진적인 변경임
  • Diff가 깔끔함 — 관련 없는 변경이 섞여 있지 않음
  • 단순화된 코드가 프로젝트 규칙을 따름 (CLAUDE.md 또는 동등한 파일에서 확인)
  • 에러 처리가 제거되거나 약화되지 않음
  • 죽은 코드가 남아 있지 않음 (사용되지 않는 import, 도달할 수 없는 분기)
  • 팀원 또는 검토 에이전트가 이 변경을 순 개선으로 승인할 것임

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

alfathafp/portofolio-web-design

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).

alfathafp/portofolio-web-design

Tests in real browsers via Chrome DevTools MCP. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data. Requires the chrome-devtools MCP server to be configured.

alfathafp/portofolio-web-design

Automates CI/CD pipeline setup. Use when setting up or modifying build and deployment pipelines. Use when you need to automate quality gates, configure test runners in CI, or establish deployment strategies.

alfathafp/portofolio-web-design

Conducts multi-axis code review. Use before merging any change. Use when reviewing code written by yourself, another agent, or a human. Use when you need to assess code quality across multiple dimensions before it enters the main branch. Use when asked to review a diff or a pull request, even when the diff is pasted inline.

alfathafp/portofolio-web-design

Establishes a project's quality bar as a written contract and stops agents quietly lowering it. Interviews the user on which dimensions matter, supplies sane default thresholds when they have no number in mind, records everything in CONSTRAINTS.md, and watches the diff for a weakened bar — new @ts-ignore or eslint-disable suppressions, skipped or deleted tests, assertions stripped out, unimplemented stubs, thresholds edited down. Use when no quality bar is written down, when the user says "set up constraints" or "define our standards", when the user wants dimensions they care about — accessibility, web performance, coverage — set up as enforced constraints, when an agent keeps silencing checks or skipping tests to get to green, when you need a coverage or performance threshold and don't know what number to pick, or when an agent writes more code than anyone will read.

alfathafp/portofolio-web-design

Optimizes agent context setup. Use when starting a new session, when agent output quality degrades, when switching between tasks, or when you need to configure rules files and context for a project.

alfathafp/portofolio-web-design

Guides systematic root-cause debugging. Use when tests fail, builds break, something that worked yesterday broke, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need to figure out what broke and why — a systematic approach to finding and fixing the root cause rather than guessing.

alfathafp/portofolio-web-design

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

alfathafp/portofolio-web-design

Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.

alfathafp/portofolio-web-design

Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.

alfathafp/portofolio-web-design

Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies

alfathafp/portofolio-web-design

Records decisions and documentation. Use when you need to document an architecture decision (ADR) or the reasoning behind a design choice, when changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.

alfathafp/portofolio-web-design

Subjects every non-trivial decision to a fresh-context adversarial review before it stands. Use when you want every assumption cross-examined before proceeding, when stress-testing a plan for hidden failure modes, when correctness matters more than speed, when working in unfamiliar code, when stakes are high (production auth, security-sensitive logic, a high-stakes migration, irreversible operations), or any time a confident output would be cheaper to verify now than to debug later.

alfathafp/portofolio-web-design

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

alfathafp/portofolio-web-design

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work

alfathafp/portofolio-web-design

Builds production-quality, accessible, responsive user-facing UIs. Use when building or modifying interfaces and pages, creating components, implementing layouts, meeting WCAG accessibility requirements, managing state, or when the output needs to look and feel production-quality rather than AI-generated.

alfathafp/portofolio-web-design

Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, splitting uncommitted work in a messy working tree into clean atomic commits, opening or reviewing a pull request (PR), pushing to a remote, or when you need to organize work across multiple parallel streams. Use when cutting a release, choosing a semantic version bump, tagging, or writing a changelog.

alfathafp/portofolio-web-design

Refines raw ideas into sharp, actionable concepts through structured divergent and convergent thinking. Use when an idea is still vague, when you need to stress-test assumptions before committing to a plan, or when you want to expand options before converging on one. Triggers on "ideate", "refine this idea", or "stress-test my plan".

alfathafp/portofolio-web-design

Delivers changes incrementally in thin, verifiable slices. Use when implementing any feature or change that touches more than one file, or when picking up the next task from a plan. Use when rolling a change out behind a feature flag, when you're about to write a large amount of code at once, or when a task feels too big to land in one step.

alfathafp/portofolio-web-design

Guides stable API and interface design. Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.

관련 스킬