- Home
- Skills
- Code Quality & Review
- Complexity Analyzer
Works with the AI Agents you already use
Complexity Analyzer
Measure cyclomatic complexity and git churn to identify high-risk code hotspots and enforce quality gates.
$1.99
Complexity Analyzer
Example session with this skill installed
Run a complexity analysis on the src/ directory, rank the top 10 functions, and include git churn data to find hotspots.
- Read your context and instructions
- Compiled the complexity analyzer
Analyzed 42 files in src/. Identified 127 functions. Correlated complexity scores with git commit history to identify high-risk hotspots.
Code Complexity & Hotspot Report
| Function | File | Grade | Complexity | Churn (Commits) | Hotspot Score |
|---|---|---|---|---|---|
process_order_v2 | src/orders.py | F | 48 | 85 | 4080 |
validate_payload | src/api/utils.ts | E | 34 | 12 | 408 |
calculate_tax_calc | src/finance.py | D | 28 | 42 | 1176 |
handle_websocket | src/net/ws.go | C | 18 | 5 | 90 |
init_database | src/db/core.py | B | 9 | 15 | 135 |
format_response | src/api/utils.ts | B | 7 | 20 | 140 |
get_user_meta | src/auth.py | A | 4 | 3 | 12 |
log_event | src/logger.py | A | 2 | 50 | 100 |
check_permission | src/auth.py | A | 5 | 8 | 40 |
parse_config | src/config.py | A | 3 | 2 | 6 |
Analysis Summary:
Critical Risk: process_order_v2 in orders.py has a Grade F complexity and high churn. It is the primary candidate for refactoring.
Testing Gap: calculate_tax_calc shows high churn (42 commits) but moderate complexity (Grade D). Ensure full branch coverage here.
Maintainability: The api/utils.ts file is growing in complexity across multiple functions; consider splitting this utility file.
Next steps
- Run
python3 scripts/complexity.py src/orders.py --max 15to identify specific blocks for extraction. - Refactor
process_order_v2by extracting the nested conditional logic into standalone private functions. - Add the
--failflag to your CI pipeline to prevent new Grade E or F functions from being merged.
Connects securely to your tools. The creator never sees your data.
About this skill
Legacy codebases often hide technical debt in bloated functions that are impossible to test. This skill identifies the riskiest logic by measuring cyclomatic complexity, nesting depth, and parameter counts across multiple languages.
What it does
- Multi-language analysis measures Python via AST and uses brace-aware heuristics for JS, TS, Java, C#, Go, PHP, Ruby, Kotlin, and C++.
- Complexity grading assigns A through F marks to functions based on scoring thresholds from 1 to 41+.
- Hotspot identification combines code complexity with git churn to find frequently changed, high-risk files.
- CI enforcement provides exit codes to fail builds when functions exceed a defined complexity maximum.
- Data export generates CSV or JSON files for integration with engineering dashboards or reporting tools.
How it works
- Run a scan on a directory or specific file to generate a ranked list of the top complex functions.
- Apply the churn flag to correlate complexity with commit history, highlighting where bugs are most likely to live.
- Set a complexity threshold to trigger failures in CI pipelines for functions exceeding specific limits.
Frameworks & tools
The analyzer uses Python 3 for the core logic, utilizing the ast module for Python-specific parsing and standard regex/brace counting for other languages.
Why this beats prompting it yourself
Manual code reviews often miss deep nesting or high cyclomatic counts in large files. This tool provides deterministic metrics and mathematical rankings that standard LLM prompts cannot consistently replicate across thousands of lines of code.
Use cases
- Identify high-priority refactoring targets in a legacy monolith.
- Prevent technical debt by blocking complex PRs in CI/CD pipelines.
- Generate risk reports for engineering leadership during project handovers.
- Prioritize unit test coverage for functions with high cyclomatic scores.
Known limitations
Heuristics for non-Python languages may miscount complexity in highly unconventional syntax or template-heavy C++ code. Requires Python 3 installed on the runner.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Code Quality & Review.
Heuristics for non-Python languages may miscount complexity in unconventional syntax. Requires Python 3 on the host machine.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 1 month ago