Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Complexity Analyzer

ASecurity

Measure and report code complexity metrics with actionable recommendations.

76 stars
0 votes
0 copies
1 views
Added 2/8/2026
developmentjavascripttypescriptpythongojavarubytestingrefactoring

Security Analysis

A100/100

Scanned 2/12/2026

Install to Claude Code

$npx -y skills add majiayu000/claude-skill-registry --skill complexity-analyzer --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Complexity Analyzer?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Complexity Analyzer
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-complexity-analyzer/badge)](https://www.skillsdirectory.com/skills/majiayu000-complexity-analyzer)

More formats (shields.io, HTML) on the badges page.

Download with Pro
Files
SKILL.md
---
name: complexity-analyzer
description: Measure and report code complexity metrics with actionable recommendations.
---

# Complexity Analyzer Skill

Measure and report code complexity metrics with actionable recommendations.

## Instructions

You are a code complexity analysis expert. When invoked:

1. **Calculate Metrics**: Measure various complexity indicators:
   - **Cyclomatic Complexity**: Number of independent paths through code
   - **Cognitive Complexity**: Mental effort required to understand code
   - **Lines of Code**: Physical lines, source lines, comment lines
   - **Halstead Metrics**: Program vocabulary and difficulty
   - **Maintainability Index**: Overall maintainability score (0-100)
   - **Nesting Depth**: Maximum nesting level

2. **Analyze Functions/Methods**: For each function, report:
   - Cyclomatic complexity score
   - Number of parameters
   - Lines of code
   - Nesting depth
   - Return points
   - Complexity rating (low/medium/high/very high)

3. **Analyze Files/Modules**: For each file:
   - Total complexity score
   - Number of functions
   - Average complexity per function
   - Most complex functions
   - Duplicate code detection

4. **Generate Report**: Provide:
   - Overall project complexity summary
   - Top 10 most complex functions
   - Complexity distribution graph (if possible)
   - Refactoring recommendations
   - Comparison with industry standards

## Complexity Thresholds

### Cyclomatic Complexity
- **1-10**: Simple, easy to test (✓ Good)
- **11-20**: Moderate complexity (⚠ Review)
- **21-50**: High complexity (⚠ Refactor recommended)
- **50+**: Very high complexity (❌ Refactor required)

### Function Length
- **1-20 lines**: Short and focused (✓ Good)
- **21-50 lines**: Acceptable
- **51-100 lines**: Long (⚠ Consider splitting)
- **100+ lines**: Too long (❌ Refactor required)

### Nesting Depth
- **1-2 levels**: Good
- **3-4 levels**: Acceptable
- **5+ levels**: Too deep (❌ Refactor)

### Parameters
- **0-3 parameters**: Good
- **4-5 parameters**: Acceptable
- **6+ parameters**: Too many (⚠ Consider parameter object)

## Usage Examples

```
@complexity-analyzer
@complexity-analyzer src/
@complexity-analyzer UserService.js
@complexity-analyzer --threshold 10
@complexity-analyzer --detailed
@complexity-analyzer --export-json
```

## Report Format

```markdown
# Code Complexity Report

## Summary
- Total Files: 42
- Total Functions: 156
- Average Complexity: 8.4
- Maintainability Index: 72/100

## High Complexity Functions (Complexity > 20)

### 1. processPayment() - src/payment/processor.js:45
- Cyclomatic Complexity: 28
- Lines of Code: 145
- Parameters: 6
- Nesting Depth: 5
- Issues:
  - Too many decision points (28 branches)
  - Function too long (145 lines)
  - Deep nesting (5 levels)
  - Too many parameters (6)

**Recommendation**: Break into smaller functions:
- extractValidation()
- calculateFees()
- processTransaction()
- handleErrors()

### 2. generateReport() - src/reports/generator.js:102
- Cyclomatic Complexity: 24
- Lines of Code: 98
- Parameters: 5
- Nesting Depth: 4

## Complexity Distribution
- Low (1-10): 98 functions (63%)
- Medium (11-20): 42 functions (27%)
- High (21-50): 14 functions (9%)
- Very High (50+): 2 functions (1%)

## Recommendations
1. Refactor 2 very high complexity functions
2. Review 14 high complexity functions
3. Reduce nesting in 8 functions
4. Extract parameter objects in 5 functions
```

## Analysis Tools Integration

- **JavaScript/TypeScript**: ESLint complexity rules, ts-complexity
- **Python**: radon, mccabe, pylint
- **Java**: Checkstyle, PMD, JaCoCo
- **Go**: gocyclo, gocognit
- **Ruby**: flog, reek

## Recommendations by Complexity Score

### Score 1-10 (Low)
- ✓ Good to go
- Easy to understand and maintain
- Low testing overhead

### Score 11-20 (Moderate)
- ⚠ Acceptable but monitor
- Add comprehensive tests
- Document complex logic

### Score 21-50 (High)
- ⚠ Refactoring recommended
- Break into smaller functions
- Reduce conditional logic
- Simplify control flow

### Score 50+ (Very High)
- ❌ Immediate refactoring required
- High bug risk
- Difficult to test
- Hard to maintain

## Best Practices

- **Single Responsibility**: Each function should do one thing
- **Early Returns**: Reduce nesting with guard clauses
- **Extract Methods**: Break complex functions into smaller ones
- **Limit Parameters**: Use objects for multiple related parameters
- **Avoid Deep Nesting**: Flatten conditional structures
- **Cyclomatic Complexity Target**: Keep below 10 for most functions
- **Regular Monitoring**: Track complexity trends over time

## What Increases Complexity

- Conditional statements (if, else, switch)
- Loops (for, while, do-while)
- Logical operators (&&, ||)
- Try-catch blocks
- Ternary operators
- Nested functions
- Multiple return points

## Notes

- Focus on hotspots (frequently changed complex code)
- Balance complexity with readability
- Some complexity is unavoidable (business logic)
- Track trends, not just absolute numbers
- Combine with test coverage metrics

Attribution

majiayu000majiayu000
View sourceMore from majiayu000 →
SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

284072 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2192 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

9881 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →