Fundamental software development principles including SOLID, DRY, Occam's Razor (KISS), Miller's Law, and YAGNI. Use when discussing principles (原則), simplicity (シンプル), complexity (複雑), architecture (アーキテクチャ), refactoring (リファクタリング), maintainability (保守性), code quality (コード品質), design patterns, best practices, or clean code. Provides decision frameworks and practical guidelines for writing maintainable, understandable code. Essential for structure-reviewer, root-cause-reviewer, and /code command implementations.
This skill is limited to using the following tools:
EVALUATIONS.mdThis skill consolidates core software development principles into a single, coherent knowledge base. Covers:
Keywords that activate this skill:
For guaranteed activation:
Use these questions to apply principles quickly:
"Is there a simpler way to achieve this?"
"Am I duplicating knowledge or intent?"
"Does this class/module have a single, clear reason to change?"
"Can a new team member understand this in <1 minute?"
"Is this solving a real problem that exists now?"
Goal: Create flexible, maintainable systems through proper dependency management.
The Five Principles:
A class should have only one reason to change.
// ❌ Multiple responsibilities
class User {
validate(): boolean // Validation logic
save(): void // Persistence logic
sendEmail(): void // Notification logic
}
// ✅ Single responsibility
class UserValidator { validate(user: User): ValidationResult }
class UserRepository { save(user: User): Promise<void> }
class UserNotifier { sendEmail(user: User): Promise<void> }
Open for extension, closed for modification.
// ✅ Extend through interfaces
interface PaymentProcessor {
process(amount: number): Result
}
class StripeProcessor implements PaymentProcessor {}
class PayPalProcessor implements PaymentProcessor {}
Subtypes must be substitutable for their base types.
Many specific interfaces over one general-purpose interface.
Depend on abstractions, not concretions.
Full details: [@~/.claude/rules/reference/SOLID.md]
Core Philosophy: Every piece of knowledge must have a single, unambiguous, authoritative representation.
Not just code duplication - it's about knowledge duplication:
// ❌ Knowledge duplication
// In validation: maxLength = 100
// In database: VARCHAR(100)
// In UI: maxlength="100"
// ✅ Single source of truth
const LIMITS = { username: 100 }
// Use LIMITS everywhere
Rule of Three: See duplication twice? Note it. See it three times? Refactor it.
Full details: [@~/.claude/rules/reference/DRY.md]
Core Philosophy: The simplest solution that solves the problem is usually the best solution.
KISS: Keep It Simple, Stupid - same principle, memorable acronym.
Decision Framework:
// ❌ Unnecessarily complex
class UserAuthenticationManager {
private strategies: Map<string, AuthStrategy>
// 50 lines of abstraction
}
// ✅ Simple and sufficient
function authenticate(username: string, password: string): boolean {
const user = findUser(username)
return user && verifyPassword(password, user.passwordHash)
}
Full details: [@~/.claude/rules/reference/OCCAMS_RAZOR.md]
Core Philosophy: The human mind can hold approximately 7±2 items in short-term memory.
Scientific Foundation: This cognitive limit has profound implications:
Recommended Limits:
// ❌ Cognitive overload - 9 parameters
function createUser(
firstName, lastName, email,
phone, address, city,
state, zip, country
) { }
// ✅ Respecting cognitive limits - 3 grouped parameters
function createUser(
identity: UserIdentity,
contact: ContactInfo,
location: LocationInfo
) { }
Full details: [@~/.claude/rules/reference/MILLERS_LAW.md]
Core Philosophy: Don't add functionality until it's actually needed.
Implementation Phases (add each only when needed):
Decision Framework: Before adding code, ask:
If "No" → Don't add it yet
// ❌ YAGNI violation - premature abstraction
interface PaymentProcessor {
process(amount: number): Promise<Result>
}
class StripePaymentProcessor implements PaymentProcessor { }
// No other processors exist or planned
// ✅ YAGNI compliant
async function processPayment(amount: number) {
return stripe.charge(amount)
}
// Add interface when second processor is actually needed
Full details: [@~/.claude/rules/reference/YAGNI.md]
YAGNI + Occam's Razor:
"Build the simplest thing that solves today's problem only"
DRY + SOLID (SRP):
"Single source of truth for each responsibility"
Miller's Law + Occam's Razor:
"Simplicity within cognitive limits"
SOLID (DIP) + DRY:
"Abstractions prevent knowledge duplication"
YAGNI + TDD:
"Test-driven development naturally enforces YAGNI"
When principles conflict:
Canonical source:
~/.claude/rules/reference/
# In agent YAML frontmatter
dependencies: [code-principles]
Or explicit reference:
[@~/.claude/skills/applying-code-principles/SKILL.md]
Principles are working when:
Rule: When in doubt, start simple. Add complexity only when evidence demands it.
All principle documentation is maintained in ~/.claude/rules/reference/:
SOLID.md - Five SOLID principles with examplesDRY.md - Don't Repeat Yourself methodologyOCCAMS_RAZOR.md - Simplicity principle with KISSMILLERS_LAW.md - Cognitive limits (7±2) scientific foundationYAGNI.md - You Aren't Gonna Need It with decision frameworkNote: This skill references rules/reference/ as the single source of truth for principle documentation.