complexity-management
БесплатноБез исполняемых скриптовНе проверенMaintain and improve code quality using PHPInsights without decreasing quality thresholds. Use when PHPInsights fails, cyclomatic complexity is too high, code…
Об этом скилле
Code Complexity Management
Context (Input)
- PHPInsights checks fail (
make phpinsightsreturns errors) - Cyclomatic complexity exceeds thresholds
- Code quality score drops below 100%
- Architecture score falls below 100%
- Style score drops below 100%
- Complexity score falls below 93%
- Adding new features that increase complexity
- Refactoring existing code for better maintainability
Task (Function)
Maintain exceptional code quality standards using PHPInsights while preserving hexagonal architecture, DDD patterns, and CQRS design.
Success Criteria:
make phpinsightspasses without errors- Code quality: 100%
- Complexity: ≥ 94%
- Architecture: 100%
- Style: 100%
Protected Quality Thresholds
CRITICAL: These thresholds in phpinsights.php must NEVER be lowered:
'requirements' => [
'min-quality' => 100, // Code quality
'min-complexity' => 94, // Cyclomatic complexity
'min-architecture' => 100, // Architecture compliance
'min-style' => 100, // Coding style
],
Policy: If PHPInsights fails, fix the code - NEVER lower these thresholds.
⚠️ CRITICAL POLICY: NEVER CHANGE CONFIG
╔═══════════════════════════════════════════════════════════════╗
║ When PHPInsights fails, you MUST FIX THE CODE. ║
║ NEVER lower thresholds in phpinsights.php. ║
║ ║
║ ❌ FORBIDDEN: Changing config to pass checks ║
║ ✅ REQUIRED: Refactoring code to meet standards ║
╚═══════════════════════════════════════════════════════════════╝
Quick Start Workflow
Step 1: Identify Complex Classes
# Find top 20 most complex classes
make analyze-complexity
# Find top 10 classes
make analyze-complexity N=10
# Export as JSON for tracking
make analyze-complexity-json N=20 > complexity-report.json
Output shows:
- CCN (Cyclomatic Complexity): > 15 is critical
- WMC (Weighted Method Count): Sum of all method complexities
- Avg Complexity: CCN ÷ Methods (target: < 5)
- Max Complexity: Highest complexity of any single method
- Maintainability Index: 0-100 (target: > 65)
See: reference/analysis-tools.md
Step 2: Run PHPInsights
make phpinsights
Step 3: Identify Failing Metric
❌ [COMPLEXITY] 93.5 pts (target: 94%)
✗ Method `CustomerCommandHandler::handle` has cyclomatic complexity of 12
Step 4: Apply Refactoring Strategy
See: refactoring-strategies.md for proven patterns:
- Extract Methods
- Strategy Pattern
- Early Returns
- Functional Composition
Step 5: Verify Improvements
make phpinsights
Repeat until all scores meet thresholds.
Quick Fix Guide by Issue Type
Cyclomatic Complexity Too High
Problem: Method has too many decision points (if/else/switch/loops)
Identify hotspots:
make analyze-complexity N=10
Solutions:
- Extract methods: Break complex method into smaller private methods
- Strategy pattern: Replace conditionals with polymorphism
- Early returns: Reduce nesting with guard clauses
- Command pattern: Separate command handling logic
See: refactoring-strategies.md for DDD/CQRS-specific patterns
Architecture Violations
Problem: Layer dependencies violated (e.g., Domain depending on Infrastructure)
Solutions:
- Review layer boundaries: Domain → Application → Infrastructure
- Use interfaces: Define contracts in Domain, implement in Infrastructure
- Dependency injection: Inject dependencies through constructors
- Repository pattern: Keep data access in Infrastructure layer
See: deptrac-fixer skill for fixing architectural violations
Style Issues
Problem: Code doesn't meet PSR-12 or Symfony coding standards
Solution:
# Auto-fix most style issues
make phpcsfixer
# Re-run PHPInsights to verify
make phpinsights
Line Length > 100 Characters
Problem: Lines exceed configured limit
Solutions:
- Break long method calls into multiple lines
- Extract complex expressions into variables
- Use named parameters (PHP 8+)
- Refactor long argument lists into DTOs
See: reference/project-configuration.md
Constraints (Parameters)
NEVER
- Lower quality thresholds in
phpinsights.php - Lower thresholds in
phpinsights-tests.php - Skip PHPInsights checks to "save time"
- Disable sniffs without understanding impact
- Ignore architecture violations
- Put business logic in Application layer (belongs in Domain)
ALWAYS
- Fix code to meet standards (not config to meet code)
- Run
make phpinsightsafter refactoring - Maintain hexagonal architecture while reducing complexity
- Keep Domain layer
Установить complexity-management в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл complexity-management?
Maintain and improve code quality using PHPInsights without decreasing quality thresholds. Use when PHPInsights fails, cyclomatic complexity is too high, code quality drops, or when refactoring for better maintainability. Always maintains 94% complexity and 100% quality/architecture/style scores.
Как установить скилл complexity-management?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл complexity-management запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
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