Code Complexity Analysis
Measuring and reducing cyclomatic complexity and cognitive complexity to improve maintainability.
Install
/plugin marketplace add sethdford/claude-skillsThe repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.
npx skills add sethdford/claude-skills --skill code-complexity-analysisgit 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-analysisPersonal 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
Details
- Skill name
code-complexity-analysis- Repository
- sethdford/claude-skills
- 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
A B Test Design
48sethdford/claude-skills
Design rigorous A/B tests with hypotheses, variants, metrics, and sample size calculations.
A B Test Design Pm
48sethdford/claude-skills
Analytics and experimentation skill for product managers.
Abuse Case Design
48sethdford/claude-skills
Design abuse cases (negative use cases) showing how attackers misuse system features. Use when identifying attacks that exploit intended functionality or business logic flaws.
Code Review Standards
48sethdford/claude-skills
Establish clear, enforceable code review standards that balance quality with velocity, enabling asynchronous review and knowledge sharing. Use when creating or updating review expectations, scaling engineering teams, or improving code quality metrics.
Cloud Architecture
48sethdford/claude-skills
Design cloud infrastructure for AWS, GCP, or Azure. Plan compute, storage, networking, and compliance. Use when architecting cloud systems or migrating to cloud.
Code Smell Detector
48sethdford/claude-skills
Identify code smells like long methods, duplication, low cohesion, and high coupling. Use when assessing code health.
Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.