Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Measures cyclomatic complexity, cognitive complexity, and function length across codebases to identify maintenance hotspots. Use when someone asks about code complexity, function length analysis, maintainability metrics, or needs to find the most complex parts of their codebase. Trigger words: complexity, cyclomatic, cognitive complexity, long functions, hotspots, maintainability index, code metrics.
.claude/skills/terminalskills-code-complexity-scanner/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-13 | ✗→✓ | ▲ Improved | 33% | 0% |
| case-14 | ✗→✓ | ▲ Improved | -18% | 0% |
| case-15 | ✗→✓ | ▲ Improved | 28% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 106% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 152% | 0% |
This skill analyzes source code to measure cyclomatic complexity, cognitive complexity, and function length. It identifies the most complex functions and files in a codebase, helping teams focus refactoring efforts on the code that's hardest to maintain and most likely to harbor bugs.
Detect the primary language from file extensions and package files. Filter to source code only (exclude node_modules, vendor, dist, build, __pycache__, .git).
For each function/method, count:
if, elif/else if → +1 eachfor, while, do-while → +1 eachcase in switch (each case) → +1 eachcatch → +1&&, || in conditions → +1 each?: → +1More nuanced than cyclomatic — penalizes nesting:
Rank files by:
Present findings in three tiers:
User prompt:
Scan src/ for the most complex functionsAgent output:
Complexity Report — src/ (89 files scanned)
🔴 CRITICAL (complexity > 25)
src/billing/calculator.ts
calculateInvoiceTotal() Cyclomatic: 34 Cognitive: 48 Lines: 180
applyDiscountRules() Cyclomatic: 26 Cognitive: 31 Lines: 95
src/api/middleware/auth.ts
validateAndRefreshToken() Cyclomatic: 28 Cognitive: 35 Lines: 120
🟡 WARNING (complexity 15-25)
src/workers/sync.ts
reconcileRecords() Cyclomatic: 19 Cognitive: 24 Lines: 88
src/utils/validators.ts
validateAddress() Cyclomatic: 16 Cognitive: 18 Lines: 65
Summary:
Files scanned: 89 | Functions analyzed: 412
Average complexity: 6.8 | Median: 4
Functions above threshold: 14 (3.4%)
Recommended target: reduce critical functions below 15User prompt:
What are the complexity hotspots in our Django app?Agent output:
Complexity Hotspots — myapp/ (67 files)
Top 10 by Cyclomatic Complexity:
Rank Function CC Lines File
1 process_order() 38 340 views/checkout.py
2 generate_report() 27 210 reports/builder.py
3 sync_inventory() 24 180 tasks/inventory.py
4 parse_import_file() 22 150 importers/csv.py
5 calculate_shipping() 19 95 shipping/rates.py
Nesting depth violations (>4 levels):
views/checkout.py:142 — 6 levels deep in process_order()
reports/builder.py:89 — 5 levels deep in generate_report()
Recommended refactoring order: process_order() first (highest complexity,
most changed file per git history, 340 lines is 3x recommended max).| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 33,801 | 4,770 | -86% | 1 | 1 | 0% | 6,518 | 1,348 | -79% | 0 | 0 | — |
case-02 | fail→fail | 17,050 | 13,575 | -20% | 1 | 1 | 0% | 2,908 | 3,764 | +29% | 0 | 0 | — |
case-03 | pass→pass | 8,748 | 10,813 | +24% | 1 | 1 | 0% | 1,493 | 3,081 | +106% | 0 | 0 | — |
case-04 | pass→pass | 4,963 | 5,802 | +17% | 1 | 1 | 0% | 856 | 2,153 | +152% | 0 | 0 | — |
case-05 | fail→fail | 7,105 | 6,734 | -5% | 1 | 1 | 0% | 1,280 | 1,545 | +21% | 0 | 0 | — |
case-06 | pass→pass | 6,934 | 3,892 | -44% | 1 | 1 | 0% | 1,353 | 1,874 | +39% | 0 | 0 | — |
case-07 | pass→pass | 7,714 | 5,121 | -34% | 1 | 1 | 0% | 1,522 | 2,122 | +39% | 0 | 0 | — |
case-08 | pass→pass | 8,561 | 5,700 | -33% | 1 | 1 | 0% | 1,563 | 2,255 | +44% | 0 | 0 | — |
case-09 | pass→pass | 8,302 | 3,315 | -60% | 1 | 1 | 0% | 1,509 | 1,679 | +11% | 0 | 0 | — |
case-10 | pass→pass | 11,420 | 5,361 | -53% | 1 | 1 | 0% | 1,844 | 2,020 | +10% | 0 | 0 | — |
case-11 | pass→pass | 4,757 | 3,878 | -18% | 1 | 1 | 0% | 861 | 1,747 | +103% | 0 | 0 | — |
case-12 | pass→pass | 8,726 | 2,093 | -76% | 1 | 1 | 0% | 1,117 | 1,465 | +31% | 0 | 0 | — |
case-13 | fail→pass | 6,418 | 2,345 | -63% | 1 | 1 | 0% | 1,143 | 1,516 | +33% | 0 | 0 | — |
case-14 | fail→pass | 12,887 | 3,251 | -75% | 1 | 1 | 0% | 2,081 | 1,711 | -18% | 0 | 0 | — |
case-15 | fail→pass | 14,024 | 9,679 | -31% | 1 | 1 | 0% | 2,280 | 2,918 | +28% | 0 | 0 | — |
case-16 | pass→pass | 13,143 | 7,108 | -46% | 1 | 1 | 0% | 2,144 | 2,158 | +1% | 0 | 0 | — |
case-17 | pass→pass | 6,048 | 5,940 | -2% | 1 | 1 | 0% | 988 | 2,184 | +121% | 0 | 0 | — |
case-18 | pass→pass | 9,856 | 6,194 | -37% | 1 | 1 | 0% | 1,802 | 2,238 | +24% | 0 | 0 | — |
case-19 | pass→pass | 6,531 | 7,441 | +14% | 1 | 1 | 0% | 1,185 | 2,418 | +104% | 0 | 0 | — |
case-20 | pass→pass | 7,475 | 6,521 | -13% | 1 | 1 | 0% | 1,215 | 2,125 | +75% | 0 | 0 | — |
case-21 | pass→pass | 10,537 | 9,254 | -12% | 1 | 1 | 0% | 1,829 | 2,690 | +47% | 0 | 0 | — |
case-22 | pass→pass | 6,588 | 5,118 | -22% | 1 | 1 | 0% | 1,181 | 2,009 | +70% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 20 counted toward the lift figure. The other 2 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +14 percentage points is the difference between those two pass rates over the 20 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.