Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

sc-principles

БесплатноЗапускает вложенные скриптыНе проверен

Enforce KISS, Purity, SOLID, and Let It Crash principles through mandatory validation gates. Detects complexity violations, impure functions, design…

Tony363от Tony363★ 21 звезда на GitHub

Об этом скилле

/sc:principles - Code Principles Validator

Mandatory validation skill enforcing four fundamental software engineering principles:

  1. KISS (Keep It Simple, Stupid) - Code should be as simple as possible
  2. Functional Core, Imperative Shell - Business logic must be pure; I/O belongs at edges
  3. SOLID - Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, Dependency Inversion
  4. Let It Crash - Fail fast for bugs; handle errors explicitly at boundaries

Quick Start

# Full validation (all four principles)
/sc:principles src/

# KISS only validation
/sc:principles src/ --kiss-only

# Purity only validation
/sc:principles src/ --purity-only

# SOLID only validation
/sc:principles src/ --solid-only

# Let It Crash only validation
/sc:principles src/ --crash-only

# Strict mode (warnings become errors)
/sc:principles src/ --strict

# Generate detailed report
/sc:principles src/ --report

Behavioral Flow

1. INITIALIZE
   ├── Detect scope root
   ├── Find changed Python files (git diff)
   └── Determine file contexts (core vs shell)

2. ANALYZE
   ├── Parse AST for each file
   ├── Calculate complexity metrics (KISS)
   ├── Detect I/O patterns (Purity)
   ├── Check structural patterns (SOLID)
   └── Analyze error handling (Let It Crash)

3. VALIDATE
   ├── Compare against thresholds
   ├── Classify violations (error vs warning)
   └── Apply context rules (core stricter than shell)

4. REPORT/BLOCK
   ├── Output violations with locations
   ├── Generate actionable recommendations
   └── Exit 0 (pass) or 2 (blocked)

Validation Rules

KISS Gate

Metric Threshold Severity Description
Cyclomatic Complexity > 10 error Number of independent paths through code
Cyclomatic Complexity > 7 warning Early warning for growing complexity
Cognitive Complexity > 15 error Weighted complexity (nested structures count more)
Function Length > 50 lines error Lines of code per function (inclusive count)
Nesting Depth > 4 levels error If/for/while/with/try nesting
Parameter Count > 5 warning Function parameters

Cognitive vs Cyclomatic Complexity:

  • Cyclomatic counts decision points (branches)
  • Cognitive weights nested structures more heavily: 1 + nesting_depth per control structure
  • Example: if (if (if ...)) has low cyclomatic but high cognitive (hard to read)

Purity Gate

The "Functional Core, Imperative Shell" pattern:

Layer Path Patterns I/O Allowed Severity
Core */domain/*, */logic/*, */services/*, */utils/*, */core/* NO error
Shell */handlers/*, */adapters/*, */api/*, */cli/*, */scripts/*, */tests/* YES warning

Note: Files in */archive/*, */examples/*, */benchmarks/*, conftest.py, setup.py, and *__main__.py are treated as shell (I/O allowed).

Detected I/O Patterns:

Category Examples
File I/O open(), read(), write(), Path.read_text()
Network requests.get(), httpx, urllib, socket
Database execute(), query(), session.add(), cursor
Subprocess subprocess.run(), os.system(), Popen
Global State global, nonlocal keywords
Side Effects print(), logging.*, logger.*
Async I/O async def, await, async for, async with

SOLID Gate

Detects structural violations of SOLID design principles.

Principle Detection Severity Description
SRP File >300 lines, class with >5 public methods warning Single Responsibility - one reason to change
OCP if/elif chains on type, isinstance cascades warning Open-Closed - extend, don't modify
LSP Override that raises NotImplementedError error Liskov Substitution - honor contracts
ISP Interface/protocol with >7 methods warning Interface Segregation - small interfaces
DIP Direct instantiation in business logic warning Dependency Inversion - depend on abstractions

Code Smells to Flag:

Smell Principle Recommended Fix
File >300 lines SRP Extract responsibilities into modules
if/else type chains OCP Strategy pattern or registry
Override that throws LSP Honor base contract or don't inherit
10+ method interface ISP Split into focused interfaces
new Service() in logic DIP Dependency injection

Let It Crash Gate

Detects anti-patterns in error handling based on the "Let It Crash" philosophy.

Pattern Severity Description
Bare except: error Catches all exceptions including KeyboardInterrupt
except Exception: (no re-raise) warning Swallows errors without handling
except: pass error Silent failu
Полный SKILL.md на GitHub

Установить sc-principles в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

scripts/__init__.pyscripts/shared.pyscripts/validate_crash.pyscripts/validate_kiss.pyscripts/validate_purity.pyscripts/validate_solid.py

FAQ

Что делает скилл sc-principles?

Enforce KISS, Purity, SOLID, and Let It Crash principles through mandatory validation gates. Detects complexity violations, impure functions, design anti-patterns, and error handling issues.

Как установить скилл sc-principles?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл sc-principles запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить sc-principles с