Code Complexity Analyzer for Openclaw

A multi-language static analysis tool that measures cyclomatic, cognitive, and structural metrics to identify high-risk code.

charlie-morrison
v1.0.1
May 1, 2026
0
926
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install code-complexity-analyzer

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-complexity-analyzer 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 Complexity Analyzer?

The Code Complexity Analyzer is a robust utility designed to maintain high engineering standards by quantifying how difficult code is to test and maintain. By integrating this within your Openclaw Skills library, developers can automatically scan source code for deep nesting, overly long functions, and complex logical paths that lead to technical debt.

Built as a pure Python tool with no external dependencies, it provides an efficient way to evaluate Python, JavaScript, TypeScript, and Go files. It helps teams move beyond simple linting by focusing on the perceived difficulty of understanding code (Cognitive Complexity) and the number of independent execution paths (Cyclomatic Complexity).

Code Complexity Analyzer Use Cases

  • Identifying refactoring candidates in legacy codebases by pinpointing high-risk functions.
  • Setting up CI/CD quality gates to prevent overly complex code from being merged.
  • Generating automated complexity reports in Markdown for pull request reviews.
  • Auditing new dependencies or internal modules for maintainability and structural integrity.

How Code Complexity Analyzer Works

  1. The tool parses the target source files into an Abstract Syntax Tree (AST) for the respective language.
  2. It traverses the tree to identify function definitions and logical control structures like loops and conditionals.
  3. It calculates metrics including Cyclomatic Complexity (CC), Cognitive Complexity (COG), and nesting depth based on the structure.
  4. It compares these values against configurable thresholds to determine risk levels (Simple, Low, Moderate, or High).
  5. Finally, it outputs the results in text, JSON, or Markdown format and returns an exit code based on violation status.

Code Complexity Analyzer Setup

To start using this tool with your Openclaw Skills, ensure you have Python 3 installed. No additional pip installations are required.

# Clone or locate the script
# Analyze your source directory
python3 scripts/analyze_complexity.py src/

# Run with custom thresholds for a stricter CI gate
python3 scripts/analyze_complexity.py src/ --cc 8 --cog 12

Code Complexity Analyzer Data Schema & Taxonomy

The analyzer organizes its findings based on function-level granularity. It tracks the following taxonomy for every analyzed file:

Metric Description Indicator
CC Cyclomatic Complexity Logic paths
COG Cognitive Complexity Readability score
Lines Function Length Vertical scale
Params Parameter Count Interface surface
Nesting Max Depth Logic indentation

Output results can be exported as a structured JSON object for integration into other Openclaw Skills workflows.

Code Complexity Analyzer Advanced Features

  • Multi-format output support (JSON, Markdown, Text) for seamless tool integration.
  • Configurable risk-level mapping to differentiate between minor technical debt and critical hazards.
  • Automatic exclusion of common directories like node_modules and pycache.
  • Verbose mode for full transparency into all functions, not just those violating thresholds.
  • Standardized exit codes (0, 1, 2) for easy integration into shell scripts and automation pipelines.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*