Code Complexity Analysis

Measuring and reducing cyclomatic complexity and cognitive complexity to improve maintainability.

48 stars 10 forksSoftware Development Plugin marketplace

Install

Claude Code plugin
/plugin marketplace add sethdford/claude-skills

The repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add sethdford/claude-skills --skill code-complexity-analysis
Manual install
git clone --depth 1 https://github.com/sethdford/claude-skills.git /tmp/claude-skills
mkdir -p ~/.claude/skills
cp -r /tmp/claude-skills/engineer/code-quality/skills/code-complexity-analysis ~/.claude/skills/code-complexity-analysis

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# Code Complexity Analysis

Quantifying and reducing the inherent difficulty of code.

## Context

You are helping the engineer measure and reduce code complexity. If code is provided, calculate metrics and suggest decomposition strategies. Complexity is a primary predictor of bugs.

## Domain Context

- **Cyclomatic Complexity**: Number of independent paths through code; each decision point adds 1
- **Cognitive Complexity**: How hard is it for a human to understand? Nesting, jumps, and abstractions add cost
- **Threshold**: Cyclomatic complexity > 10 is a smell; > 15 demands refactoring
- **Testing Cost**: Each decision path requires a test; high complexity means high test burden
- **Maintenance Cost**: High complexity → higher bug rate, slower changes

## Instructions

1. **Count Decisions**: Count if/else, switch, loops, operators; each adds 1 to cyclomatic complexity
2. **Check Nesting**: Each nested level adds cognitive cost; avoid nesting > 3 levels deep
3. **Identify Polymorphism Opportunities**: Replace switch/if chains with strategy pattern
4. **Extract Complex Conditions**: Move boolean logic to named methods or variables
5. **Break Long Methods**: Extract sub-methods even if called once; improves understanding
6. **Use Early Returns**: Guard clauses reduce nesting and improve readability
7. **Reduce Parameters**: Complex signatures add cognitive load; use parameter objects
8. **Test Complexity**: If > 10 tests needed for one method, it's too complex
Read the full skill on GitHub

Details

Skill name
code-complexity-analysis
Path
engineer/code-quality/skills/code-complexity-analysis/SKILL.md
License
MIT
Repo updated
11 March 2026

FAQ

What does the Code Complexity Analysis skill do?

Measuring and reducing cyclomatic complexity and cognitive complexity to improve maintainability.

How do I install the Code Complexity Analysis skill?

Claude Code plugin: /plugin marketplace add sethdford/claude-skills. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Code Complexity Analysis popular?

It lives in sethdford/claude-skills, which has 48 GitHub stars and 10 forks.

Related skills

Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.