code-complexity-analyzer

Measure cyclomatic complexity, cognitive complexity, and structural metrics for Python, JavaScript/TypeScript, and Go code. Use when analyzing code quality, finding complex functions, setting CI quality gates, reviewing code for refactoring candidates, or generating complexity reports. Supports per-function metrics, configurable thresholds, risk levels, and multiple output formats (text, JSON, markdown).

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "code-complexity-analyzer" with this command: npx skills add charlie-morrison/code-complexity-analyzer

Code Complexity Analyzer

Measure cyclomatic, cognitive, and structural complexity per function. Pure Python, no dependencies.

Quick Start

# Analyze a directory
python3 scripts/analyze_complexity.py src/

# Analyze specific files
python3 scripts/analyze_complexity.py app.py utils.py

# Show all functions (not just violations)
python3 scripts/analyze_complexity.py src/ --verbose

# Custom thresholds
python3 scripts/analyze_complexity.py src/ --cc 15 --cog 20 --max-lines 80

Output Formats

python3 scripts/analyze_complexity.py src/ --format text      # human-readable (default)
python3 scripts/analyze_complexity.py src/ --format json       # CI/tooling
python3 scripts/analyze_complexity.py src/ --format markdown   # reports

Supported Languages

  • Python (.py)
  • JavaScript (.js, .jsx, .mjs, .cjs)
  • TypeScript (.ts, .tsx)
  • Go (.go)

Metrics

MetricDescriptionDefault Threshold
Cyclomatic (CC)Independent execution paths≤10
Cognitive (COG)Perceived difficulty to understand (nesting-weighted)≤15
LinesFunction length≤50
ParamsParameter count≤5
NestingMax nesting depth≤4

Risk Levels

  • 🟢 Simple — CC≤5, COG≤8
  • 🟡 Low — CC≤10, COG≤15
  • 🟠 Moderate — CC≤20, COG≤25
  • 🔴 High — CC>20 or COG>25

Options

--cc N           Cyclomatic threshold (default: 10)
--cog N          Cognitive threshold (default: 15)
--max-lines N    Function length threshold (default: 50)
--max-params N   Parameter count threshold (default: 5)
--max-nesting N  Nesting depth threshold (default: 4)
--exclude DIR    Additional directories to exclude
--verbose, -v    Show all functions, not just violations

Auto-excluded: node_modules, .git, __pycache__, venv, dist, build.

Exit Codes

  • 0 — no violations
  • 1 — violations found (functions exceed CC or COG thresholds)
  • 2 — no analyzable files found

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

YiHui GIT MONITOR

通用 Git 项目监控工具。支持 GitHub、GitLab、Gitee 等所有 Git 平台。可以添加、删除、检查任意 Git 仓库的更新,自动拉取代码并生成变更摘要。

Registry SourceRecently Updated
Coding

Workspace Governance

A methodology-first workspace governance skill for AI agents. Focuses on principles, decision framework, and safe execution patterns instead of fixed directo...

Registry SourceRecently Updated
Coding

Nox Influencer - Creator Discovery & Influencer Marketing

Runs NoxInfluencer creator and marketing-ops workflows via CLI, including creator discovery for influencer marketing, creator marketing, UGC, social media ma...

Registry SourceRecently Updated
Coding

Gigo Lobster Doctor

🦞 GIGO · gigo-lobster-doctor: 环境体检模式:只检查 gateway、Python 依赖、题包链路与 PNG 证书能力,不跑正式试吃。 Triggers: 龙虾体检 / 检查龙虾环境 / lobster doctor / check lobster environment.

Registry SourceRecently Updated