measure-complexity

Measures cyclomatic complexity and maintainability index with radon to rank refactoring candidates.

1|Updated Aug 14, 2026
One-click install
npx skills add https://github.com/zhiyuan-zhang0206/Ava --skill measure-complexity-zhiyuan-zhang0206
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: measure-complexity
Source: https://github.com/zhiyuan-zhang0206/Ava/tree/main/.agents/skills/measure-complexity
Command: npx skills add https://github.com/zhiyuan-zhang0206/Ava --skill measure-complexity-zhiyuan-zhang0206

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires radon.

What problem does it solve? Python codebases accumulate complex functions that are hard to test and risky to change, but teams lack a quick, objective way to locate the worst offenders. This Skill runs a mechanical complexity scan that pinpoints exactly which functions and modules deserve refactoring attention first. ## Core Features & Use Cases - Cyclomatic complexity scan: Runs radon cc per function with numeric scores, A–F ranks, and repo-wide averages, with JSON output for machine processing. - Threshold-based ranking: Flags functions above a configurable complexity threshold (default cc > 10) and sorts them descending into a ranked hotspot report with file:line:function locations. - Maintainability index: Computes per-module MI (0–100) via radon mi to find structurally hard-to-maintain modules even when individual functions look fine. - Use Case: Before a sprint dedicated to tech debt, run the scan across the source tree, cross-check high-cc functions against low-MI modules and git blame history, then refactor the top hotspots with behavior-pinning tests and prove the cc drop in the PR. ## Quick Start Ask the agent to run the measure-complexity skill to scan the repository and list the functions with cyclomatic complexity above 10 ranked from highest to lowest.

Frequently Asked Questions about measure-complexity

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I measure cyclomatic complexity in Python?▼

Run radon cc with the -s flag to show numeric complexity scores per function, for example `uvx radon cc -a -s path/to/file.py`. The -a flag adds an average at the end, and -j emits JSON for machine processing.

How to find functions above a complexity threshold with radon?▼

Use the -n flag to set the minimum displayed complexity, so a threshold of 10 means `-n 11`, and add `-o SCORE` to sort by complexity descending. For machine-readable output, filter the JSON from `radon cc -j` where complexity exceeds your threshold.

What is a good cyclomatic complexity number?▼

Complexity of 1–5 is simple and fine as-is, 6–10 is moderate and worth watching, 11–20 marks refactor candidates, and 21+ indicates priority debt where bugs concentrate. The threshold is a judgment dial since parsers and state machines can legitimately score higher.

Is radon a required dependency for this repo?▼

No, radon is not listed as a dev dependency in pyproject.toml. The recommended approach is running it via `uvx radon`, which downloads it into the uv cache without changing the repo; alternatively install it into the venv or add it with `uv add --dev radon`.

What is the maintainability index and how is it interpreted?▼

The maintainability index is a 0–100 per-module score computed from Halstead volume, cyclomatic complexity, lines of code, and comment ratio, obtained via `radon mi -s`. Rank A is above 19, B is 9–19, and C is 9 or below, with low MI signaling modules that are structurally hard to maintain.

When should a high complexity score not trigger a refactor?▼

High complexity is acceptable when the logic is inherently branched, such as a parser, state machine, or decision table. The scan is a locator rather than a gate, so read the flagged function first to decide whether it needs extraction, guard clauses, or a dispatch table.