coding-standards
БесплатноЗапускает вложенные скриптыНе проверенComprehensive coding standards and best practices for maintainable, consistent software development across multiple languages and paradigms
Об этом скилле
Coding Standards Skill
Level 1: Quick Start (5 minutes)
What You'll Learn
Apply essential coding standards for clean, maintainable code that follows industry best practices.
Core Principles
- Consistency: Follow established style guides (PEP 8, Airbnb, Google)
- Readability: Write self-documenting code with clear naming
- Maintainability: Keep functions small (<50 lines), files focused (<500 lines)
- Quality: Enforce standards with linters and formatters
Quick Reference
# ✅ Good: Clear naming, single responsibility
def calculate_user_discount(user: User, order: Order) -> Decimal:
"""Calculate discount based on user tier and order total."""
if user.tier == "premium":
return order.total * Decimal("0.15")
return order.total * Decimal("0.05")
# ❌ Bad: Unclear naming, mixed concerns
def calc(u, o):
d = 0.15 if u.t == "p" else 0.05
save_to_db(u, o, d) # Side effect!
return o.t * d
Essential Checklist
- Follow language-specific style guide
- Use meaningful, descriptive names
- Limit function complexity (cyclomatic < 10)
- Configure linter and formatter
- Add pre-commit hooks
Common Pitfalls
- Inconsistent naming conventions within a project
- Functions that do too many things
- Missing or outdated documentation
- Skipping code reviews
Level 2: Implementation (30 minutes)
Deep Dive Topics
1. Code Style and Formatting
Naming Conventions by Language:
// TypeScript/JavaScript
class UserService {} // PascalCase for classes
const getUserById = () => {} // camelCase for functions
const API_ENDPOINT = "..." // UPPER_SNAKE_CASE for constants
# Python
class UserService: # PascalCase for classes
def get_user_by_id(): # snake_case for functions
API_ENDPOINT = "..." # UPPER_SNAKE_CASE for constants
File Organization:
src/
├── models/ # Data models and types
├── services/ # Business logic (max 500 lines/file)
├── controllers/ # Request handlers
├── utils/ # Shared utilities
└── config/ # Configuration
2. Documentation Standards
Function Documentation:
/**
* Calculates the final price after applying discounts and tax.
*
* @param basePrice - The original price before any adjustments
* @param discountRate - Discount as a decimal (0.1 = 10%)
* @param taxRate - Tax rate as a decimal (0.08 = 8%)
* @returns The final price rounded to 2 decimal places
* @throws {ValidationError} If basePrice is negative
*
* @example
* const finalPrice = calculateFinalPrice(100, 0.1, 0.08);
* // Returns 97.20 (100 - 10% discount + 8% tax)
*/
function calculateFinalPrice(
basePrice: number,
discountRate: number,
taxRate: number
): number {
if (basePrice < 0) {
throw new ValidationError("Base price cannot be negative");
}
const discounted = basePrice * (1 - discountRate);
return Math.round(discounted * (1 + taxRate) * 100) / 100;
}
3. Architecture Patterns
SOLID Principles Application:
// Single Responsibility Principle
class UserRepository {
async findById(id: string): Promise<User> {}
async save(user: User): Promise<void> {}
}
class UserValidator {
validate(user: User): ValidationResult {}
}
// Dependency Injection
class UserService {
constructor(
private readonly repository: UserRepository,
private readonly validator: UserValidator
) {}
async createUser(userData: UserData): Promise<User> {
const validation = this.validator.validate(userData);
if (!validation.isValid) {
throw new ValidationError(validation.errors);
}
return this.repository.save(new User(userData));
}
}
4. Error Handling
// Custom error hierarchy
class ApplicationError extends Error {
constructor(
message: string,
public code: string,
public statusCode: number = 500
) {
super(message);
this.name = this.constructor.name;
}
}
class ValidationError extends ApplicationError {
constructor(message: string, public fields: string[]) {
super(message, "VALIDATION_ERROR", 400);
}
}
// Usage with proper error handling
async function processPayment(payment: Payment): Promise<Result> {
try {
validatePaymentData(payment);
const result = await paymentGateway.charge(payment);
await auditLog.record("payment.success", { paymentId: result.id });
return result;
} catch (error) {
if (error instanceof ValidationError) {
logger.warn("Invalid payment data", { fields: error.fields });
throw error;
}
logger.error("Payment processing failed", { error, payment });
throw new ApplicationError(
"Payment processing failed",
"PAYMENT_ERROR",
502
);
}
}
Implementation Patterns
DRY (Don't Repeat Yourself)
// ❌ Bad: Repeated logic
function calculateEmploye
Установить coding-standards в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл coding-standards?
Comprehensive coding standards and best practices for maintainable, consistent software development across multiple languages and paradigms
Как установить скилл coding-standards?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл coding-standards запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic