applying-code-principles

thkt's avatarfrom thkt

Fundamental software principles - SOLID, DRY, Occam's Razor, Miller's Law, YAGNI. Triggers: 原則, シンプル, 複雑, アーキテクチャ, リファクタリング, 保守性, コード品質, design pattern, best practice, clean code

⭐3stars🔀0forks📁View on GitHub🕐Updated Jan 4, 2026

When & Why to Use This Skill

This Claude skill facilitates the application of core software engineering principles—including SOLID, DRY, YAGNI, and Occam's Razor—to enhance code quality and system architecture. It helps developers minimize technical debt by providing actionable guidelines for refactoring, simplifying complex logic, and enforcing best practices for maintainability and readability. By integrating specific thresholds for code complexity, it ensures that software remains scalable and easy for teams to understand.

Use Cases

  • Refactoring legacy code: Identifying and eliminating code smells by applying DRY (Don't Repeat Yourself) and SOLID principles to improve long-term maintainability.
  • Architectural Decision Making: Using YAGNI (You Ain't Gonna Need It) and Occam's Razor to prevent over-engineering and ensure the simplest effective solution is implemented.
  • Code Quality Audits: Enforcing strict thresholds for function arguments, class methods, and conditional nesting to reduce cognitive load and follow Miller's Law.
  • Design Pattern Implementation: Guiding the creation of flexible and decoupled systems by ensuring interfaces are introduced only when necessary (Rule of Three).
nameapplying-code-principles
description>
allowed-tools[Read, Grep, Glob]
user-invocablefalse

Code Principles

Priority Order

Priority Principle When to Apply
1 Safety First Security, data integrity
2 YAGNI Don't build what you don't need
3 Occam's Razor Simplest solution
4 SOLID For complex systems
5 DRY Eliminate duplication (not at cost of clarity)
6 Miller's Law Respect 7±2 cognitive limit

Quick Checks

See CLAUDE.md Development Checks section (always loaded, single source of truth).

Thresholds

Target Ideal Max Limit
Function args 3 5 7
Class methods 5 7 9
Conditionals 3 5 7

Rules

Principle Rule
DRY Abstract on 3rd duplication (Rule of Three)
SOLID Interface only when 2nd implementation appears
YAGNI Build only if problem exists now
Readable New team member understands in < 1 minute