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

clean-code

하는 일

이 스킬은 AI 에이전트에게 단순하고 명확한 코드를 선호하는 실용적인 코딩 기준을 제공합니다. 과하게 설계하지 않는 깔끔한 코드를 원하는 개발자를 위한 것입니다.

사용하는 경우

  • ✓코드를 단순하게 유지하면서 작성하거나 검토해 달라고 요청할 때.
  • ✓함수가 길거나 이름이 불분명하거나 중첩이 깊을 때.
  • ✓아직 필요하지 않은 기능을 만드는 것을 피하고 싶은 경우.

스킬 링크

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/clean-code/SKILL.md

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

사용 방법

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

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

Use this skill to help me: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/clean-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분.

작동 방식

스킬은 이름 짓기, 함수 크기, 구조에 대한 규칙과 DRY, KISS 같은 원칙을 제공합니다. 에이전트는 코드를 쓰거나 정리할 때 이를 적용합니다.

기술 내용 (원본 SKILL.md)

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

Clean Code - Pragmatic AI Coding Standards

CRITICAL SKILL - Be concise, direct, and solution-focused.


Core Principles

Principle Rule
SRP Single Responsibility - each function/class does ONE thing
DRY Don't Repeat Yourself - extract duplicates, reuse
KISS Keep It Simple - simplest solution that works
YAGNI You Aren't Gonna Need It - don't build unused features
Boy Scout Leave code cleaner than you found it

Naming Rules

Element Convention
Variables Reveal intent: userCount not n
Functions Verb + noun: getUserById() not user()
Booleans Question form: isActive, hasPermission, canEdit
Constants SCREAMING_SNAKE: MAX_RETRY_COUNT

Rule: If you need a comment to explain a name, rename it.


Function Rules

Rule Description
Small Max 20 lines, ideally 5-10
One Thing Does one thing, does it well
One Level One level of abstraction per function
Few Args Max 3 arguments, prefer 0-2
No Side Effects Don't mutate inputs unexpectedly

Code Structure

Pattern Apply
Guard Clauses Early returns for edge cases
Flat > Nested Avoid deep nesting (max 2 levels)
Composition Small functions composed together
Colocation Keep related code close

AI Coding Style

Situation Action
User asks for feature Write it directly
User reports bug Fix it, don't explain
No clear requirement Ask, don't assume

Anti-Patterns (DON'T)

❌ Pattern ✅ Fix
Comment every line Delete obvious comments
Helper for one-liner Inline the code
Factory for 2 objects Direct instantiation
utils.ts with 1 function Put code where used
"First we import..." Just write code
Deep nesting Guard clauses
Magic numbers Named constants
God functions Split by responsibility

🔴 Before Editing ANY File (THINK FIRST!)

Before changing a file, ask yourself:

Question Why
What imports this file? They might break
What does this file import? Interface changes
What tests cover this? Tests might fail
Is this a shared component? Multiple places affected

Quick Check:

File to edit: UserService.ts
└── Who imports this? → UserController.ts, AuthController.ts
└── Do they need changes too? → Check function signatures

🔴 Rule: Edit the file + all dependent files in the SAME task. 🔴 Never leave broken imports or missing updates.


Summary

Do Don't
Write code directly Write tutorials
Let code self-document Add obvious comments
Fix bugs immediately Explain the fix first
Inline small things Create unnecessary files
Name things clearly Use abbreviations
Keep functions small Write 100+ line functions

Remember: The user wants working code, not a programming lesson.


🔴 Self-Check Before Completing (MANDATORY)

Before saying "task complete", verify:

Check Question
✅ Goal met? Did I do exactly what user asked?
✅ Files edited? Did I modify all necessary files?
✅ Code works? Did I test/verify the change?
✅ No errors? Lint and TypeScript pass?
✅ Nothing forgotten? Any edge cases missed?

🔴 Rule: If ANY check fails, fix it before completing.


Verification Scripts (MANDATORY)

🔴 CRITICAL: Each agent runs ONLY their own skill's scripts after completing work.

Agent → Script Mapping

Agent Script Command
frontend-specialist UX Audit python ~/.claude/skills/frontend-design/scripts/ux_audit.py .
frontend-specialist A11y Check python ~/.claude/skills/frontend-design/scripts/accessibility_checker.py .
backend-specialist API Validator python ~/.claude/skills/api-patterns/scripts/api_validator.py .
mobile-developer Mobile Audit python ~/.claude/skills/mobile-design/scripts/mobile_audit.py .
database-architect Schema Validate python ~/.claude/skills/database-design/scripts/schema_validator.py .
security-auditor Security Scan `python ~/.c
자주 묻는 질문

DRY와 KISS는 무엇인가요?

DRY는 같은 것을 반복하지 말라는 뜻이고, KISS는 해결책을 가능한 한 단순하게 유지하라는 뜻입니다.

함수에 대한 규칙은 무엇인가요?

함수는 작고, 한 가지 일만 하며, 인자는 적고, 예기치 않은 부작용을 피해야 합니다.

주석을 선호하나요?

아니요. 명확한 이름을 선호하며, 주석이 필요한 이름이라면 이름을 바꾸라고 말합니다.

상세 정보

작성자의 원본 설명

Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments

repo: davila7/claude-code-templates

인기도

GitHub 스타
33k
순위
#8736
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬