ワンクリックで
clean-code
클린 코드 원칙 및 적용 가이드를 실행합니다.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
클린 코드 원칙 및 적용 가이드를 실행합니다.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | clean-code |
| description | 클린 코드 원칙 및 적용 가이드를 실행합니다. |
| user-invocable | true |
클린 코드 원칙 및 적용 가이드를 실행합니다.
// ❌ Bad
const d = 86400;
const list = users.filter(u => u.a > 18);
// ✅ Good
const SECONDS_PER_DAY = 86400;
const adultUsers = users.filter(user => user.age > 18);
// ❌ Bad
setTimeout(fn, 86400000);
// ✅ Good
const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
setTimeout(fn, MILLISECONDS_PER_DAY);
// ❌ Bad
const yyyymmdstr = moment().format('YYYY/MM/DD');
// ✅ Good
const currentDate = moment().format('YYYY/MM/DD');
// ❌ Bad: 너무 긴 함수
function processOrder(order) {
// 100줄의 코드...
}
// ✅ Good: 작은 함수들로 분리
function processOrder(order) {
validateOrder(order);
calculateTotal(order);
applyDiscounts(order);
saveOrder(order);
sendConfirmation(order);
}
// ❌ Bad: 여러 일을 함
function emailClients(clients) {
clients.forEach(client => {
const record = database.lookup(client);
if (record.isActive()) {
email(client);
}
});
}
// ✅ Good: 하나의 일만
function emailActiveClients(clients) {
clients
.filter(isActiveClient)
.forEach(email);
}
function isActiveClient(client) {
const record = database.lookup(client);
return record.isActive();
}
// ❌ Bad: 인수가 많음
function createUser(name, email, age, address, phone, role) {}
// ✅ Good: 객체로 전달
function createUser({ name, email, age, address, phone, role }) {}
// 또는 Builder 패턴
new UserBuilder()
.setName('John')
.setEmail('john@example.com')
.build();
// ❌ Bad: 숨겨진 부수 효과
function checkPassword(user, password) {
if (cryptographer.decrypt(user.password) === password) {
Session.initialize(); // 숨겨진 부수 효과!
return true;
}
return false;
}
// ✅ Good: 명확한 의도
function checkPassword(user, password) {
return cryptographer.decrypt(user.password) === password;
}
function loginUser(user, password) {
if (checkPassword(user, password)) {
Session.initialize();
return true;
}
return false;
}
// ❌ Bad: 주석으로 설명
// 직원이 혜택을 받을 자격이 있는지 확인
if (employee.flags & HOURLY_FLAG && employee.age > 65) {}
// ✅ Good: 코드가 설명
if (employee.isEligibleForFullBenefits()) {}
// 정규표현식 설명 (복잡한 패턴)
// Format: kk:mm:ss EEE, MMM dd, yyyy
const pattern = /\d{2}:\d{2}:\d{2} \w{3}, \w{3} \d{2}, \d{4}/;
// TODO: 임시 해결책, #123 이슈에서 수정 예정
// WARNING: 이 메서드는 O(n²) 복잡도를 가짐
// NOTE: 외부 API 제한으로 인해 이 방식 사용
// ❌ 피해야 할 주석
i++; // i를 증가시킴 (불필요)
// 작성자: John, 날짜: 2024-01-15 (버전 관리 사용)
// function oldMethod() { ... } (죽은 코드)
// ❌ Bad: 에러 코드 반환
function withdraw(amount) {
if (balance < amount) return -1;
balance -= amount;
return 0;
}
// ✅ Good: 예외 던지기
function withdraw(amount) {
if (balance < amount) {
throw new InsufficientFundsError(amount, balance);
}
balance -= amount;
}
// ❌ Bad
throw new Error('Error');
// ✅ Good
throw new ValidationError('Email format is invalid', { field: 'email' });
// ❌ Bad: 기차 충돌 (Train Wreck)
const outputDir = ctxt.getOptions().getScratchDir().getAbsolutePath();
// ✅ Good
const options = ctxt.getOptions();
const scratchDir = options.getScratchDir();
const outputDir = scratchDir.getAbsolutePath();
// 또는 더 좋은 방법
const outputDir = ctxt.getOutputDirectory();
// 클래스는 하나의 책임만
// 메서드 수보다 책임의 수가 중요
// ❌ Bad: God Class
class Employee {
// 급여 계산, 세금 계산, HR 보고서, 이메일 발송 등...
}
// ✅ Good: 분리된 책임
class Employee { /* 직원 데이터 */ }
class PayrollCalculator { /* 급여 계산 */ }
class TaxCalculator { /* 세금 계산 */ }
class HRReporter { /* HR 보고서 */ }
// 높은 응집도: 모든 메서드가 모든 인스턴스 변수 사용
class Stack {
private items = [];
push(item) { this.items.push(item); }
pop() { return this.items.pop(); }
peek() { return this.items[this.items.length - 1]; }
isEmpty() { return this.items.length === 0; }
}
## Clean Code Review
### Issues Found
| 유형 | 위치 | 문제 | 개선안 |
|------|------|------|--------|
| 네이밍 | line 10 | 불명확한 변수명 | d → dayCount |
### Refactoring
```javascript
// Before
...
// After
...
---
요청에 맞는 클린 코드 분석 및 개선안을 제시하세요.
Interactive requirements discovery through Socratic dialogue and systematic exploration
사용자 계획을 기존 도메인 모델에 대해 stress-test하는 인터뷰 세션. 용어를 날카롭게 다듬고, 결정이 굳어질 때마다 CONTEXT.md(도메인 어휘 사전)와 ADR을 인라인으로 갱신한다. 새 기능 요구사항 탐색은 `/brainstorm`을, 기존 도메인 모델·용어와의 정합성 점검은 이 스킬을 사용한다.
Evaluate design from a UX perspective, assessing visual hierarchy, information architecture, emotional resonance, cognitive load, and overall quality with quantitative scoring, persona-based testing, automated anti-pattern detection, and actionable feedback. Use when the user asks to review, critique, evaluate, or give feedback on a design or component.
Run technical quality checks across accessibility, performance, theming, responsive design, and anti-patterns. Generates a scored report with P0-P3 severity ratings and actionable plan. Use when the user wants an accessibility check, performance audit, or technical quality review. (Impeccable design audit — distinct from /audit which validates project rules.)
Create distinctive, production-grade frontend interfaces with high design quality. Generates creative, polished code that avoids generic AI aesthetics. Use when the user asks to build web components, pages, artifacts, posters, or applications, or when any design skill requires project context. Call with 'craft' for shape-then-build, 'teach' for design context setup, or 'extract' to pull reusable components and tokens into the design system.
Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks