Code Conventions - Code Style Persona
Role
Guide how to write code:
- Maintain consistent code style
- Write readable code
- Create maintainable structure
General Principles
Early Return Pattern
Prefer early returns over nested conditions for better readability.
Size Limits
| Target |
Limit |
When Exceeded |
| Function/Method |
50 lines |
Split |
| File/Class |
200 lines |
Split into modules |
| Nesting depth |
3 levels |
Apply early return |
TypeScript Conventions
Naming
| Type |
Pattern |
Example |
| Class/Interface/Type |
PascalCase |
OrderService, UserEntity |
| Function/Variable |
camelCase |
calculateTotal, userName |
| Constant |
SCREAMING_SNAKE |
MAX_RETRY_COUNT |
| File |
kebab-case or camelCase |
order-service.ts |
| Boolean |
is/has/can prefix |
isActive, hasPermission |
Best Practices
- Use arrow functions when possible
- Prefer
const over let, avoid var
- Always declare explicit types
- Use
interface for object shapes, type for unions/intersections
- Prefer
unknown over any
Avoid
❌ utils.ts, helpers.ts, common.ts, shared.ts
Python Conventions (PEP-8)
Naming
| Type |
Pattern |
Example |
| Class |
PascalCase |
OrderService, UserEntity |
| Function/Variable |
snake_case |
calculate_total, user_name |
| Constant |
SCREAMING_SNAKE |
MAX_RETRY_COUNT |
| Module/File |
snake_case |
order_service.py |
| Private |
leading underscore |
_internal_method |
Best Practices
- Maximum line length: 79 characters (code), 72 (docstrings)
- Use 4 spaces for indentation (no tabs)
- Two blank lines between top-level definitions
- One blank line between method definitions
- Use type hints (PEP 484)
- Use docstrings for public modules, functions, classes, methods
Import Order (PEP-8)
# 1. Standard library
import os
import sys
# 2. Third-party
import requests
import numpy as np
# 3. Local application
from myapp import utils
Avoid
❌ utils.py, helpers.py, common.py, shared.py
Java Conventions
Naming
| Type |
Pattern |
Example |
| Class/Interface |
PascalCase |
OrderService, UserEntity |
| Method/Variable |
camelCase |
calculateTotal, userName |
| Constant |
SCREAMING_SNAKE |
MAX_RETRY_COUNT |
| Package |
lowercase |
com.example.order |
| File |
Same as class name |
OrderService.java |
Best Practices
- One public class per file
- Use
final for immutable variables
- Prefer composition over inheritance
- Use interfaces for abstraction
- Follow JavaDoc conventions for documentation
- Use Optional instead of null for return values
Avoid
❌ Utils.java, Helpers.java, Common.java, Shared.java
Checklist
When Writing Code
Before PR
Anti-Patterns
- Magic Numbers: Using meaningless numbers directly
- God Function/Class: Giant function/class that does everything
- Callback Hell / Nested Conditionals: Deep nesting
- Copy-Paste Code: Duplicated code
- Generic Naming: utils, helpers, common, shared, misc
Completion
레퍼런스 Skill이므로 독립적 완료 조건 없음. 다른 Skill(code-reviewer, refactor-cleaner)이 참조하여 사용.
Troubleshooting
Project uses conventions different from this skill: Project-level CLAUDE.md or .editorconfig takes precedence. This skill provides defaults when no project convention exists.
Naming conflict between languages: Each language section is independent. Python uses snake_case, TypeScript uses camelCase — don't mix across language boundaries.
Linter rules conflict with these conventions: Linter config is authoritative. Update this skill’s guidance in project CLAUDE.md if persistent conflicts arise.
1---2name: code-conventions3description: 코드 컨벤션, 코딩 스타일, 코드 스타일, 네이밍, 컨벤션, 타입스크립트, 파이썬, 자바, 함수 크기, 파일 크기 - Code style reference for TypeScript, Python, and Java. Provides naming rules, function/file size limits, and formatting conventions. Use when writing or reviewing code style. Do NOT use as primary skill for code reviews (use code-reviewer) or refactoring (use refactor-cleaner).4---56# Code Conventions - Code Style Persona78## Role910Guide **how to write code**:11- Maintain consistent code style12- Write readable code13- Create maintainable structure1415## General Principles1617### Early Return Pattern1819Prefer early returns over nested conditions for better readability.2021### Size Limits2223| Target | Limit | When Exceeded |24|--------|-------|---------------|25| Function/Method | 50 lines | Split |26| File/Class | 200 lines | Split into modules |27| Nesting depth | 3 levels | Apply early return |2829---3031## TypeScript Conventions3233### Naming3435| Type | Pattern | Example |36|------|---------|---------|37| Class/Interface/Type | PascalCase | `OrderService`, `UserEntity` |38| Function/Variable | camelCase | `calculateTotal`, `userName` |39| Constant | SCREAMING_SNAKE | `MAX_RETRY_COUNT` |40| File | kebab-case or camelCase | `order-service.ts` |41| Boolean | is/has/can prefix | `isActive`, `hasPermission` |4243### Best Practices4445- Use arrow functions when possible46- Prefer `const` over `let`, avoid `var`47- Always declare explicit types48- Use `interface` for object shapes, `type` for unions/intersections49- Prefer `unknown` over `any`5051### Avoid5253```54❌ utils.ts, helpers.ts, common.ts, shared.ts55```5657---5859## Python Conventions (PEP-8)6061### Naming6263| Type | Pattern | Example |64|------|---------|---------|65| Class | PascalCase | `OrderService`, `UserEntity` |66| Function/Variable | snake_case | `calculate_total`, `user_name` |67| Constant | SCREAMING_SNAKE | `MAX_RETRY_COUNT` |68| Module/File | snake_case | `order_service.py` |69| Private | leading underscore | `_internal_method` |7071### Best Practices7273- Maximum line length: 79 characters (code), 72 (docstrings)74- Use 4 spaces for indentation (no tabs)75- Two blank lines between top-level definitions76- One blank line between method definitions77- Use type hints (PEP 484)78- Use docstrings for public modules, functions, classes, methods7980### Import Order (PEP-8)8182```python83# 1. Standard library84import os85import sys8687# 2. Third-party88import requests89import numpy as np9091# 3. Local application92from myapp import utils93```9495### Avoid9697```98❌ utils.py, helpers.py, common.py, shared.py99```100101---102103## Java Conventions104105### Naming106107| Type | Pattern | Example |108|------|---------|---------|109| Class/Interface | PascalCase | `OrderService`, `UserEntity` |110| Method/Variable | camelCase | `calculateTotal`, `userName` |111| Constant | SCREAMING_SNAKE | `MAX_RETRY_COUNT` |112| Package | lowercase | `com.example.order` |113| File | Same as class name | `OrderService.java` |114115### Best Practices116117- One public class per file118- Use `final` for immutable variables119- Prefer composition over inheritance120- Use interfaces for abstraction121- Follow JavaDoc conventions for documentation122- Use Optional instead of null for return values123124### Avoid125126```127❌ Utils.java, Helpers.java, Common.java, Shared.java128```129130---131132## Checklist133134### When Writing Code135136- [ ] Is function/method under 50 lines?137- [ ] Is file/class under 200 lines?138- [ ] Is nesting under 3 levels?139- [ ] Is early return applied?140- [ ] Is naming following language conventions?141- [ ] Are types/type hints declared?142143### Before PR144145- [ ] Consistent code style maintained146- [ ] Unnecessary comments removed147- [ ] Error handling appropriate148- [ ] Linter/formatter passed149150## Anti-Patterns151152- **Magic Numbers**: Using meaningless numbers directly153- **God Function/Class**: Giant function/class that does everything154- **Callback Hell / Nested Conditionals**: Deep nesting155- **Copy-Paste Code**: Duplicated code156- **Generic Naming**: utils, helpers, common, shared, misc157158## Completion159160레퍼런스 Skill이므로 독립적 완료 조건 없음. 다른 Skill(code-reviewer, refactor-cleaner)이 참조하여 사용.161162## Troubleshooting163164**Project uses conventions different from this skill**: Project-level CLAUDE.md or .editorconfig takes precedence. This skill provides defaults when no project convention exists.165**Naming conflict between languages**: Each language section is independent. Python uses snake_case, TypeScript uses camelCase — don't mix across language boundaries.166**Linter rules conflict with these conventions**: Linter config is authoritative. Update this skill’s guidance in project CLAUDE.md if persistent conflicts arise.