Code Metrics Analysis for Openclaw

A comprehensive code auditing tool that measures complexity, line counts, and documentation density across multiple programming languages.

johnnywang2001
v1.0.0
Mar 24, 2026
0
900
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install code-metrics

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install code-metrics using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Code Metrics Analysis?

The Code Metrics skill is a robust diagnostic utility designed for developers who need a granular understanding of their codebase health. By integrating this capability into Openclaw Skills, users can instantly generate reports on structural complexity and documentation ratios, ensuring that technical debt is identified before it becomes a bottleneck.

This tool performs deep analysis on 17+ languages, including Python, Rust, and Go. It provides a unique lens into project maintainability by calculating cyclomatic complexity for Python and ranking the largest files in a directory to pinpoint areas in need of refactoring.

Code Metrics Analysis Use Cases

  • Performing a comprehensive code audit during a project hand-off or onboarding.
  • Identifying high-risk, overly complex Python functions that require refactoring.
  • Measuring the effectiveness of documentation by calculating comment-to-code ratios.
  • Generating automated project overviews for technical stakeholders within Openclaw Skills.
  • Ranking files by size to identify monolithic components in a microservices architecture.

How Code Metrics Analysis Works

  1. The skill initializes by scanning the target directory, respecting default and user-defined exclusions like migrations or fixtures.
  2. It categorizes files by language and parses them to count lines of code, blank lines, and comments.
  3. For Python files, an AST-based parser calculates the cyclomatic complexity of every function and class.
  4. Data is aggregated into a global project overview, including documentation density and function counts.
  5. The tool ranks files by code volume and flags functions exceeding complexity thresholds (10+ or 15+).
  6. Results are outputted to the console or generated as a structured JSON object for further automation.

Code Metrics Analysis Setup

The Code Metrics skill is designed to run with zero external dependencies using Python 3.8+.

# Analyze the current project directory
python3 scripts/code_metrics.py

# Analyze a specific project path
python3 scripts/code_metrics.py /path/to/target/project

# Exclude specific directories from the analysis
python3 scripts/code_metrics.py --exclude migrations fixtures

Code Metrics Analysis Data Schema & Taxonomy

The skill produces a structured report that organizes codebase data into the following taxonomy:

Metric Category Data Points Included
Language Breakdown Total lines, code lines, comments, and blank lines per extension.
Structural Totals Total counts of functions and classes across the codebase.
Python Complexity Per-function cyclomatic complexity scores (AST-based).
File Rankings Top N files sorted by raw code line volume.
Quality Flags Warnings for functions with complexity $\ge$ 5.

Code Metrics Analysis Advanced Features

  • Multi-language support for 17+ formats including TypeScript, Swift, Kotlin, and Scala.
  • Structured JSON output mode (--json) for integration with CI/CD pipelines or custom dashboards.
  • Selective complexity analysis using the --no-complexity flag for faster performance on massive codebases.
  • Native AST-based complexity parsing for Python that requires no third-party libraries.
  • Configurable exclusion engine to filter out noise from third-party libraries or generated assets.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*