complexity

Code complexity guidelines to keep cyclomatic complexity below 6 using strategy patterns or dispatch tables. Use when writing or refactoring functions with complex branching logic.

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

When & Why to Use This Skill

This Claude skill helps developers maintain high-quality, maintainable codebases by enforcing strict cyclomatic complexity standards. It provides actionable guidance for refactoring complex branching logic into cleaner architectural patterns, such as strategy patterns or dispatch tables, ensuring that functions remain readable, testable, and easy to debug.

Use Cases

  • Refactoring legacy code: Identifying and simplifying deeply nested if-else structures or oversized switch statements to reduce technical debt.
  • Architectural optimization: Implementing strategy patterns or dispatch tables to handle complex conditional logic more efficiently.
  • Pre-merge code quality checks: Ensuring new code contributions adhere to complexity limits (below 6) before they are integrated into the main branch.
  • Improving testability: Reducing the number of execution paths within functions to make unit testing more comprehensive and less cumbersome.
namecomplexity
descriptionCode complexity guidelines to keep cyclomatic complexity below 6 using strategy patterns or dispatch tables. Use when writing or refactoring functions with complex branching logic.

Code Complexity Guidelines

Apply these guidelines to keep code complexity manageable.

Cyclomatic Complexity

Keep the cyclomatic complexity of each function below 6.

  • If you have a large switch case, consider using the strategy pattern or dispatch table instead