code-metrics

Calculate Python codebase metrics including complexity, lint warnings, and test coverage.

1|1|Updated Feb 4, 2026
One-click install
npx skills add https://github.com/brianlan/improved-ai-agent --skill code-metrics-brianlan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-metrics
Source: https://github.com/brianlan/improved-ai-agent/tree/main/skills/code-metrics
Command: npx skills add https://github.com/brianlan/improved-ai-agent --skill code-metrics-brianlan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Analyze Python codebases to generate comprehensive metrics including physical size, logical size, complexity, maintainability, lint warnings, and test coverage to help teams measure quality and plan improvements.

Core Features & Use Cases

  • Physical size metrics (SLOC, LOC, files) for quick health checks.
  • Logical size & complexity (classes, methods, functions, max CC, maintainability index) to identify hotspots.
  • Code quality & test metrics (ruff warnings, pytest coverage) to drive refactors and QA.
  • Use Case: Compare multiple directories (prefusion, tools, contrib, tests) to spot architectural gaps and debt.

Quick Start

Analyze a Python project by running the analyze_codebase.py script to generate a metrics report.

Frequently Asked Questions about code-metrics

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

FAQPage Schema
How do I calculate cyclomatic complexity and maintainability index for a Python project?

To calculate cyclomatic complexity and maintainability index for a Python project, the Skill analyzes your directories using radon to compute these metrics, identify hotspots, and generate a structured JSON report alongside a readable summary.

What's the best way to measure test coverage and lint warnings across multiple project directories?

Measuring test coverage and lint warnings across multiple directories involves running ruff and pytest with coverage tools to extract quality metrics, outputting a structured JSON report alongside a readable summary to spot architectural debt.

Can I analyze physical size metrics like SLOC and LOC for specific Python directories?

Yes, you can analyze physical size metrics like SLOC, LOC, and file counts for specific Python directories such as prefusion, tools, contrib, or tests by running the codebase analysis script to generate quick health check reports.

Does the codebase analysis exclude configuration files when running cloc and radon?

Yes, the codebase analysis excludes the configs directory by default when running cloc and radon to ensure physical and logical size metrics focus on core project code rather than configuration files.

What Python code quality metrics are needed to identify refactoring hotspots?

Identifying refactoring hotspots requires Python code quality metrics including cyclomatic complexity, maintainability index, max CC, ruff lint warnings, and test coverage insights, which are generated together in a comprehensive codebase analysis report.

How to generate a structured JSON report of Python codebase statistics?

You can generate a structured JSON report of Python codebase statistics by running the analyze_codebase.py script, which aggregates physical size, complexity, lint warnings, and pytest coverage metrics into a machine-readable output alongside a readable report.