npx skills add ...
npx skills add openshift/lightspeed-service --skill find-complexity
npx skills add openshift/lightspeed-service --skill find-complexity
Find functions and methods with high cyclomatic complexity, excessive length, or too many parameters. Use when the user asks to find complex code, complexity hotspots, refactoring candidates, or wants to improve code maintainability.
Identify functions that are hard to review, test, and maintain.
ols/). Skip tests unless explicitly asked.Ask the user:
ols/ directory.For branch mode:
This shows functions with complexity grade C or worse (threshold: 11+).
Grades: A (1-5), B (6-10), C (11-15), D (16-20), E (21-25), F (26+).
This shows files with maintainability grade B or worse.
Grades: A (20+, good), B (10-19, medium), C (0-9, poor).
Cognitive complexity weights nesting depth — a 5-deep if scores much higher than 5 sequential ifs.
Find long functions (30+ lines of logic, excluding docstrings and blank lines):
Also use pylint for method length:
Find large files (500+ lines):
Files over 500 lines are candidates for splitting into focused modules.
For each function found, classify:
| Category | Criteria | Action |
|---|---|---|
| Split | High complexity + long body | Break into smaller functions |
| Simplify | High complexity + short body | Reduce branching (early returns, lookup tables) |
| Parameterize | Too many arguments (6+) | Group into config/dataclass |
| Monitor | Grade C, not growing | Note it, revisit if it gets worse |
| Split file | File over 500 lines | Break into focused modules |
For each finding:
Summary: total hotspots by grade, top 5 worst offenders.
uvx --with flake8-cognitive-complexity flake8 --select=CCR001 --max-cognitive-complexity=10 <target>uvx radon raw <target> -suv run pylint --disable=all --enable=too-many-statements,too-many-branches,too-many-return-statements,too-many-arguments,too-many-locals <target>wc -l $(find <target> -name '*.py') | sort -rn | head -20