← ClaudeAtlas

low-complexitylisted

Enforce low Cognitive Complexity (SonarSource) and low Cyclomatic Complexity in ALL code written or modified, in any programming language, framework, or platform. This skill MUST activate automatically whenever code is being written, generated, modified, or refactored — no explicit trigger needed. Triggers include writing any function, method, class, module, script, handler, endpoint, test, or code block. Also triggers on "low complexity", "cognitive complexity", "cyclomatic complexity", "reduce complexity", "simplify code", "too complex", "refactor for readability", "clean code", "implement", "fix bug", "add feature", "generate test", "optimize", "rewrite", "scaffold".
mryll/skills · ★ 4 · AI & Automation · score 78
Install: claude install-skill mryll/skills
# Low Complexity Code Every function/method written or modified MUST target: - **Cognitive Complexity <= 5** (SonarSource metric). Acceptable up to 10 for inherently complex logic. Never exceed 15. - **Cyclomatic Complexity <= 5**. Acceptable up to 10. Never exceed 15. For full scoring rules, see [cognitive-complexity-spec.md](references/cognitive-complexity-spec.md). ## Cognitive Complexity Quick Reference **+1 for each:** `if`, ternary (`? :`), `switch` (whole), `for`, `while`, `do while`, `catch`, `else if`, `else`, `goto LABEL`, `break/continue LABEL`, each method in a recursion cycle, each sequence of like boolean operators (`&&` / `||`). **+1 nesting penalty** on top of structural increment for: `if`, ternary, `switch`, `for`, `while`, `catch` — when nested inside another flow-break structure. **Free (no increment):** method calls, `try`, `finally`, `case` labels, null-coalescing (`?.`, `??`), early `return`, simple `break`/`continue`, lambdas (but lambdas increase nesting level). ## Cyclomatic Complexity Quick Reference +1 for the method entry, +1 for each: `if`, `else if`, `for`, `while`, `do while`, `case`, `catch`, `&&`, `||`, ternary `?`. Core definition; some analyzers may vary by language. ## Mandatory Reduction Techniques Apply these in order of preference: 1. **Extract method/function** — Move a coherent block into a named function. Resets nesting to 0. First choice when the extracted block forms a coherent unit. 2. **Early return / guard clause** —